|
@@ -77,39 +77,26 @@ class BatchMarkTagNew extends Command
|
77
|
77
|
$taskInfo = json_decode(json_encode($taskInfo), 1);
|
78
|
78
|
BatchMarkTag::updateStatus($taskId, 2);
|
79
|
79
|
|
80
|
|
- # 客服许可(兼容新授权到系统的企微,此种企微的客服没有许可,但是会有75天的试用期)
|
81
|
|
- $corpInfo = AuthorizeCorp::getCorpInfo($taskInfo['corpid']);
|
82
|
|
- if(!empty($corpInfo)) {
|
83
|
|
- $chargeActiveType = 1;
|
84
|
|
- $activeUserList = [];
|
85
|
|
- if (strtotime($corpInfo->created_at) <= strtotime('-75 days')) {
|
86
|
|
- $chargeActiveType = 2;
|
87
|
|
- $activeUserList = DjUser::getActiveUserListById($taskInfo['corpid'], []);
|
88
|
|
- $activeUserList = json_decode(json_encode($activeUserList), 1);
|
89
|
|
- if(empty($activeUserList)) {
|
90
|
|
- # 选择的客服列表全部没有许可,不去查询客户列表,直接更新状态
|
91
|
|
- $status = -1;
|
92
|
|
- BatchMarkTag::updateStatus($taskId, $status);
|
93
|
|
- Log::logError('所属企微的客服全部没有许可信息', ['task_id' => $taskId, 'corpid' => $taskInfo['corpid']], $this->logName);
|
94
|
|
- return false;
|
95
|
|
- }
|
96
|
|
- }
|
97
|
|
-
|
98
|
|
- # 直接筛选出要处理的客户列表,方便生成记录表数据
|
99
|
|
- if(0 == $taskInfo['select_all']) {
|
100
|
|
- $this->dealSelectTask($taskInfo, $chargeActiveType, $activeUserList);
|
101
|
|
- } else {
|
102
|
|
- $this->dealFilterTask($taskInfo, $chargeActiveType, $activeUserList);
|
103
|
|
- }
|
104
|
|
- } else {
|
|
80
|
+ $activeUserList = DjUser::getActiveUserListById($taskInfo['corpid']);
|
|
81
|
+ if(empty($activeUserList)) {
|
|
82
|
+ # 选择的客服列表全部没有许可,不去查询客户列表,直接更新状态
|
105
|
83
|
$status = -1;
|
106
|
84
|
BatchMarkTag::updateStatus($taskId, $status);
|
107
|
|
- Log::logError('企微信息异常', ['task_id' => $taskId], $this->logName);
|
108
|
|
- EmailQueue::rPush('客户批量打标签-企微信息查询异常', 'task_id:'.$taskId, $this->emailReceiver, $this->emailSender);
|
|
85
|
+ Log::logError('所属企微的客服全部没有许可信息', ['task_id' => $taskId, 'corpid' => $taskInfo['corpid']], $this->logName);
|
|
86
|
+ return false;
|
109
|
87
|
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+ # 直接筛选出要处理的客户列表,方便生成记录表数据
|
|
91
|
+ if(0 == $taskInfo['select_all']) {
|
|
92
|
+ $this->dealSelectTask($taskInfo, $activeUserList);
|
|
93
|
+ } else {
|
|
94
|
+ $this->dealFilterTask($taskInfo, $activeUserList);
|
|
95
|
+ }
|
|
96
|
+
|
110
|
97
|
}
|
111
|
98
|
|
112
|
|
- private function dealSelectTask($taskInfo, $chargeActiveType, $activeUserList) {
|
|
99
|
+ private function dealSelectTask($taskInfo, $activeUserList) {
|
113
|
100
|
$customerList = json_decode($taskInfo['customer_list'], 1);
|
114
|
101
|
$taskId = $taskInfo['id'];
|
115
|
102
|
$corpid = $taskInfo['corpid'];
|
|
@@ -125,7 +112,7 @@ class BatchMarkTagNew extends Command
|
125
|
112
|
}
|
126
|
113
|
|
127
|
114
|
foreach ($userCustomerList as $userId => $childCustomerIdListArr) {
|
128
|
|
- if(2 == $chargeActiveType && !in_array($userId, $activeUserList)) {
|
|
115
|
+ if(!in_array($userId, $activeUserList)) {
|
129
|
116
|
Log::logInfo('客服无许可,跳过', ['user_id' => $userId, 'customer_list' => $childCustomerIdListArr], $this->logName);
|
130
|
117
|
continue;
|
131
|
118
|
}
|
|
@@ -180,10 +167,11 @@ class BatchMarkTagNew extends Command
|
180
|
167
|
return $data;
|
181
|
168
|
}
|
182
|
169
|
|
183
|
|
- private function dealFilterTask($taskInfo, $chargeActiveType, $activeUserList)
|
|
170
|
+ private function dealFilterTask($taskInfo, $activeUserList)
|
184
|
171
|
{
|
185
|
172
|
$params = json_decode($taskInfo['params'], 1);
|
186
|
173
|
$params['corpid'] = $taskInfo['corpid'];
|
|
174
|
+ $params['user_id_list'] = !is_array($params['user_id_list']) ? json_decode($params['user_id_list']) : $params['user_id_list'];
|
187
|
175
|
$source = 1;
|
188
|
176
|
|
189
|
177
|
$filterCustomerList = json_decode($taskInfo['filter_customer_list'], 1);
|
|
@@ -196,11 +184,7 @@ class BatchMarkTagNew extends Command
|
196
|
184
|
# 先查询出所有需要执行的客服,再按照客服来查询客户列表
|
197
|
185
|
$userIdList = $params['user_id_list'];
|
198
|
186
|
if (empty($userIdList)) {
|
199
|
|
- if (1 == $chargeActiveType) {
|
200
|
|
- $userIdList = DjUser::query()->where('corpid', $taskInfo['corpid'])->where('enable', 1)->pluck('user_id')->toArray();
|
201
|
|
- } else {
|
202
|
|
- $userIdList = $activeUserList;
|
203
|
|
- }
|
|
187
|
+ $userIdList = $activeUserList;
|
204
|
188
|
} else {
|
205
|
189
|
$userIdList = array_intersect($params['user_id_list'], $activeUserList);
|
206
|
190
|
}
|