allocatr/application/common/command/CheckOrderDispatchCommand.php
2025-04-18 14:39:12 +08:00

42 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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);
}
});
$output->info('OVER');
}
}