Commit a84bf01b by 叶明星

修复bug

parent 3836e5f6
Showing with 14 additions and 7 deletions
...@@ -19,6 +19,9 @@ class InviteTransformer ...@@ -19,6 +19,9 @@ class InviteTransformer
{ {
if (isset($data['data'])&&is_array($data['data'])) { if (isset($data['data'])&&is_array($data['data'])) {
$userIds = array_column($data['data'], 'user_id'); $userIds = array_column($data['data'], 'user_id');
$invitedUserIds = array_column($data['data'], 'invited_user_id');
$userIds = array_merge($userIds, $invitedUserIds);
$userIds = array_unique($userIds);
if ($userIds) { if ($userIds) {
$users = $this->service->getUsersFromRedis($userIds); $users = $this->service->getUsersFromRedis($userIds);
$mobiles = []; $mobiles = [];
...@@ -26,19 +29,23 @@ class InviteTransformer ...@@ -26,19 +29,23 @@ class InviteTransformer
$mobiles[$user['user_id']] = $user['mobile']; $mobiles[$user['user_id']] = $user['mobile'];
} }
$invitedUserIds = array_column($data['data'], 'invited_user_id'); // $invitedUserIds = array_column($data['data'], 'invited_user_id');
$invitedUsers = $this->service->getUsersFromRedis($invitedUserIds); // $invitedUsers = $this->service->getUsersFromRedis($invitedUserIds);
$invitedUserMobiles = []; // $invitedUserMobiles = [];
foreach ($users as $invitedUsers) { // dd($users);
$invitedUserMobiles[$invitedUsers['user_id']] = $user['mobile']; // foreach ($users as $invitedUsers) {
} // $invitedUserMobiles[$invitedUsers['user_id']] = $mobiles[$invitedUsers['user_id']];
// }
foreach ($data['data'] as &$item) { foreach ($data['data'] as &$item) {
//获取邀请人的手机 //获取邀请人的手机
$item['mobile'] = array_get($mobiles, $item['user_id']); $item['mobile'] = array_get($mobiles, $item['user_id']);
$item['add_time'] = date('Y-m-d H:i:s', $item['add_time']); $item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
//获取被邀请人的手机 //获取被邀请人的手机
$item['invited_user_mobile'] = array_get($invitedUserMobiles,$item['user_id']); $item['invited_user_mobile'] = array_get($mobiles,$item['invited_user_id']);
// if(empty($item['invited_user_mobile'])){
// dd($item['invited_user_id']);
// }
} }
} }
unset($item); unset($item);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment