|
@@ -404,7 +404,7 @@ class wechatWorkService
|
404
|
404
|
while ($flag) {
|
405
|
405
|
$accessToken = AuthorizeCorp::getAccessToken($corpid, '根据员工获取外部客户');
|
406
|
406
|
try{
|
407
|
|
- $result = wechatWorkService::getCustomerListMethod($params, $accessToken);
|
|
407
|
+ $result = wechatWorkService::getCustomerListMethod($params, $accessToken, $corpid);
|
408
|
408
|
// if($corpid == 'wwdfec0bcee287d5c5') {
|
409
|
409
|
// Log::logInfo('同步客户', ['corpid' => $corpid, 'user_list' => $userList, 'res' =>$result], 'get_corp_customer_list');
|
410
|
410
|
// }
|
|
@@ -488,28 +488,28 @@ class wechatWorkService
|
488
|
488
|
}
|
489
|
489
|
|
490
|
490
|
// 根据内部员工获取外部联系客户具体方法
|
491
|
|
- public static function getCustomerListMethod($params, $accessToken, $retry = 0)
|
|
491
|
+ public static function getCustomerListMethod($params, $accessToken, $corpid, $retry = 0)
|
492
|
492
|
{
|
493
|
493
|
$url = 'https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user?access_token='.$accessToken;
|
494
|
494
|
|
495
|
495
|
$result = HttpService::httpPost($url, json_encode($params), true);
|
496
|
496
|
$result = mb_convert_encoding($result, "UTF-8");
|
497
|
497
|
$result = json_decode($result, 1);
|
498
|
|
- if(empty($result) && $retry < 5) {
|
|
498
|
+ if((empty($result) || (isset($result['errcode']) && in_array($result['errcode'], [-1]))) && $retry < 5) {
|
499
|
499
|
sleep(2);
|
500
|
500
|
$retry++;
|
501
|
|
- return self::getCustomerListMethod($params, $accessToken, $retry);
|
|
501
|
+ return self::getCustomerListMethod($params, $accessToken, $corpid, $retry);
|
502
|
502
|
}
|
503
|
503
|
|
504
|
504
|
if(isset($result['errcode']) && in_array($result['errcode'], [0, 701008, 60111])) {
|
505
|
505
|
return $result;
|
506
|
506
|
} else {
|
507
|
507
|
// 请求失败,将响应数据写入日志
|
508
|
|
- Log::logError('获取内部员工对应的外部联系人列表失败:URL'.$url.', 请求参数:'.json_encode($params),
|
|
508
|
+ Log::logError('获取内部员工对应的外部联系人列表失败:URL'.$url.', 请求参数:'.json_encode(array_merge($params, ['corpid' => $corpid])),
|
509
|
509
|
(array)$result, 'get_user_customer_list');
|
510
|
510
|
|
511
|
511
|
EmailQueue::rPush('获取内部员工对应的外部联系人列表失败', json_encode([
|
512
|
|
- 'url' => $url, 'params' => $params, 'result' => (array)$result
|
|
512
|
+ 'url' => $url, 'params' => array_merge($params, ['corpid' => $corpid]), 'result' => (array)$result
|
513
|
513
|
]), ['song.shen@kuxuan-inc.com'], '猎羽');
|
514
|
514
|
|
515
|
515
|
return false;
|