From f87648c09bb568e37be2f3a5790bead38a7e6987 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Sun, 8 Jun 2025 11:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/orders/Dispatchrecord.php | 4 ++ .../command/CheckOrderDispatchGotCommand.php | 39 ++++++++++++++++++- application/extra/alibaba_dyvms.php | 2 +- application/services/OrderDispatchService.php | 1 + 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/application/admin/controller/orders/Dispatchrecord.php b/application/admin/controller/orders/Dispatchrecord.php index 3c2de1b..4205084 100644 --- a/application/admin/controller/orders/Dispatchrecord.php +++ b/application/admin/controller/orders/Dispatchrecord.php @@ -136,6 +136,10 @@ class Dispatchrecord extends Backend 'remark' => '人工跟进,备注内容:'.$params['remark'], ]; Hook::listen('order_dispatch_change', $hookParams); + + if($params['rate'] == 10){ + $dispatch->got_time = date('Y-m-d H:i:s', time()); + } } } $dispatch->follow = 1; diff --git a/application/common/command/CheckOrderDispatchGotCommand.php b/application/common/command/CheckOrderDispatchGotCommand.php index 414c08c..f462d24 100644 --- a/application/common/command/CheckOrderDispatchGotCommand.php +++ b/application/common/command/CheckOrderDispatchGotCommand.php @@ -15,7 +15,7 @@ use think\Hook; class CheckOrderDispatchGotCommand extends Command { - protected $title = '【自动派单未接单检测,五分钟未接单,重派派单】/【自动派单上门时间已到,未完成上门】,每分钟执行一次'; + protected $title = '【自动派单未接单检测,五分钟未接单,重派派单】/【自动派接单五分钟未预约,重新派单】/【自动派单上门时间已到,未完成上门】,每分钟执行一次'; protected function configure() { $this->setName('check:dispatch-toget') @@ -25,6 +25,7 @@ class CheckOrderDispatchGotCommand extends Command protected function execute(Input $input, Output $output){ $this->_toget(); + $this->_toplan(); $this->_toarrive(); $output->info('OVER'); } @@ -66,6 +67,42 @@ class CheckOrderDispatchGotCommand extends Command } + + //未预约 + private function _toplan(){ + try { + $Model = new OrderDispatch(); + $now = date('Y-m-d H:i:s', time() - 5 * 60); //创建三十分名以上未接的任务 + $OrderLogic = new OrderLogic(); + + $Model->where('status', OrderDispatch::STATUS_GOTIT) + ->where('type', 2) + ->where('got_time', '<=', $now) + ->chunk(100, function ($list) use ($OrderLogic) { + foreach ($list as $item) { + try { + //取消旧单 + $OrderLogic->noWorkerCanGetIt($item); + //自动重派新单 + $order = Order::get($item->order_id); + AutoDispatchLogic::autoDispatch($order); + echo 'succ:' . $item->id . PHP_EOL; + } catch (Exception $exception) { + echo $exception->getMessage() . PHP_EOL; + } + } + }); + }catch (Exception $exception){ + echo $exception->getMessage(). PHP_EOL; + Db::name('debug_log')->insert([ + 'title' => $this->title, + 'content' => '未预约,错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(), + 'create_time' => date('Y-m-d H:i:s', time()) + ]); + } + } + + //预约时间过了未上门检测 private function _toarrive(){ try { diff --git a/application/extra/alibaba_dyvms.php b/application/extra/alibaba_dyvms.php index 6ee25d4..85b7fc0 100644 --- a/application/extra/alibaba_dyvms.php +++ b/application/extra/alibaba_dyvms.php @@ -12,5 +12,5 @@ return [ 'sync' => true, //同步 - 'status' => false, //true启用,0关闭 + 'status' => true, //true启用,0关闭 ]; \ No newline at end of file diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 3fa9562..300c2d4 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -155,6 +155,7 @@ class OrderDispatchService extends BaseService //接单 $orderDispatch->status = $orderDispatchStatus; $orderDispatch->follow = 1; + $orderDispatch->got_time = date('Y-m-d H:i:s', time()); //拒接原因 if ($type == 'reject') { if (empty($params['reject_reason'])) {