diff --git a/Server/application/command/SwitchFriendsCommand.php b/Server/application/command/SwitchFriendsCommand.php index 422fb4bf..ec197d7e 100644 --- a/Server/application/command/SwitchFriendsCommand.php +++ b/Server/application/command/SwitchFriendsCommand.php @@ -50,19 +50,21 @@ class SwitchFriendsCommand extends Command $automaticAssign = new AutomaticAssign(); foreach ($toSwitch as $friend) { + $friendId = !empty($friend['friendId']) ? $friend['friendId'] : $friend['id']; $automaticAssign->allotWechatFriend([ - 'wechatFriendId' => $friend['friendId'], + 'wechatFriendId' => $friendId, 'toAccountId' => $friend['accountId'], ], true); - $output->writeln('切换好友:' . $friend['friendId'] . ' 到账号:' . $friend['accountId']); - $switchedIds[] = $friend['friendId']; + $output->writeln('切换好友:' . $friendId . ' 到账号:' . $friend['accountId']); + $switchedIds[] = $friendId; } // 过滤掉已切换的,保留未切换和新进来的 $newFriends = Cache::get($cacheKey, []); $updated = []; foreach ($newFriends as $friend) { - if (!in_array($friend['friendId'], $switchedIds)) { + $friendId = !empty($friend['friendId']) ? $friend['friendId'] : $friend['id']; + if (!in_array($friendId, $switchedIds)) { $updated[] = $friend; } }