1.这是一段代码
public function getSatisfyRecall($orders, $maxDays)
{
$day = 15;
$time = time();
$upper = null;
$returnRemindOrder = null;
foreach ($orders as $index => $orderItem) {
$timePassed = floor(($time - $orderItem['receive_time']) / 86400);
if ($index == 0) {
$maxDay = $maxDays[$orderItem['days_map']][1] ?? -1;
if ($maxDay >= $timePassed) {
$orders[0]['user_type'] = 1;
$returnRemindOrder = $orders[0];
break;
}
}
if ($upper && $index <= 2) {
$diffDays = floor(($orderItem['receive_time'] - $upper['receive_time']) / 86400);
if ($diffDays <= $day) {
$userType = $index === 2 ? 2 : 1;
$maxDay = $maxDays[$orderItem['days_map']][$userType] ?? -1;
if ($maxDay >= $timePassed) {
$upper['user_type'] = $userType;
$returnRemindOrder = $upper;
break;
}
} else {
$userType = $index === 2 ? 3 : 2;
$maxDay = $maxDays[$orderItem['days_map']][$userType] ?? -1;
if ($maxDay >= $timePassed) {
$orderItem['user_type'] = $userType;
$returnRemindOrder = $orderItem;
break;
}
}
}
if ($index >= 3) {
$maxDay = $maxDays[$upper['days_map']][3] ?? -1;
$timePassed = floor(($time - $upper['receive_time']) / 86400);
if ($maxDay >= $timePassed) {
$upper['user_type'] = 3;
$returnRemindOrder = $upper;
break;
} else {
// 保证多次复购签收回访已经完全推送完成,切当前订单在推送时间范围内
$currentReceiveTime = $upper['receive_time'] + ($maxDay * 86400);
if ($orderItem['receive_time'] >= $currentReceiveTime && $maxDay >= floor(($time - $orderItem['receive_time']) / 86400)) {
$orderItem['user_type'] = 3;
$returnRemindOrder = $orderItem;
break;
}
}
}
$upper = $orderItem;
}
return $returnRemindOrder;
}
发表回复