Merge branch 'develop' into yongpxu-dev
# Conflicts: # Server/application/command/SwitchFriendsCommand.php resolved by develop version # Server/application/cunkebao/controller/ContentLibraryController.php resolved by develop version # Server/application/cunkebao/controller/WorkbenchController.php resolved by develop version # Server/application/cunkebao/controller/plan/PlanSceneV1Controller.php resolved by develop version # Server/application/job/WechatMomentsJob.php resolved by develop version # Server/application/job/WorkbenchAutoLikeJob.php resolved by develop version # Server/extend/WeChatDeviceApi/Adapters/ChuKeBao/Adapter.php resolved by develop version
This commit is contained in:
@@ -171,7 +171,7 @@ class AutomaticAssign extends BaseController
|
||||
* @param int $optFrom 操作来源
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function allotWechatFriend($data = [],$isInner = false)
|
||||
public function allotWechatFriend($data = [],$isInner = false,$errorNum = 0)
|
||||
{
|
||||
// 获取授权token
|
||||
$authorization = trim($this->request->header('authorization', $this->authorization));
|
||||
@@ -188,23 +188,24 @@ class AutomaticAssign extends BaseController
|
||||
$wechatFriendId = !empty($data['wechatFriendId']) ? $data['wechatFriendId'] : input('wechatFriendId', 0);
|
||||
$toAccountId = !empty($data['toAccountId']) ? $data['toAccountId'] : input('toAccountId', 0);
|
||||
$comment = !empty($data['comment']) ? $data['comment'] : input('comment', '');
|
||||
$notifyReceiver = !empty($data['notifyReceiver']) ? $data['notifyReceiver'] : input('notifyReceiver', false);
|
||||
$notifyReceiver = !empty($data['notifyReceiver']) ? $data['notifyReceiver'] : input('notifyReceiver', 'false');
|
||||
$optFrom = !empty($data['optFrom']) ? $data['optFrom'] : input('optFrom', 4); // 默认操作来源为4
|
||||
|
||||
// 参数验证
|
||||
if (empty($wechatFriendId)) {
|
||||
return errorJson('微信好友ID不能为空');
|
||||
return json_encode(['code'=>500,'msg'=>'微信好友ID不能为空']);
|
||||
|
||||
}
|
||||
|
||||
if (empty($toAccountId)) {
|
||||
return errorJson('目标账号ID不能为空');
|
||||
return json_encode(['code'=>500,'msg'=>'目标账号ID不能为空']);
|
||||
}
|
||||
|
||||
|
||||
// 设置请求头
|
||||
$headerData = ['client:system'];
|
||||
$header = setHeader($headerData, $authorization, 'json');
|
||||
|
||||
|
||||
// 发送请求
|
||||
$url = $this->baseUrl . 'api/WechatFriend/allot?wechatFriendId='.$wechatFriendId.'¬ifyReceiver='.$notifyReceiver.'&comment='.$comment.'&toAccountId='.$toAccountId.'&optFrom='.$optFrom;
|
||||
$result = requestCurl($url, [], 'PUT', $header, 'json');
|
||||
@@ -226,8 +227,59 @@ class AutomaticAssign extends BaseController
|
||||
if($isInner){
|
||||
return json_encode(['code'=>500,'msg'=>'微信好友分配失败:' . $e->getMessage()]);
|
||||
}else{
|
||||
Cache::rm('system_authorization_token');
|
||||
Cache::rm('system_refresh_token');
|
||||
$errorNum ++;
|
||||
if ($errorNum <= 3) {
|
||||
$this->allotWechatFriend($data,$isInner,$errorNum);
|
||||
}
|
||||
return json_encode(['code'=>500,'msg'=> $result]);
|
||||
return errorJson('微信好友分配失败:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function multiAllotFriendToAccount($data = [],$errorNum = 0){
|
||||
// 获取授权token
|
||||
$authorization = $this->authorization;
|
||||
if (empty($authorization)) {
|
||||
return json_encode(['code'=>500,'msg'=>'缺少授权信息']);
|
||||
}
|
||||
|
||||
$wechatFriendIds = !empty($data['wechatFriendIds']) ? $data['wechatFriendIds'] : input('wechatFriendIds', []);
|
||||
$toAccountId = !empty($data['toAccountId']) ? $data['toAccountId'] : input('toAccountId', 0);
|
||||
$notifyReceiver = !empty($data['notifyReceiver']) ? $data['notifyReceiver'] : input('notifyReceiver', 'false');
|
||||
// 参数验证
|
||||
if (empty($wechatFriendIds)) {
|
||||
return json_encode(['code'=>500,'msg'=>'微信好友ID不能为空']);
|
||||
}
|
||||
|
||||
if (empty($toAccountId)) {
|
||||
return json_encode(['code'=>500,'msg'=>'目标账号ID不能为空']);
|
||||
}
|
||||
|
||||
|
||||
// 设置请求头
|
||||
$headerData = ['client:system'];
|
||||
$header = setHeader($headerData, $authorization, 'json');
|
||||
|
||||
// 发送请求
|
||||
$url = $this->baseUrl . 'api/WechatFriend/multiAllotFriendToAccount?wechatFriendIds='.$wechatFriendIds.'&toAccountId='.$toAccountId.'¬ifyReceiver='.$notifyReceiver;
|
||||
$result = requestCurl($url, [], 'PUT', $header, 'json');
|
||||
if (empty($result)) {
|
||||
return json_encode(['code'=>200,'msg'=>'微信好友分配成功']);
|
||||
} else {
|
||||
Cache::rm('system_authorization_token');
|
||||
Cache::rm('system_refresh_token');
|
||||
$errorNum ++;
|
||||
if ($errorNum <= 3) {
|
||||
$this->multiAllotFriendToAccount($data,$errorNum);
|
||||
}
|
||||
return json_encode(['code'=>500,'msg'=> $result]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user