预防执行点赞、采集朋友圈等切换好友无法切换回来
This commit is contained in:
@@ -7,6 +7,7 @@ use app\cunkebao\model\ContentItem;
|
||||
use think\Controller;
|
||||
use think\Db;
|
||||
use app\api\controller\WebSocketController;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Env;
|
||||
use app\api\controller\AutomaticAssign;
|
||||
|
||||
@@ -893,6 +894,25 @@ class ContentLibraryController extends Controller
|
||||
//执行切换好友命令
|
||||
$automaticAssign = new AutomaticAssign();
|
||||
$automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['id'],'toAccountId' => $toAccountId],true);
|
||||
|
||||
//记录切换好友
|
||||
$cacheKey = 'allotWechatFriend';
|
||||
$cacheFriend = $friend;
|
||||
$cacheFriend['time'] = time() + 120;
|
||||
$maxRetry = 5;
|
||||
$retry = 0;
|
||||
do {
|
||||
$cacheFriendData = Cache::get($cacheKey, []);
|
||||
// 去重:移除同friendId的旧数据
|
||||
$cacheFriendData = array_filter($cacheFriendData, function($item) use ($cacheFriend) {
|
||||
return $item['friendId'] !== $cacheFriend['friendId'];
|
||||
});
|
||||
$cacheFriendData[] = $cacheFriend;
|
||||
$success = Cache::set($cacheKey, $cacheFriendData);
|
||||
$retry++;
|
||||
} while (!$success && $retry < $maxRetry);
|
||||
|
||||
|
||||
//执行采集朋友圈命令
|
||||
$webSocket = new WebSocketController(['userName' => $username,'password' => $password,'accountId' => $toAccountId]);
|
||||
$webSocket->getMoments(['wechatFriendId' => $friend['id'],'wechatAccountId' => $friend['wechatAccountId']]);
|
||||
|
||||
Reference in New Issue
Block a user