This commit is contained in:
xman 2025-06-12 21:24:27 +08:00
parent c5738d7dc1
commit b6d4a5661d
8 changed files with 70 additions and 18 deletions

View File

@ -20,6 +20,18 @@ class OrderLog
$remark = $response['remark'] ?? ''; //备注 $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 = [ $data = [
'order_id' => $order->id, 'order_id' => $order->id,
'order_status' => $order->status, 'order_status' => $order->status,
@ -27,7 +39,7 @@ class OrderLog
'role' => $role, 'role' => $role,
'remark' => $remark, 'remark' => $remark,
'admin_id' => $auth->id ?? 0, 'admin_id' => $auth->id ?? 0,
'admin_user' => $role==1 ? ($auth->nickname ?? '系统') : $auth->name 'admin_user' => $adminUser
]; ];
(new \app\admin\model\OrderLog())->save($data); (new \app\admin\model\OrderLog())->save($data);
} }

View File

@ -13,7 +13,7 @@ use think\Hook;
class AutoDispatchLogic class AutoDispatchLogic
{ {
public static function autoDispatch($order,$auth=null) public static function autoDispatch($order,$auth=null,$isRetry=false)
{ {
// //
// if ($order->dispatch_type != 2) { // if ($order->dispatch_type != 2) {
@ -56,13 +56,16 @@ class AutoDispatchLogic
$hookparams['order'] = $order; $hookparams['order'] = $order;
$hookparams['role'] = 1; $hookparams['role'] = 1;
$hookparams['auth'] = null; $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); Hook::listen('order_change', $hookparams);
//日志 //日志
$hookParams = [ $hookParams = [
'dispatch' => (new OrderDispatch())->where('id', $orderDispatch->id)->find(), 'dispatch' => (new OrderDispatch())->where('id', $orderDispatch->id)->find(),
'remark' => '系统自动派单给师:'. $worker->name .'('.$worker->tel.')', 'remark' => '自动派单给工程师:'. $worker->name .'('.$worker->tel.')',
]; ];
Hook::listen('order_dispatch_change', $hookParams); Hook::listen('order_dispatch_change', $hookParams);

View File

@ -171,7 +171,13 @@ class Dispatch extends Backend
Hook::listen('order_change', $hookparams); Hook::listen('order_change', $hookparams);
$dispatch = $this->model->get($this->model->id); $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 //dispatch log
$hookParams2 = [ $hookParams2 = [
'dispatch' => $dispatch, 'dispatch' => $dispatch,

View File

@ -214,7 +214,14 @@ class Dispatch2 extends Backend
} }
$result = $row->allowField(true)->save($params); $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){ if($workerChange){
$hookParams = [ $hookParams = [
'dispatch' => $row, 'dispatch' => $row,

View File

@ -130,7 +130,15 @@ class Dispatchrecord extends Backend
if($dispatch->status != $params['rate']){ if($dispatch->status != $params['rate']){
$dispatch->status = $params['rate']; $dispatch->status = $params['rate'];
$dispatch->save(); $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 = [ $hookParams = [
'dispatch' => $dispatch, 'dispatch' => $dispatch,
'remark' => '人工跟进,备注内容:'.$params['remark'], 'remark' => '人工跟进,备注内容:'.$params['remark'],

View File

@ -131,7 +131,7 @@
return ` return `
<div class="timeline-progress-item"> <div class="timeline-progress-item">
<span class="progress-time">${progress.create_time}</span> <span class="progress-time">${progress.create_time}</span>
<span class="progress-user">${progress.status_text}</span> <!-- span class="progress-user">${progress.status_text}</span -->
<span class="progress-user">${innerUserDisplay}</span> <span class="progress-user">${innerUserDisplay}</span>
<span class="progress-remark">${progress.remark || '无内容'}</span> <span class="progress-remark">${progress.remark || '无内容'}</span>
</div> </div>
@ -142,9 +142,9 @@
<div class="timeline-marker"></div> <div class="timeline-marker"></div>
<div class="timeline-content"> <div class="timeline-content">
<h4 class="timeline-title">${log.order_status_text || '无状态'}</h4> <h4 class="timeline-title">${log.order_status_text || '无状态'}</h4>
<p><strong>${outerUserDisplay}</strong></p>
<p><strong>变更说明:</strong>${log.remark || '无'}</p> <p>${log.create_time} ${outerUserDisplay}&nbsp;&nbsp;${log.remark || '无'} </p>
<p class="timeline-time">${log.create_time}</p>
${progressHTML ? `<div class="timeline-progress">${progressHTML}</div>` : ''} ${progressHTML ? `<div class="timeline-progress">${progressHTML}</div>` : ''}
</div> </div>
`; `;

View File

@ -75,9 +75,18 @@ class OrderLogic
Hook::listen('order_change', $params); Hook::listen('order_change', $params);
if($roleInfo['role'] == 1){ //后台操作 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{ }else{
$orderDispatch->admin_user = '师傅:'. $roleInfo['auth']->name; $orderDispatch->admin_user = '工程师:'. $roleInfo['auth']->name;
} }
$hookParams = [ $hookParams = [
'dispatch' => $orderDispatch, 'dispatch' => $orderDispatch,
@ -97,7 +106,7 @@ class OrderLogic
Db::startTrans(); Db::startTrans();
try { try {
if (is_null($remark)){ if (is_null($remark)){
$remark = ''.$dispatch->worker_name.')超时未接单,任务取消'; $remark = '工程师('.$dispatch->worker_name.')超时未接单,任务取消';
} }
$this->cancelOrderDispatch($dispatch,null,$remark); $this->cancelOrderDispatch($dispatch,null,$remark);
Db::commit(); Db::commit();
@ -121,7 +130,14 @@ class OrderLogic
$dispatch->allowField(true)->save(['status' => OrderDispatch::STATUS_CANCEL, 'follow'=>2,'remark' => $remark]); $dispatch->allowField(true)->save(['status' => OrderDispatch::STATUS_CANCEL, 'follow'=>2,'remark' => $remark]);
if(!empty($auth)){ 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{ }else{
$dispatch->admin_user = config('system_name'); $dispatch->admin_user = config('system_name');
} }
@ -145,7 +161,7 @@ class OrderLogic
$params['order'] = $order; $params['order'] = $order;
$params['role'] = 1; $params['role'] = 1;
$params['auth'] = $auth; $params['auth'] = $auth;
$params['remark'] = '任务被取消,订单状态回退'; $params['remark'] = '取消任务,订单状态回退';
if (!empty($remark)) { if (!empty($remark)) {
$params['remark'] .= ',备注:' . $remark; $params['remark'] .= ',备注:' . $remark;
} }

View File

@ -49,7 +49,7 @@ class CheckOrderDispatchGotCommand extends Command
$OrderLogic->noWorkerCanGetIt($item); $OrderLogic->noWorkerCanGetIt($item);
//自动重派新单 //自动重派新单
$order = Order::get($item->order_id); $order = Order::get($item->order_id);
AutoDispatchLogic::autoDispatch($order); AutoDispatchLogic::autoDispatch($order,null,true);
echo 'succ:' . $item->id . PHP_EOL; echo 'succ:' . $item->id . PHP_EOL;
} catch (Exception $exception) { } catch (Exception $exception) {
echo $exception->getMessage() . PHP_EOL; echo $exception->getMessage() . PHP_EOL;
@ -85,7 +85,7 @@ class CheckOrderDispatchGotCommand extends Command
$OrderLogic->noWorkerCanGetIt($item); $OrderLogic->noWorkerCanGetIt($item);
//自动重派新单 //自动重派新单
$order = Order::get($item->order_id); $order = Order::get($item->order_id);
AutoDispatchLogic::autoDispatch($order); AutoDispatchLogic::autoDispatch($order,null,true);
echo 'succ:' . $item->id . PHP_EOL; echo 'succ:' . $item->id . PHP_EOL;
} catch (Exception $exception) { } catch (Exception $exception) {
echo $exception->getMessage() . PHP_EOL; echo $exception->getMessage() . PHP_EOL;