feat(process/Task.php): 修改订单删除逻辑及定时任务

This commit is contained in:
mkm 2024-09-18 11:13:38 +08:00
parent 19be49f0d5
commit 80bf6eaf4f

View File

@ -23,7 +23,7 @@ class Task
new Crontab('0 */10 * * * *', function () {
$where = ['paid' => 0];
$where[] = ['create_time', '<', time() - 600]; // 10分钟前创建的订单
$where[] = ['source', '<',2];
$where[] = ['source', '<=',1];
// 删除10分钟未支付的订单
$oid = StoreOrder::where($where)->column('id'); // 删除时间设置为当前时间,即删除
if ($oid) {
@ -39,17 +39,6 @@ class Task
//删除未充值的订单
UserRecharge::where('paid', 0)->where('status', 1)->where('create_time', '<', $oneHourAgo)->update(['delete_time' => time()]);
});
new Crontab('0 */1 * * * *', function () {
$endTime = time();
// 计算10分钟前的时间戳
$startTime = $endTime - 10 * 60;
$arr = UserRecharge::where('paid', 0)->where('status', 1)->whereBetweenTime('create_time', $startTime, $endTime)->column('order_id');
foreach ($arr as $v) {
Redis::send('task-recharge-query', ['order_id' => $v]);
}
});
//每10秒执行一次
new Crontab('*/10 * * * * *', function () {
$select=Db::name('wechat_micropay')->limit(100)->select();