diff --git a/Server/application/cunkebao/controller/ContentLibraryController.php b/Server/application/cunkebao/controller/ContentLibraryController.php index 0b648a9c..3a445cfc 100644 --- a/Server/application/cunkebao/controller/ContentLibraryController.php +++ b/Server/application/cunkebao/controller/ContentLibraryController.php @@ -916,17 +916,14 @@ class ContentLibraryController extends Controller //执行切换好友命令 $automaticAssign = new AutomaticAssign(); $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['id'],'toAccountId' => $toAccountId],true); + //存入缓存 + $friendData['friendId'] = $friend['id']; + artificialAllotWechatFriend($friendData); //执行采集朋友圈命令 $webSocket = new WebSocketController(['userName' => $username,'password' => $password,'accountId' => $toAccountId]); $webSocket->getMoments(['wechatFriendId' => $friend['id'],'wechatAccountId' => $friend['wechatAccountId']]); //采集完毕切换 - $res = $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['id'],'toAccountId' => $friend['accountId']],true); - $res = json_decode($res, true); - if($res == '无效路径或登录状态失效'){ - $cacheFriend = $friend; - $cacheFriend['friendId'] = $friend['id']; - artificialAllotWechatFriend($friend); - } + $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['id'],'toAccountId' => $friend['accountId']],true); } @@ -1035,12 +1032,6 @@ class ContentLibraryController extends Controller ]; } catch (\Exception $e) { - - $cacheFriend = $friendData; - $cacheFriend['friendId'] = $friend['id']; - artificialAllotWechatFriend($friend); - - return [ 'status' => 'error', 'message' => '采集过程发生错误: ' . $e->getMessage() diff --git a/Server/application/job/WechatMomentsJob.php b/Server/application/job/WechatMomentsJob.php index 88d380d2..ad9f5345 100644 --- a/Server/application/job/WechatMomentsJob.php +++ b/Server/application/job/WechatMomentsJob.php @@ -46,26 +46,20 @@ class WechatMomentsJob // 执行切换好友命令 $automaticAssign = new AutomaticAssign(); $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $toAccountId], true); + //存入缓存 + artificialAllotWechatFriend($friend); // 执行采集朋友圈命令 $webSocket = new WebSocketController(['userName' => $username, 'password' => $password, 'accountId' => $toAccountId]); $webSocket->getMoments(['wechatFriendId' => $friend['friendId'], 'wechatAccountId' => $friend['wechatAccountId']]); // 处理完毕切换回原账号 - $res = $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); - $res = json_decode($res, true); - if ($res == '无效路径或登录状态失效'){ - artificialAllotWechatFriend($friend); - } + $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); } catch (\Exception $e) { // 发生异常时也要切换回原账号 - $res = $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); - $res = json_decode($res, true); - if ($res == '无效路径或登录状态失效'){ - artificialAllotWechatFriend($friend); - } + $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); Log::error("采集好友 {$friend['id']} 的朋友圈失败:" . $e->getMessage()); continue; } diff --git a/Server/application/job/WorkbenchAutoLikeJob.php b/Server/application/job/WorkbenchAutoLikeJob.php index b0f489de..5f656025 100644 --- a/Server/application/job/WorkbenchAutoLikeJob.php +++ b/Server/application/job/WorkbenchAutoLikeJob.php @@ -219,7 +219,8 @@ class WorkbenchAutoLikeJob // 执行切换好友命令 $automaticAssign = new AutomaticAssign(); $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $toAccountId], true); - + //存入缓存 + artificialAllotWechatFriend($friend); // 创建WebSocket链接 $webSocket = new WebSocketController(['userName' => $username, 'password' => $password, 'accountId' => $toAccountId]); @@ -234,12 +235,7 @@ class WorkbenchAutoLikeJob if (empty($moments) || count($moments) == 0) { // 处理完毕切换回原账号 - $res = $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); - $res = json_decode($res, true); - if($res == '无效路径或登录状态失效'){ - artificialAllotWechatFriend($friend); - } - + $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); Log::info("好友 {$friend['friendId']} 没有需要点赞的朋友圈"); return; } @@ -263,19 +259,11 @@ class WorkbenchAutoLikeJob } // 处理完毕切换回原账号 - $res = $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); - $res = json_decode($res, true); - if($res == '无效路径或登录状态失效'){ - artificialAllotWechatFriend($friend); - } + $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); } catch (\Exception $e) { // 异常情况下也要确保切换回原账号 $automaticAssign = new AutomaticAssign(); - $res = $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); - $res = json_decode($res, true); - if($res == '无效路径或登录状态失效'){ - artificialAllotWechatFriend($friend); - } + $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $friend['accountId']], true); Log::error("处理好友 {$friend['friendId']} 朋友圈失败异常: " . $e->getMessage()); } }