@ -23,17 +23,21 @@ function OfflineOrderCheckFunc()
$db = Db::get();
$now = new DateTime();
// 时间点1: 当前时间 +1 个月
$date1 = (clone $now)->modify('+1 month')->format('Y-m-d H:i:00');
// 时间点2: 当前时间 +7 天
$date2 = (clone $now)->modify('+7 days')->format('Y-m-d H:i:00');
$date3 = (clone $now)->modify('+6 days')->format('Y-m-d H:i:00');
$date2 = (clone $now)->modify('+23 days')->format('Y-m-d H:i:00');
// 时间点3: date1 + 8 天
$date3 = (clone $now)->modify('+22 days')->format('Y-m-d H:i:00');
$currentTime = $now->format('Y-m-d H:i:00');
$order_tongzhi = $db->getRow(
"SELECT COUNT(1) AS c
FROM orders
WHERE status = ?
AND TIMESTAMP(appointment_date, appointment_time) IN (?, ?)
AND
((TIMESTAMP(appointment_date, appointment_time) IN (?) and offline_sendmsg_status=0) or (TIMESTAMP(appointment_date, appointment_time) IN (?) and offline_sendmsg_status in(0,1)))
AND source LIKE ?
AND offline_sendmsg_status < > 2",
[
@ -45,19 +49,24 @@ function OfflineOrderCheckFunc()
);
$order_cancel = $db->getRow(
"SELECT COUNT(1) AS c
FROM orders
WHERE status = ?
FROM orders
WHERE status = ?
AND source LIKE ?
AND (
TIMESTAMP(appointment_date, appointment_time) = ?
-- 条件1: 预约时间 = +6天 且 offline_sendmsg_status 在 (1,2)
(TIMESTAMP(appointment_date, appointment_time) = ?
AND offline_sendmsg_status IN (1,2))
OR
TIMESTAMP(appointment_date, appointment_time) < ?
)
AND source LIKE ?",
-- 条件2: 预约时间 < 当前时间(已过期),不关心 offline_sendmsg_status
(TIMESTAMP(appointment_date, appointment_time) < ?)
)",
[
1,
'%线下体检预约%',
$date3, // 条件1: +6天
$currentTime, // 条件2: 小于当前时间
'%线下体检预约%'
$currentTime // 条件2: 小于当前时间
]
);
if ($order_tongzhi['c'] > 0) {
@ -65,7 +74,7 @@ function OfflineOrderCheckFunc()
} else if ($order_cancel['c'] > 0){
OfflineOrderCheck(2);
}else {
Tool::log('未检测到任务');
Tool::log('下线预约订单 未检测到任务, date1: '.$date1.',date2:'.$date2.',date3:'.$date3.',currentTime:'.$currentTime );
}
}