Commit cf43c737 by 杨树贤

签到列表的返回中添加受邀人电话

parent 4e37a0bf
<?php
namespace App\Services;
use Common\Model\RedisModel;
class BaseService
{
public function getUsersFromRedis($userIds = [])
{
$redis = new RedisModel();
$users = $redis->hmget('ic_user', $userIds);
foreach ($users as $key => $user) {
$users[$key] = json_decode($user, true);
}
return $users;
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
namespace App\Services;
class InviteService
class InviteService extends BaseService
{
public function getInviteList($map = [])
{
......@@ -12,6 +12,23 @@ class InviteService
$result = reportCurl($url, $map, true);
$result = json_decode($result, true);
//需要处理一下数据,因为要获得被邀请人的电话号码
$userMobiles = [];
if (isset($result['data']) && $result['data']) {
//获取到被邀请人的信息
$ids = array_column($result['data'], 'invited_user_id');
$users = $this->getUsersFromRedis($ids);
foreach ($users as $user) {
$userMobiles[$user['user_id']] = $user['mobile'];
}
$result['data'] = array_map(function ($value) use ($userMobiles) {
$value['invited_user_mobile'] = $userMobiles[$value['invited_user_id']];
return $value;
}, $result['data']);
}
return $result;
}
......
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