feat(process): 添加任务处理功能
This commit is contained in:
parent
4c1a07e598
commit
d43d26163f
@ -40,4 +40,7 @@ return [
|
||||
]
|
||||
]
|
||||
],
|
||||
'task' => [
|
||||
'handler' => process\Task::class
|
||||
],
|
||||
];
|
||||
|
22
process/Task.php
Normal file
22
process/Task.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace process;
|
||||
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use Workerman\Crontab\Crontab;
|
||||
|
||||
class Task
|
||||
{
|
||||
public function onWorkerStart()
|
||||
{
|
||||
|
||||
// 每5分钟执行一次
|
||||
new Crontab('0 */10 * * * *', function(){
|
||||
$where=['paid'=>0];
|
||||
$where[]=['create_time','<',time() - 600];// 10分钟前创建的订单
|
||||
// 删除10分钟未支付的订单
|
||||
StoreOrder::where($where)->update(['delete_time'=>time()]); // 删除时间设置为当前时间,即删除
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user