From 054803673555f177cae925de3662f5bfb3881de6 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Thu, 5 Jun 2025 21:15:41 +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 --- .../admin/behavior/OrderDispatchLog.php | 4 ++-- application/admin/behavior/OrderLog.php | 2 +- .../admin/controller/AutoDispatchLogic.php | 16 +++++++++---- application/admin/controller/Message.php | 5 ++-- application/admin/controller/Order.php | 10 +------- .../admin/controller/orders/Dispatch.php | 2 +- application/common/Logic/OrderLogic.php | 23 ++++++++++--------- .../command/CheckOrderDispatchGotCommand.php | 2 +- 8 files changed, 33 insertions(+), 31 deletions(-) diff --git a/application/admin/behavior/OrderDispatchLog.php b/application/admin/behavior/OrderDispatchLog.php index d2ae877..50f6d55 100644 --- a/application/admin/behavior/OrderDispatchLog.php +++ b/application/admin/behavior/OrderDispatchLog.php @@ -29,7 +29,7 @@ class OrderDispatchLog 'status' => $dispatch->status, 'status_text' => $statusList[$dispatch->status], 'remark' => $remark, - 'admin_user' => $dispatch->admin_user??'sys', + 'admin_user' => $dispatch->admin_user??'系统', ]; \app\admin\model\OrderDispatchLog::create($data); @@ -63,7 +63,7 @@ class OrderDispatchLog } } }catch (Exception $exception){ - + echo $exception->getMessage(); } } } diff --git a/application/admin/behavior/OrderLog.php b/application/admin/behavior/OrderLog.php index 926e37f..0769561 100644 --- a/application/admin/behavior/OrderLog.php +++ b/application/admin/behavior/OrderLog.php @@ -27,7 +27,7 @@ class OrderLog 'role' => $role, 'remark' => $remark, 'admin_id' => $auth->id ?? 0, - 'admin_user' => $role==1 ? ($auth->nickname ?? 'sys') : $auth->name + 'admin_user' => $role==1 ? ($auth->nickname ?? '系统') : $auth->name ]; (new \app\admin\model\OrderLog())->save($data); } diff --git a/application/admin/controller/AutoDispatchLogic.php b/application/admin/controller/AutoDispatchLogic.php index 7ab3c64..39298c4 100644 --- a/application/admin/controller/AutoDispatchLogic.php +++ b/application/admin/controller/AutoDispatchLogic.php @@ -13,7 +13,7 @@ use think\Hook; class AutoDispatchLogic { - public static function autoDispatch($order) + public static function autoDispatch($order,$auth=null) { // // if ($order->dispatch_type != 2) { @@ -22,13 +22,12 @@ class AutoDispatchLogic $worker_id = (new DispatchLogic())->getMaxScoreWorker($order); -// dd($worker_id); if (!$worker_id) { $order->dispatch_type = 1; $order->save(); return false; } -// $admin = Admin::where('id',$order->admin_id)->find(); + //$admin = Admin::where('id',$order->admin_id)->find(); $insert = [ 'admin_id' => 1, 'admin_user' => '系统', @@ -46,10 +45,19 @@ class AutoDispatchLogic $res = $orderDispatch->allowField(true)->save($insert); $order->status = \app\admin\model\Order::STATUS_DISPATCHED; $order->dispatch_time = date('Y-m-d H:i:s'); - // $order->dispatch_admin_id = $this->auth->id; + $order->dispatch_admin_id = 1; + $order->dispatch_admin_user = '系统'; $order->worker_id = $worker_id; $order->save(); + + //日志 + $hookparams['order'] = $order; + $hookparams['role'] = 1; + $hookparams['auth'] = $auth; + $hookparams['remark'] = '系统自动完成派单';//. $worker->name.'('.$worker->tel.')'; + Hook::listen('order_change', $hookparams); + //日志 $hookParams = [ 'dispatch' => (new OrderDispatch())->where('id', $orderDispatch->id)->find(), diff --git a/application/admin/controller/Message.php b/application/admin/controller/Message.php index 8e49f65..2af1bb2 100644 --- a/application/admin/controller/Message.php +++ b/application/admin/controller/Message.php @@ -129,7 +129,8 @@ class Message extends Backend { $count = 0; //超管不提醒新消息 -// if(!$this->auth->isSuperAdmin()){ + //if(!$this->auth->isSuperAdmin()){ + if(!$this->auth->id != 1){ $count = $this->model ->where('type',1) ->where('to_id',$this->auth->id) @@ -138,7 +139,7 @@ class Message extends Backend ->whereRaw("FIND_IN_SET({$this->auth->id}, read_uid) = 0 OR read_uid = '' or read_uid is null") ->whereTime('create_time', '>=', '-3 days') ->count(); -// } + } return [ 'count' => $count ]; diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index d4284ae..ef6eff8 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -248,16 +248,8 @@ class Order extends Backend $result = $this->model->allowField(true)->save($params); if ($params['dispatch_type'] == 2) { - AutoDispatchLogic::autoDispatch($this->model); + AutoDispatchLogic::autoDispatch($this->model,$this->auth); } - //日志 - - $hookparams['order'] = $this->model; - $hookparams['role'] = 1; - $hookparams['auth'] = $this->auth; - $hookparams['remark'] = $params['remark'] ?? ''; - Hook::listen('order_change', $hookparams); - Db::commit(); } catch (ValidateException | PDOException | Exception $e) { Db::rollback(); diff --git a/application/admin/controller/orders/Dispatch.php b/application/admin/controller/orders/Dispatch.php index 7e89df4..bec654f 100644 --- a/application/admin/controller/orders/Dispatch.php +++ b/application/admin/controller/orders/Dispatch.php @@ -167,7 +167,7 @@ class Dispatch extends Backend $hookparams['order'] = $order; $hookparams['role'] = 1; $hookparams['auth'] = $this->auth; - $hookparams['remark'] = ''; + $hookparams['remark'] = '手动完成派单'; Hook::listen('order_change', $hookparams); $dispatch = $this->model->get($this->model->id); diff --git a/application/common/Logic/OrderLogic.php b/application/common/Logic/OrderLogic.php index 68a8f1f..7a0d032 100644 --- a/application/common/Logic/OrderLogic.php +++ b/application/common/Logic/OrderLogic.php @@ -131,23 +131,24 @@ class OrderLogic if($nocancelOrder){ - $order = Order::where('id',$dispatch->order_id)->where('status',Order::STATUS_DISPATCHED)->find(); + $order = Order::where('id',$dispatch->order_id)->find(); $order->worker_id = 0; - $order->save(); if(empty($order)){ throw new Exception('未找到关联订单'); } //回退订单状态 - $order->status = Order::STATUS_DISPATCHING; - $order->save(); - $params['order'] = $order; - $params['role'] = 1; - $params['auth'] = $auth; - $params['remark'] = '任务被取消[ID:' . $dispatch->id . '],订单状态回退'; - if (!empty($remark)) { - $params['remark'] .= ',备注:' . $remark; + if($order->status != Order::STATUS_DISPATCHING){ + $order->status = Order::STATUS_DISPATCHING; + $order->save(); + $params['order'] = $order; + $params['role'] = 1; + $params['auth'] = $auth; + $params['remark'] = '任务被取消[ID:' . $dispatch->id . '],订单状态回退'; + if (!empty($remark)) { + $params['remark'] .= ',备注:' . $remark; + } + Hook::listen('order_change', $params); } - Hook::listen('order_change', $params); } } diff --git a/application/common/command/CheckOrderDispatchGotCommand.php b/application/common/command/CheckOrderDispatchGotCommand.php index 0405861..ca4b3fb 100644 --- a/application/common/command/CheckOrderDispatchGotCommand.php +++ b/application/common/command/CheckOrderDispatchGotCommand.php @@ -22,7 +22,7 @@ class CheckOrderDispatchGotCommand extends Command protected function execute(Input $input, Output $output){ - //$this->_toget(); + $this->_toget(); $this->_toarrive(); $output->info('OVER'); }