我有一个每月定期账单,我想在到期前 6 天向该人发送一封电子邮件,如果已经发送,则不要重新发送。在 PHP 中工作。我目前在数据库中有两列:paidUntil 和 sentReminder,都是 DATETIME,但我可以根据需要进行更改。
所以,在伪代码中:
IF(between 6 days before expiration and expiration date AND reminder NOT sent)
send reminder
set that reminder was already sent
else
if the month has past and time for new reminder, go back to top
下个月,重新开始整个过程。请注意,人们可以在每月的 1 日、9 日或任何给定日期到期。请帮忙!
编辑: 我基本上想在每个月的会员到期前 6 或 5 天向某人发送一次提醒。就这样。这是我的一些代码,但我一直在犹豫如何检查我发送最后一次提醒的时间是否已经过得足以生成一个新的......抱歉这里的所有评论!
$paidUntil = strtotime($oneUser->paidUntil);
$paidUntilMonthPrior = strtotime('-1 month', $paidUntil);
$reminderSent = strtotime($oneUser->reminderSent);
//$paidDateRemindRange = strtotime('-6 days', $paidUntil); //6 days till u remind somebody
$noNeedToSend = strtotime('+25 days', $reminderSent);
//$paidDateReset = strtotime('+1 day', $paidUntil);
//if($thisMonth==date('F',$paidUntil)) {
// $sameMonth=true;
//}
//if($todayTime>$paidDateReminder && $todayTime<$paidUntil && $todayTime>$reminderSent)
// $expirationRange=true;
if($todayTime < $noNeedToSend) {
// is within 25 days from last sending - do nothing
}
elseif($todayTime>$noNeedToSend && $todayTime<$paidUntil) {
//is between 25 days and still less than the paid until time AND has not been sent this cycle
// send expiration email and mark that its been sent
$expirationRange=true;
}