代码优化
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
// 过滤掉已切换的,保留未切换和新进来的
|
||||
|
||||
Reference in New Issue
Block a user