From b6d4a5661dcc427ccaecbae0bcc3db0e598d9fe2 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Thu, 12 Jun 2025 21:24:27 +0800 Subject: [PATCH] sb --- application/admin/behavior/OrderLog.php | 14 +++++++++- .../admin/controller/AutoDispatchLogic.php | 9 ++++--- .../admin/controller/orders/Dispatch.php | 8 +++++- .../admin/controller/orders/Dispatch2.php | 9 ++++++- .../controller/orders/Dispatchrecord.php | 10 ++++++- .../admin/view/orders/dispatchlog/index.html | 8 +++--- application/common/Logic/OrderLogic.php | 26 +++++++++++++++---- .../command/CheckOrderDispatchGotCommand.php | 4 +-- 8 files changed, 70 insertions(+), 18 deletions(-) diff --git a/application/admin/behavior/OrderLog.php b/application/admin/behavior/OrderLog.php index 0769561..8b9f224 100644 --- a/application/admin/behavior/OrderLog.php +++ b/application/admin/behavior/OrderLog.php @@ -20,6 +20,18 @@ class OrderLog $remark = $response['remark'] ?? ''; //备注 + if($role == 1 && !empty($auth->id)){ + $groups = $auth->getGroups($auth->id); + $groupName = ''; + if(!empty($groups)){ + $groupNames = array_column($groups,'name'); + $groupName = implode(',',$groupNames); + } + $auth->nickname = $groupName.':'. $auth->nickname; + } + + $adminUser = $role==1 ? ($auth->nickname ?? '系统') : $auth->name; + $data = [ 'order_id' => $order->id, 'order_status' => $order->status, @@ -27,7 +39,7 @@ class OrderLog 'role' => $role, 'remark' => $remark, 'admin_id' => $auth->id ?? 0, - 'admin_user' => $role==1 ? ($auth->nickname ?? '系统') : $auth->name + 'admin_user' => $adminUser ]; (new \app\admin\model\OrderLog())->save($data); } diff --git a/application/admin/controller/AutoDispatchLogic.php b/application/admin/controller/AutoDispatchLogic.php index cef084f..e769791 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,$auth=null) + public static function autoDispatch($order,$auth=null,$isRetry=false) { // // if ($order->dispatch_type != 2) { @@ -56,13 +56,16 @@ class AutoDispatchLogic $hookparams['order'] = $order; $hookparams['role'] = 1; $hookparams['auth'] = null; - $hookparams['remark'] = '系统自动完成派单';//. $worker->name.'('.$worker->tel.')'; + $hookparams['remark'] = '自动完成派单';//. $worker->name.'('.$worker->tel.')'; + if ($isRetry) { + $hookparams['remark'] = '订单重派:工程师【'.$worker->name.'】超时不接单,系统自动转派订单'; + } Hook::listen('order_change', $hookparams); //日志 $hookParams = [ 'dispatch' => (new OrderDispatch())->where('id', $orderDispatch->id)->find(), - 'remark' => '系统自动派单给师傅:'. $worker->name .'('.$worker->tel.')', + 'remark' => '自动派单给工程师:'. $worker->name .'('.$worker->tel.')', ]; Hook::listen('order_dispatch_change', $hookParams); diff --git a/application/admin/controller/orders/Dispatch.php b/application/admin/controller/orders/Dispatch.php index bec654f..c2d6443 100644 --- a/application/admin/controller/orders/Dispatch.php +++ b/application/admin/controller/orders/Dispatch.php @@ -171,7 +171,13 @@ class Dispatch extends Backend Hook::listen('order_change', $hookparams); $dispatch = $this->model->get($this->model->id); - $dispatch->admin_user = $this->auth->nickname; + $groups = $this->auth->getGroups($this->auth->id); + $groupName = ''; + if(!empty($groups)){ + $groupNames = array_column($groups,'name'); + $groupName = implode(',',$groupNames); + } + $dispatch->admin_user = $groupName.":".$this->auth->nickname; //dispatch log $hookParams2 = [ 'dispatch' => $dispatch, diff --git a/application/admin/controller/orders/Dispatch2.php b/application/admin/controller/orders/Dispatch2.php index 5e665d7..36198f9 100644 --- a/application/admin/controller/orders/Dispatch2.php +++ b/application/admin/controller/orders/Dispatch2.php @@ -214,7 +214,14 @@ class Dispatch2 extends Backend } $result = $row->allowField(true)->save($params); - $row->admin_user = $this->auth->nickname; + //$row->admin_user = $this->auth->nickname; + $groups = $this->auth->getGroups($this->auth->id); + $groupName = ''; + if(!empty($groups)){ + $groupNames = array_column($groups,'name'); + $groupName = implode(',',$groupNames); + } + $row->admin_user = $groupName.':'.$this->auth->nickname; if($workerChange){ $hookParams = [ 'dispatch' => $row, diff --git a/application/admin/controller/orders/Dispatchrecord.php b/application/admin/controller/orders/Dispatchrecord.php index 4205084..bd60cb5 100644 --- a/application/admin/controller/orders/Dispatchrecord.php +++ b/application/admin/controller/orders/Dispatchrecord.php @@ -130,7 +130,15 @@ class Dispatchrecord extends Backend if($dispatch->status != $params['rate']){ $dispatch->status = $params['rate']; $dispatch->save(); - $dispatch->admin_user = '管理员:'. $this->auth->nickname; + + $groups = $this->auth->getGroups($this->auth->id); + $groupName = ''; + if(!empty($groups)){ + $groupNames = array_column($groups,'name'); + $groupName = implode(',',$groupNames); + } + + $dispatch->admin_user = $groupName.':'. $this->auth->nickname; $hookParams = [ 'dispatch' => $dispatch, 'remark' => '人工跟进,备注内容:'.$params['remark'], diff --git a/application/admin/view/orders/dispatchlog/index.html b/application/admin/view/orders/dispatchlog/index.html index be68c98..144871e 100644 --- a/application/admin/view/orders/dispatchlog/index.html +++ b/application/admin/view/orders/dispatchlog/index.html @@ -131,7 +131,7 @@ return `
${progress.create_time} - ${progress.status_text} + ${innerUserDisplay} ${progress.remark || '无内容'}
@@ -142,9 +142,9 @@

${log.order_status_text || '无状态'}

-

${outerUserDisplay}

-

变更说明:${log.remark || '无'}

-

${log.create_time}

+ +

${log.create_time} ${outerUserDisplay}  ${log.remark || '无'}

+ ${progressHTML ? `
${progressHTML}
` : ''}
`; diff --git a/application/common/Logic/OrderLogic.php b/application/common/Logic/OrderLogic.php index facbf8e..4f89558 100644 --- a/application/common/Logic/OrderLogic.php +++ b/application/common/Logic/OrderLogic.php @@ -75,9 +75,18 @@ class OrderLogic Hook::listen('order_change', $params); if($roleInfo['role'] == 1){ //后台操作 - $orderDispatch->admin_user = '管理员:'. $roleInfo['auth']->nickname; + + $auth = $roleInfo['auth']; + $groups = $auth->getGroups($auth->id); + $groupName = ''; + if(!empty($groups)){ + $groupNames = array_column($groups,'name'); + $groupName = implode(',',$groupNames); + } + + $orderDispatch->admin_user = $groupName.':'. $auth->nickname; }else{ - $orderDispatch->admin_user = '师傅:'. $roleInfo['auth']->name; + $orderDispatch->admin_user = '工程师:'. $roleInfo['auth']->name; } $hookParams = [ 'dispatch' => $orderDispatch, @@ -97,7 +106,7 @@ class OrderLogic Db::startTrans(); try { if (is_null($remark)){ - $remark = '师傅('.$dispatch->worker_name.')超时未接单,任务取消'; + $remark = '工程师('.$dispatch->worker_name.')超时未接单,任务取消'; } $this->cancelOrderDispatch($dispatch,null,$remark); Db::commit(); @@ -121,7 +130,14 @@ class OrderLogic $dispatch->allowField(true)->save(['status' => OrderDispatch::STATUS_CANCEL, 'follow'=>2,'remark' => $remark]); if(!empty($auth)){ - $dispatch->admin_user = '管理员:'.$auth->nickname; + + $groups = $auth->getGroups($auth->id); + $groupName = ''; + if(!empty($groups)){ + $groupNames = array_column($groups,'name'); + $groupName = implode(',',$groupNames); + } + $dispatch->admin_user = $groupName.':'.$auth->nickname; }else{ $dispatch->admin_user = config('system_name'); } @@ -145,7 +161,7 @@ class OrderLogic $params['order'] = $order; $params['role'] = 1; $params['auth'] = $auth; - $params['remark'] = '任务被取消,订单状态回退'; + $params['remark'] = '取消任务,订单状态回退'; if (!empty($remark)) { $params['remark'] .= ',备注:' . $remark; } diff --git a/application/common/command/CheckOrderDispatchGotCommand.php b/application/common/command/CheckOrderDispatchGotCommand.php index f462d24..16b97e0 100644 --- a/application/common/command/CheckOrderDispatchGotCommand.php +++ b/application/common/command/CheckOrderDispatchGotCommand.php @@ -49,7 +49,7 @@ class CheckOrderDispatchGotCommand extends Command $OrderLogic->noWorkerCanGetIt($item); //自动重派新单 $order = Order::get($item->order_id); - AutoDispatchLogic::autoDispatch($order); + AutoDispatchLogic::autoDispatch($order,null,true); echo 'succ:' . $item->id . PHP_EOL; } catch (Exception $exception) { echo $exception->getMessage() . PHP_EOL; @@ -85,7 +85,7 @@ class CheckOrderDispatchGotCommand extends Command $OrderLogic->noWorkerCanGetIt($item); //自动重派新单 $order = Order::get($item->order_id); - AutoDispatchLogic::autoDispatch($order); + AutoDispatchLogic::autoDispatch($order,null,true); echo 'succ:' . $item->id . PHP_EOL; } catch (Exception $exception) { echo $exception->getMessage() . PHP_EOL;