22 lines
549 B
PHP
22 lines
549 B
PHP
<?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()]); // 删除时间设置为当前时间,即删除
|
|
});
|
|
|
|
|
|
}
|
|
} |