|
@@ -116,7 +116,56 @@ class BatchMarkTagDeal extends Command
|
116
|
116
|
|
117
|
117
|
$stat = ['success' => 0, 'fail' => 0];
|
118
|
118
|
foreach ($externalUserIdList as $externalUserId) {
|
|
119
|
+ if(1 == $taskInfo['type']) {
|
|
120
|
+ $newAddTagIdList = $newTagList;
|
|
121
|
+ $newRemoveTagIdList = [];
|
|
122
|
+ } else if(2 == $taskInfo['type']) {
|
|
123
|
+ $newAddTagIdList = [];
|
|
124
|
+ $newRemoveTagIdList = $newTagList;
|
|
125
|
+ }
|
|
126
|
+
|
|
127
|
+ $this->markTag($taskInfo['corpid'], $recordInfo['user_id'], $externalUserId, $newAddTagIdList, $newRemoveTagIdList);
|
|
128
|
+ }
|
|
129
|
+ }
|
|
130
|
+
|
|
131
|
+ private function markTag($corpid, $userId, $externalUserId, $newAddTagIdList, $newRemoveTagIdList, $retry = 0) {
|
|
132
|
+ $responseData = QyCommon::mark_tag($corpid, $userId, $externalUserId, $newAddTagIdList, $newRemoveTagIdList);
|
|
133
|
+
|
|
134
|
+ if(isset($responseData['errcode']) && $responseData['errcode'] == 0) {
|
|
135
|
+ // 编辑成功了
|
|
136
|
+ TagService::updateLocalCustomerTagSecond($corpid, $userId, $externalUserId, $newAddTagIdList, $newRemoveTagIdList);
|
|
137
|
+
|
|
138
|
+ $state = $data['state'] ?? null;
|
|
139
|
+ if (!is_null($state)) {
|
|
140
|
+ // 客户详情10s同步一遍
|
|
141
|
+ RedisModel::lPush(CustomerDetails::CUSTOMER_DATA_SYNC_RDS, json_encode([
|
|
142
|
+ 'corpid' => $corpid,
|
|
143
|
+ 'user_id' => $userId,
|
|
144
|
+ 'external_userid' => $externalUserId,
|
|
145
|
+ 'exec_time' => time() + 10
|
|
146
|
+ ]));
|
|
147
|
+ }
|
119
|
148
|
|
|
149
|
+ return true;
|
|
150
|
+ } else {
|
|
151
|
+ if(!in_array($responseData['errcode'], [84061, 60111])) { # 无法处理的状态码:没有好友关系或者客服ID不存在
|
|
152
|
+ // 判断重试次数
|
|
153
|
+ if($ <= 5) {
|
|
154
|
+ $re_times++;
|
|
155
|
+ $data['re_times'] = $re_times;
|
|
156
|
+ // RedisModel::lPush(CustomerTagService::CUSTOMER_TAG_MARK_RDS, json_encode($data));
|
|
157
|
+ } else {
|
|
158
|
+ // 还是一直失败,则不再请求,日志记录一下
|
|
159
|
+ Log::logError('', [
|
|
160
|
+ 'corpid' => $corpid,
|
|
161
|
+ 'param' => $data,
|
|
162
|
+ 'message' => '请求企微打标签接口3次重试均失败',
|
|
163
|
+ ], $this->logName);
|
|
164
|
+ EmailQueue::rPush('请求企微打标签接口3次重试均失败', json_encode(['params' => $data, 'res' => $responseData], 256), $this->emailReceiver, $this->emailSender);
|
|
165
|
+ // 邮件报警
|
|
166
|
+ // $this->exceptionHandler(json_encode(['params' => $data, 'msg' => '请求企微打标签接口3次重试均失败', 'res' => $responseData], 256));
|
|
167
|
+ }
|
|
168
|
+// }
|
120
|
169
|
}
|
121
|
170
|
}
|
122
|
171
|
}
|