From 5240852df9df7aab03eaf45e4fdd3001689e4ee4 Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Wed, 21 May 2025 16:36:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=82=B9=E8=B5=9E=20?= =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E7=99=BB=E5=BD=95=E5=89=8D=E7=BD=AE=E5=88=B0?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E5=A4=9A=E8=BF=9B=E7=A8=8B=E5=89=8D=20?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E9=87=8D=E5=A4=8D=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/application/job/WorkbenchJob.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Server/application/job/WorkbenchJob.php b/Server/application/job/WorkbenchJob.php index 1f3c1484..cb2eb3a0 100644 --- a/Server/application/job/WorkbenchJob.php +++ b/Server/application/job/WorkbenchJob.php @@ -197,10 +197,18 @@ class WorkbenchJob } // 将好友列表分成20组 - $friendGroups = array_chunk($friendList, 10); - + $friendGroups = array_chunk($friendList, 20); $processes = []; + // 初始化WebSocketController + $username = Env::get('api.username', ''); + $password = Env::get('api.password', ''); + $toAccountId = ''; + if (!empty($username) || !empty($password)) { + $toAccountId = Db::name('users')->where('account',$username)->value('s2_accountId'); + } + $webSocket = new WebSocketController(['userName' => $username, 'password' => $password, 'accountId' => $toAccountId]); + foreach ($friendGroups as $groupIndex => $friendGroup) { // 创建子进程 $pid = pcntl_fork(); @@ -216,7 +224,6 @@ class WorkbenchJob // 子进程 try { foreach ($friendGroup as $friend) { - // 验证是否达到点赞次数上限 $likeCount = $this->getTodayLikeCount($workbench, $config, $friend['deviceId']); if ($likeCount >= $config['maxLikes']) { @@ -231,7 +238,7 @@ class WorkbenchJob ->count(); if ($friendMaxLikes < $config['friendMaxLikes']) { - $this->processFriendMoments($workbench, $config, $friend); + $this->processFriendMoments($workbench, $config, $friend, $webSocket); } } } catch (\Exception $e) { @@ -307,8 +314,9 @@ class WorkbenchJob * @param Workbench $workbench * @param WorkbenchAutoLike $config * @param array $friend + * @param WebSocketController $webSocket */ - protected function processFriendMoments($workbench, $config, $friend) + protected function processFriendMoments($workbench, $config, $friend, $webSocket) { $toAccountId = ''; $username = Env::get('api.username', ''); @@ -323,7 +331,6 @@ class WorkbenchJob $automaticAssign->allotWechatFriend(['wechatFriendId' => $friend['friendId'], 'toAccountId' => $toAccountId], true); // 执行采集朋友圈命令 - $webSocket = new WebSocketController(['userName' => $username, 'password' => $password, 'accountId' => $toAccountId]); $webSocket->getMoments(['wechatFriendId' => $friend['friendId'], 'wechatAccountId' => $friend['wechatAccountId']]); // 查询未点赞的朋友圈