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

43 lines
1.1 KiB
PHP

<?php
namespace app\common\command;
use app\admin\model\Order;
use app\admin\model\OrderDispatch;
use app\common\Logic\OrderLogic;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Hook;
class CheckOrderDispatchGotCommand extends Command
{
protected function configure()
{
$this->setName('check:dispatch-toget')
->setDescription('dispatch未接单通知,每五分钟检测一次');
}
protected function execute(Input $input, Output $output){
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s',time()-30*60); //创建三十分名以上未接的任务
$now2 = date('Y-m-d H:i:s',time()-30*600); //上次通知在30分钟以前
$OrderLogic = new OrderLogic();
$Model->where('status',OrderDispatch::STATUS_TOGET)
->where('create_time','<=',$now)
->where('notice_time','<=',$now2)
->chunk(100, function ($list) use ($OrderLogic){
foreach ($list as $item) {
$OrderLogic->noWorkerCanGetIt($item);
}
});
$output->info('OVER');
}
}