allocatr/application/common/command/CheckOrdeRecordCommand.php
2025-04-16 10:34:26 +08:00

45 lines
1.3 KiB
PHP

<?php
namespace app\common\command;
use app\admin\model\OrderDispatch;
use app\admin\model\OrderDispatchRecord;
use think\console\Command;
use think\console\Input;
use think\console\Output;
class CheckOrdeRecordCommand extends Command
{
protected function configure()
{
$this->setName('check:dispatch-record-notice')
->setDescription('dispatch跟进记录通知,每分钟一次');
}
protected function execute(Input $input, Output $output){
$Model = new OrderDispatchRecord();
$now = date('Y-m-d H:i:s'); //创建三十分名以上未接的任务
//$Model->where('need_notice',1)
$Model->where('notice_time','<=',$now)
->where('status',0)
->chunk(100, function ($list) {
$ids = [];
$dispatchIds = [];
foreach ($list as $item) {
$ids[] = $item->id;
$dispatchIds[] = $item->dispatch_id;
//修改状态
if($item->need_notice == 1){ //需要通知
}
}
OrderDispatchRecord::whereIn('id',$ids)->update(['status'=>1]);
OrderDispatch::where('id',$dispatchIds)->where('follow',1)->update(['follow'=>0]);
});
}
}