代码优化

This commit is contained in:
wong
2025-07-08 11:56:24 +08:00
parent 2d55cac6fd
commit d5968a0991

View File

@@ -34,7 +34,6 @@ class SwitchFriendsCommand extends Command
do {
$friends = Cache::get($cacheKey, []);
$original = $friends;
$toSwitch = [];
foreach ($friends as $friend) {
@@ -51,12 +50,18 @@ class SwitchFriendsCommand extends Command
$automaticAssign = new AutomaticAssign();
foreach ($toSwitch as $friend) {
$friendId = !empty($friend['friendId']) ? $friend['friendId'] : $friend['id'];
$automaticAssign->allotWechatFriend([
$res = $automaticAssign->allotWechatFriend([
'wechatFriendId' => $friendId,
'toAccountId' => $friend['accountId'],
], true);
$output->writeln('切换好友:' . $friendId . ' 到账号:' . $friend['accountId']);
$switchedIds[] = $friendId;
$res = json_decode($res, true);
if ($res['code'] == 200){
$output->writeln('切换好友:' . $friendId . ' 到账号:' . $friend['accountId']);
$switchedIds[] = $friendId;
}else{
$output->writeln('切换好友:' . $friendId . ' 到账号:' . $friend['accountId'] .' 结果:' .$res['msg']);
}
sleep(1);
}
// 过滤掉已切换的,保留未切换和新进来的