更新 线下预约 推送和取消逻辑

main
yanzai 2 months ago
parent 982df592f3
commit 7f55a939b4

@ -758,12 +758,13 @@ class OrderNewController extends Controller
$type = request('type');//1通知2取消
$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');
// 时间点3当前时间 +6 天(你定义了 $date3但没用上这里也加上可选
$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');
// 时间点3date1 + 8 天
$date3 = (clone $now)->modify('+22 days')->format('Y-m-d H:i:00');
$currentTime = $now->format('Y-m-d H:i:00');
if($type==1){
$AspZhuan = new AspNetZhuanController();
@ -813,10 +814,15 @@ class OrderNewController extends Controller
->where('status', 1)
->where('source', 'LIKE', '%线下体检预约%')
->where(function ($query) use ($date3, $currentTime) {
// 条件组:满足任一即可
$query->whereRaw('TIMESTAMP(appointment_date, appointment_time) = ?', [$date3]) // 精确匹配 +6天
->orWhereRaw('TIMESTAMP(appointment_date, appointment_time) < ?', [$currentTime]); // 小于当前时间
})->get();
// 条件1offline_sendmsg_status 在 [1,2] 且 预约时间 = +6天
$query->where(function ($q) use ($date3) {
$q->whereIn('offline_sendmsg_status', [1, 2])
->whereRaw('TIMESTAMP(appointment_date, appointment_time) = ?', [$date3]);
})
// 条件2预约时间已过期不管 offline_sendmsg_status 是多少)
->orWhereRaw('TIMESTAMP(appointment_date, appointment_time) < ?', [$currentTime]);
})
->get();
$do = new OrderService();
foreach ($order_cancels as $order) {
$orderids[]=$order->id;

@ -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');
// 时间点3date1 + 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",
[
@ -47,17 +51,22 @@ function OfflineOrderCheckFunc()
"SELECT COUNT(1) AS c
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);
}
}

Loading…
Cancel
Save