兼容切换好友功能
This commit is contained in:
@@ -50,19 +50,21 @@ class SwitchFriendsCommand extends Command
|
|||||||
|
|
||||||
$automaticAssign = new AutomaticAssign();
|
$automaticAssign = new AutomaticAssign();
|
||||||
foreach ($toSwitch as $friend) {
|
foreach ($toSwitch as $friend) {
|
||||||
|
$friendId = !empty($friend['friendId']) ? $friend['friendId'] : $friend['id'];
|
||||||
$automaticAssign->allotWechatFriend([
|
$automaticAssign->allotWechatFriend([
|
||||||
'wechatFriendId' => $friend['friendId'],
|
'wechatFriendId' => $friendId,
|
||||||
'toAccountId' => $friend['accountId'],
|
'toAccountId' => $friend['accountId'],
|
||||||
], true);
|
], true);
|
||||||
$output->writeln('切换好友:' . $friend['friendId'] . ' 到账号:' . $friend['accountId']);
|
$output->writeln('切换好友:' . $friendId . ' 到账号:' . $friend['accountId']);
|
||||||
$switchedIds[] = $friend['friendId'];
|
$switchedIds[] = $friendId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过滤掉已切换的,保留未切换和新进来的
|
// 过滤掉已切换的,保留未切换和新进来的
|
||||||
$newFriends = Cache::get($cacheKey, []);
|
$newFriends = Cache::get($cacheKey, []);
|
||||||
$updated = [];
|
$updated = [];
|
||||||
foreach ($newFriends as $friend) {
|
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;
|
$updated[] = $friend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user