代码提交
This commit is contained in:
@@ -37,7 +37,13 @@ class SwitchFriendsCommand extends Command
|
||||
$output->writeln('开始执行好友切换任务...');
|
||||
|
||||
do {
|
||||
$friends = Cache::get($cacheKey, []);
|
||||
//$friends = Cache::get($cacheKey, []);
|
||||
|
||||
$friends = [
|
||||
['time' => 1111,'accountId' => 6222,'friendId' => 21075650],
|
||||
['time' => 1111,'accountId' => 6222,'friendId' => 20112769],
|
||||
];
|
||||
|
||||
|
||||
$toSwitch = [];
|
||||
foreach ($friends as $friend) {
|
||||
@@ -65,25 +71,23 @@ class SwitchFriendsCommand extends Command
|
||||
$friendId = !empty($friend['friendId']) ? $friend['friendId'] : $friend['id'];
|
||||
$groupedByAccount[$accountId][] = $friendId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 对每个账号的好友进行20个为一组的分组
|
||||
foreach ($groupedByAccount as $accountId => $accountFriends) {
|
||||
$chunks = array_chunk($accountFriends, 20);
|
||||
$output->writeln('账号 ' . $accountId . ' 共有 ' . count($accountFriends) . ' 个好友,分为 ' . count($chunks) . ' 组');
|
||||
|
||||
$accountSuccess = 0;
|
||||
$accountFailed = 0;
|
||||
|
||||
|
||||
foreach ($chunks as $chunkIndex => $chunk) {
|
||||
$output->writeln('处理账号 ' . $accountId . ' 第 ' . ($chunkIndex + 1) . ' 组,共 ' . count($chunk) . ' 个好友');
|
||||
|
||||
try {
|
||||
$friendIds = implode(',', $chunk);
|
||||
$res = $automaticAssign->multiAllotFriendToAccount([
|
||||
'wechatFriendIds' => $friendIds,
|
||||
'toAccountId' => $accountId,
|
||||
]);
|
||||
|
||||
$res = json_decode($res, true);
|
||||
if ($res['code'] == 200){
|
||||
$output->writeln('✓ 成功切换好友:' . $friendIds . ' 到账号:' . $accountId);
|
||||
|
||||
Reference in New Issue
Block a user