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'] ?? ''; //备注
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);
}

View File

@ -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);

View File

@ -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,

View File

@ -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,

View File

@ -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'],

View File

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

View File

@ -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;
}

View File

@ -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;