|
@@ -62,7 +62,9 @@ class Tickets extends Base |
|
@@ -62,7 +62,9 @@ class Tickets extends Base |
|
62
|
$log->engineer_id = $engineer_id;
|
62
|
$log->engineer_id = $engineer_id;
|
|
63
|
$log->is_engineer = in_array($engineer_id, $engineer_ids);
|
63
|
$log->is_engineer = in_array($engineer_id, $engineer_ids);
|
|
64
|
$this->logs()->save($log);
|
64
|
$this->logs()->save($log);
|
|
65
|
- }catch (\Exception $exception){}
|
65
|
+ }catch (\Exception $exception){
|
|
|
|
66
|
+ Log::error(" | ERRPR | Ticket saveEngineers {$exception->getMessage()} \n {$exception->getTraceAsString()}");
|
|
|
|
67
|
+ }
|
|
66
|
}
|
68
|
}
|
|
67
|
|
69
|
|
|
68
|
// 删除没有参与当前工单的人员(若之前已有)
|
70
|
// 删除没有参与当前工单的人员(若之前已有)
|
|
@@ -70,15 +72,16 @@ class Tickets extends Base |
|
@@ -70,15 +72,16 @@ class Tickets extends Base |
|
70
|
}
|
72
|
}
|
|
71
|
|
73
|
|
|
72
|
/**
|
74
|
/**
|
|
73
|
- * 推送钉钉通知任务
|
75
|
+ * TODO 这个是一个补充功能
|
|
|
|
76
|
+ * 那些情况需要推送钉钉内部通知?
|
|
74
|
* 1. 客户提交了工单
|
77
|
* 1. 客户提交了工单
|
|
75
|
- * - 通知第一负责人
|
78
|
+ * - 通知第一负责人 (gl_ticket_logs 表做了标记)
|
|
76
|
* 2. 客户补充了工单
|
79
|
* 2. 客户补充了工单
|
|
77
|
- * - 通知最近的聊天技术
|
80
|
+ * - 通知最近的聊天技术(gl_ticket_chats 表做了标记)
|
|
78
|
* 3. 技术完成了工单
|
81
|
* 3. 技术完成了工单
|
|
79
|
- * - 通知第一负责人,通知企微群
|
82
|
+ * - 通知第一负责人 (暂无,所以这里做补充,如果以后要把上面的逻辑也加进来也可以,只是我为了偷懒,暂时只考虑完成工单请款)
|
|
80
|
*/
|
83
|
*/
|
|
81
|
- public function pushDing($action = 'create')
|
84
|
+ public function pushDing($type = 'finish')
|
|
82
|
{
|
85
|
{
|
|
83
|
try {
|
86
|
try {
|
|
84
|
$ding = new TicketDing();
|
87
|
$ding = new TicketDing();
|
|
@@ -86,36 +89,23 @@ class Tickets extends Base |
|
@@ -86,36 +89,23 @@ class Tickets extends Base |
|
86
|
$ding->table_name = 'gl_tickets';
|
89
|
$ding->table_name = 'gl_tickets';
|
|
87
|
$ding->table_id = $this->id;
|
90
|
$ding->table_id = $this->id;
|
|
88
|
|
91
|
|
|
89
|
- if ($action == 'create')
|
92
|
+ if ($type == 'finish')
|
|
90
|
{
|
93
|
{
|
|
91
|
- // 客户提交了工单
|
94
|
+ // 所以技术完成了工单,通知第一负责人 和 工单的提交人
|
|
92
|
$ding->userIds = [$this->project->engineer_id];
|
95
|
$ding->userIds = [$this->project->engineer_id];
|
|
|
|
96
|
+ if ($this->submit_side == 1) {
|
|
|
|
97
|
+ // A 端提的,还要通知提交人
|
|
|
|
98
|
+ $ding->userIds[] = $this->submit_user_id;
|
|
|
|
99
|
+ // 去重
|
|
|
|
100
|
+ $ding->userIds = array_unique($ding->userIds);
|
|
|
|
101
|
+ }
|
|
93
|
$ding->msgParam = json_encode([
|
102
|
$ding->msgParam = json_encode([
|
|
94
|
- 'text' => "您有新的工单(ID: {$this->id}),请及时处理!",
|
103
|
+ 'text' => "工单(ID: {$this->id}),已经全部完成,请访问查看详情!",
|
|
95
|
'title' => 'AI协同工单 - ' . $this->project->title,
|
104
|
'title' => 'AI协同工单 - ' . $this->project->title,
|
|
96
|
'picUrl' => 'https://hub.globalso.com/logocm.png',
|
105
|
'picUrl' => 'https://hub.globalso.com/logocm.png',
|
|
97
|
'messageUrl' => 'https://oa.quanqiusou.cn/afterorder?project_id=' . $this->project->uuid,
|
106
|
'messageUrl' => 'https://oa.quanqiusou.cn/afterorder?project_id=' . $this->project->uuid,
|
|
98
|
], JSON_UNESCAPED_UNICODE);
|
107
|
], JSON_UNESCAPED_UNICODE);
|
|
99
|
$ding->save();
|
108
|
$ding->save();
|
|
100
|
- }elseif ($action == 'chat'){
|
|
|
|
101
|
- // 客户补充了工单
|
|
|
|
102
|
- $ding = new TicketDing();
|
|
|
|
103
|
- $lastChat = TicketChat::where('ticket_id', $this->id)
|
|
|
|
104
|
- ->where('submit_side', 1)
|
|
|
|
105
|
- ->orderBy('id', 'desc')
|
|
|
|
106
|
- ->first();
|
|
|
|
107
|
-
|
|
|
|
108
|
- $ding->userIds = [!empty($lastChat) ? $lastChat->manage_id : $this->project->engineer_id];
|
|
|
|
109
|
- $ding->msgParam = json_encode([
|
|
|
|
110
|
- 'text' => "客户补充了工单(ID: {$this->id}),请及时处理!",
|
|
|
|
111
|
- 'title' => 'AI协同工单 - ' . $this->project->title,
|
|
|
|
112
|
- 'picUrl' => 'https://hub.globalso.com/logocm.png',
|
|
|
|
113
|
- 'messageUrl' => 'https://oa.quanqiusou.cn/afterorder?project_id=' . $this->project->uuid,
|
|
|
|
114
|
- ], JSON_UNESCAPED_UNICODE);
|
|
|
|
115
|
- $ding->save();
|
|
|
|
116
|
- }elseif ($action == 'finish'){
|
|
|
|
117
|
- // 完成工单
|
|
|
|
118
|
-
|
|
|
|
119
|
}
|
109
|
}
|
|
120
|
}catch (\Exception $exception){
|
110
|
}catch (\Exception $exception){
|
|
121
|
Log::error(" | ERRPR | Ticket {$exception->getMessage()} \n {$exception->getTraceAsString()}");
|
111
|
Log::error(" | ERRPR | Ticket {$exception->getMessage()} \n {$exception->getTraceAsString()}");
|