allocatr/application/common/command/CheckOrderDispatchCommand.php
2025-03-31 15:15:41 +08:00

43 lines
1.0 KiB
PHP

<?php
namespace app\common\command;
use app\admin\model\OrderDispatch;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Hook;
class CheckOrderDispatchCommand extends Command
{
protected function configure()
{
$this->setName('check:dispatch-overtime')
->setDescription('检测dispatch表超时任务');
}
protected function execute(Input $input, Output $output){
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s');
$Model->where('status',OrderDispatch::STATUS_PLANIT)
->where('plan_time','<=',$now)
->chunk(100, function ($list) {
foreach ($list as $item) {
//1修改为超时
$item->status = OrderDispatch::STATUS_OVERTIME;
$item->save();
$params = ['dispatch'=>$item,'remark'=>'系统自动处理,任务超时'];
Hook::listen('order_dispatch_change',$params);
}
});
}
}