This commit is contained in:
xman 2025-06-04 20:48:44 +08:00
parent 61ef1d0d39
commit 459f094718
10 changed files with 107 additions and 62 deletions

View File

@ -88,28 +88,35 @@ class Dispatch2 extends Backend
$row->follow = 2;
OrderDispatch::where('id',$row->id)->update(['follow'=>2]);
}
if($row->btn_record ){
if($row->type == 2)
{
if($row->btn_record){
if($row->follow ==1 ){
$row->btn_record = true;
}else{
$row->btn_record = false;
$now = date('Y-m-d H:i:s');
//未上门
if($row->status == OrderDispatch::STATUS_PLANIT){ //待上门
if(empty($row->arrive_time))
{
if($row->plan_time < $now)
{
$row->btn_record = true;
}
}else{
//已上门 完成时间超了
if($row->estimated_finish_time < $now)
{ //预估完成时间过了
$row->btn_record = true;
}
}
}
}
// if($row->type == 2)
// {
// $row->btn_record = false;
// $now = date('Y-m-d H:i:s');
// //未上门
// if($row->status == OrderDispatch::STATUS_PLANIT){ //待上门
// if(empty($row->arrive_time))
// {
// if($row->plan_time < $now)
// {
// $row->btn_record = true;
// }
// }else{
// //已上门 完成时间超了
// if($row->estimated_finish_time < $now)
// { //预估完成时间过了
// $row->btn_record = true;
// }
// }
// }
// }
}
// $row->btn_income = (in_array($row->status, $this->model->btnActiveStatusList('btn_income')) && in_array($row->order->status, $orderModel->incomeBtnStatus())) ? true : false;

View File

@ -124,6 +124,8 @@ class Dispatchrecord extends Backend
$params['notice_time'] = date('Y-m-d', $timestamp) . ' 09:00:00'; // 拼接为明天的 9 点
//$dispatch->work_progress = $params['rate'];
$params['need_notice'] = 0;
$params['status'] = 1;
if(!empty($params['rate'])){ //修改任务的状态
if($dispatch->status != $params['rate']){
$dispatch->status = $params['rate'];
@ -134,17 +136,14 @@ class Dispatchrecord extends Backend
'remark' => '人工跟进,备注内容:'.$params['remark'],
];
Hook::listen('order_dispatch_change', $hookParams);
}
}
$dispatch->follow = 1;
$dispatch->record_count ++;
}
$params['admin_id'] = $this->auth->id;
$result = $this->model->allowField(true)->save($params);
$dispatch->follow = 1;
$dispatch->record_count ++;
$dispatch->save();
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();

View File

@ -22,11 +22,12 @@ return [
'app\admin\command\ImportServiceItems',
'app\admin\command\Test',
'app\common\command\CheckOrderDispatchGotCommand',
'app\common\command\UpdateWorkerManCommand',
'app\common\command\CheckOrderDispatchCommand',
'app\common\command\CheckOrdeRecordCommand',
'app\common\command\CheckSmsPlantCommand',
'app\common\command\CheckTTSOverTimeCommand',
'app\common\command\CheckTTSTaskCommand',
'app\common\command\UpdateWorkerManCommand',
'app\common\command\CheckTTSPlantCommand',
];

View File

@ -98,9 +98,6 @@ class OrderLogic
try {
$remark = '师傅超时未接单,任务取消';
$this->cancelOrderDispatch($dispatch,null,$remark);
Db::commit();
}catch (Exception $exception){
Db::rollback();

View File

@ -24,6 +24,7 @@ class CheckOrdeRecordCommand extends Command
$Model = new OrderDispatchRecord();
$now = date('Y-m-d H:i:s');
$Model->where('notice_time','<=',$now)
->where('need_notice',1)
->where('status',0)
->chunk(100, function ($list) {
$ids = [];

View File

@ -16,35 +16,64 @@ class CheckOrderDispatchGotCommand extends Command
protected function configure()
{
$this->setName('check:dispatch-toget')
->setDescription('自动派单未接单检测,五分钟未接单重派派单5分钟执行一次');
->setDescription('自动派单未接单检测,五分钟未接单,重派派单】/【自动派单上门时间已到,未完成上门】5分钟执行一次');
}
protected function execute(Input $input, Output $output){
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s',time()-5*60); //创建三十分名以上未接的任务
$OrderLogic = new OrderLogic();
$Model->where('status',OrderDispatch::STATUS_TOGET)
->where('type',2)
->where('create_time','<=',$now)
->chunk(100, function ($list) use ($OrderLogic){
foreach ($list as $item) {
try {
//取消旧单
$OrderLogic->noWorkerCanGetIt($item);
//自动重派新单
$order = Order::get($item->order_id);
$orderService = new \app\admin\controller\Order();
$orderService->autoDispatch($order);
}catch (Exception $exception){
}
}
});
//$this->_toget();
$this->_toarrive();
$output->info('OVER');
}
//未接单检测
private function _toget(){
try {
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s', time() - 5 * 60); //创建三十分名以上未接的任务
$OrderLogic = new OrderLogic();
$Model->where('status', OrderDispatch::STATUS_TOGET)
->where('type', 2)
->where('create_time', '<=', $now)
->chunk(100, function ($list) use ($OrderLogic) {
foreach ($list as $item) {
try {
//取消旧单
$OrderLogic->noWorkerCanGetIt($item);
//自动重派新单
$order = Order::get($item->order_id);
$orderService = new \app\admin\controller\Order();
$orderService->autoDispatch($order);
echo 'succ:' . $item->id . PHP_EOL;
} catch (Exception $exception) {
echo $exception->getMessage() . PHP_EOL;
}
}
});
}catch (Exception $exception){
echo $exception->getMessage(). PHP_EOL;
}
}
//预约时间过了未上门检测
private function _toarrive(){
try {
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s', time() - 5 * 60); //创建三十分名以上未接的任务
$count = $Model->whereIn('status', [OrderDispatch::STATUS_PLANIT,OrderDispatch::STATUS_OVERTIME])
->where('type', 2)
->where('follow', 1)
->where('plan_time', '<=', $now)
->update(['follow'=>0]);
echo 'arrive_count:'. $count. PHP_EOL;
}catch (Exception $exception){
echo $exception->getMessage(). PHP_EOL;
}
}
}

View File

@ -7,6 +7,7 @@ use app\admin\model\OrderDispatch;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Exception;
class CheckSmsPlantCommand extends Command
{
@ -20,14 +21,21 @@ class CheckSmsPlantCommand extends Command
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s'); //两小时通知
$afterTwoHours = date('Y-m-d H:i:s', strtotime('+2 hours'));
$Model->where('status','=',OrderDispatch::STATUS_PLANIT)
$Model->whereIn('status',[OrderDispatch::STATUS_PLANIT,OrderDispatch::STATUS_OVERTIME])
->where('plan_time','between',[$now,$afterTwoHours])
->where('notice_num','<',3)
->chunk(100, function ($list){
$ids = [];
foreach ($list as $item) {
$ids[] = $item->id;
SendMailLogic::sendToWorker($item->worker_tel);
try {
SendMailLogic::sendToWorker($item->worker_tel);
}catch (Exception $exception){
echo '短信发送失败:'.$exception->getMessage().PHP_EOL;
}
echo '短信发送完成:'.$item->id.PHP_EOL;
}
if(!empty($ids)){
OrderDispatch::whereIn('id',$ids)->update(['notice_num'=>3,'notice_time'=>date('Y-m-d H:i:s')]);

View File

@ -22,11 +22,11 @@ class CheckTTSOverTimeCommand extends Command
protected function execute(Input $input, Output $output){
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s'); //两小时通知
$afterTwoHours = date('Y-m-d H:i:s', strtotime('+1 hours'));
$now = date('Y-m-d H:i:s');
$Model->where('status','=',OrderDispatch::STATUS_CLOCK)
->where('estimated_finish_time','between',[$now,$afterTwoHours])
->where('type',2)
->where('estimated_finish_time','<',$now)
->where('tts_notice','<',3)
->chunk(100, function ($list) {
$ids = [];
@ -46,7 +46,8 @@ class CheckTTSOverTimeCommand extends Command
(new TtsLog())->insertAll($logs);
}
if(!empty($ids)){
OrderDispatch::whereIn('id',$ids)->update(['tts_notice'=>3,'tts_check_time'=>date('Y-m-d H:i:s')]);
$count = OrderDispatch::whereIn('id',$ids)->update(['follow'=>0,'tts_notice'=>3,'tts_check_time'=>date('Y-m-d H:i:s')]);
echo $count.PHP_EOL;
}
});
$output->info('OVER');

View File

@ -22,10 +22,11 @@ class CheckTTSPlantCommand extends Command
protected function execute(Input $input, Output $output){
$Model = new OrderDispatch();
$now = date('Y-m-d H:i:s'); //小时通知
$now = date('Y-m-d H:i:s'); //提前一小时通知
$afterTwoHours = date('Y-m-d H:i:s', strtotime('+1 hours'));
$Model->where('status','=',OrderDispatch::STATUS_PLANIT)
->where('type','=',2)
->where('plan_time','between',[$now,$afterTwoHours])
->where('tts_notice','<',2)
->chunk(100, function ($list) {
@ -46,7 +47,8 @@ class CheckTTSPlantCommand extends Command
(new TtsLog())->insertAll($logs);
}
if(!empty($ids)){
OrderDispatch::whereIn('id',$ids)->update(['tts_notice'=>2,'tts_check_time'=>date('Y-m-d H:i:s')]);
$count = OrderDispatch::whereIn('id',$ids)->update(['tts_notice'=>2,'tts_check_time'=>date('Y-m-d H:i:s')]);
echo $count.PHP_EOL;
}
});
$output->info('OVER');

View File

@ -23,11 +23,11 @@ class CheckTTSTaskCommand extends Command
protected function execute(Input $input, Output $output){
$Model = new TtsLog();
$ttsService = new NoticeLogic();
$Model->where('status','=',OrderDispatch::STATUS_CLOCK)
->where('tts_notice','<',3)
$Model->where('status','=',0)
->chunk(100, function ($list)use($ttsService) {
foreach ($list as $item) {
$ttsService->callIt($item);
echo $item->id.PHP_EOL;
}
});
$output->info('OVER');