Parcourir la source

获取他人用户信息

lizhen_gitee il y a 1 an
Parent
commit
3fb1e9563e

+ 2 - 1
application/api/controller/Baseconfig.php

@@ -16,7 +16,8 @@ class Baseconfig extends Api
     public function index(){
 
         $config = [
-            'index_pipei_switch'    => config('site.index_pipei_switch'), //首页匹配功能开关
+            'kefu_userids'    => config('site.kefu_userids'), //在线客服用户ids
+//            'index_pipei_switch'    => config('site.index_pipei_switch'), //首页匹配功能开关
         ];
 
         $this->success('success',$config);

+ 20 - 63
application/api/controller/Usercenter.php

@@ -28,71 +28,48 @@ class UserCenter extends Common
         $this->userModel = new \app\common\model\User();
     }
 
-    /**
-     * 获取当前用户信息
-     */
-    public function getMyUserInfo() {
-        $this->success("获取成功!",$this->auth->getUserinfo());
-    }
+
 
     /**
      * 获取个人信息
      */
     public function getUserInfo() {
-        $user_id = $this->request->param("user_id");
+        $user_id = input("user_id");
         if (!$user_id) {
             $this->error(__('Invalid parameters'));
         }
         // 获取基本信息
         $where = [];
         $where["id"] = $user_id;
-        $userInfo = $this->userModel->field("id,nickname,pre_nickname,image,mobile,avatar,pre_avatar,gender,age,u_id,level,jewel,
-        age_id,constellation_id,province_id,city_id,desc,is_cool,is_manager,is_stealth,charm_level,wealth_level")->where($where)->find();
+        $userInfo = $this->userModel->field("id,nickname,mobile,avatar,gender,u_id,level,age_id,province_id,city_id,desc,charm_level,wealth_level,job_id")->where($where)->find();
+        if(!$userInfo){
+            $this->error('不存在的用户');
+        }
+        $userInfo = info_domain_image($userInfo,['avatar']);
 
         //用户钱包
         $userwallet = Db::name('user_wallet')->where('user_id',$user_id)->find();
-        $userInfo['money'] = $userwallet['money'];
-        $userInfo['jewel'] = $userwallet['jewel'];
+        $userInfo['wallet'] = $userwallet;
+
 
-        $userInfo['nickname_status'] = $userInfo['avatar_status'] = 0;
-        if (!empty($userInfo['pre_nickname']) && $userInfo['pre_nickname'] != $userInfo['nickname']) {
-            $userInfo['nickname_status'] = 1;
-        }
-        if (!empty($userInfo['pre_avatar']) && $userInfo['pre_avatar'] != $userInfo['avatar']) {
-            $userInfo['avatar_status'] = 1;
-        }
         $userInfoA = $this->userModel->getAppendData($userInfo);
         $userInfo['age_text'] = $userInfoA['age_text'];
-        $userInfo['constellation_text'] = $userInfoA['constellation_text'];
         $userInfo['province_text'] = $userInfoA['province_text'];
         $userInfo['city_text'] = $userInfoA['city_text'];
-        $userInfo['friends_num'] = $userInfoA['friends_num'];
+//        $userInfo['friends_num'] = $userInfoA['friends_num'];
         $userInfo['look_num'] = $userInfoA['look_num'];
-        // 获取技能信息
-        $skillList = Model("ViewUserSkill")->getSkillInfo($user_id);
-        $userInfo["skill"] = implode("/",$skillList);
-        // 获取关注粉丝信息
-        $followModel = new \app\common\model\ViewFollows();
-        $fansModel = new \app\common\model\ViewFans();
-        // 获取关注信息
-        $where = [];
-        $where["user_id"] = $user_id;
-        $userCount = $followModel->where($where)->value("follows"); //该用户关注了几个人
-        $userInfo["follows_count"] = $userCount?$userCount:0;
-        $userInfo["follows"] = $userInfo["follows_count"];//前端字段使用不一致添加
-        // 获取粉丝数
-        $where = [];
-        $where["user_id"] = $user_id;
-        $fansCount = $fansModel->where($where)->value("fans"); //该用户的粉丝数
-        $userInfo["fans_count"] = $fansCount?$fansCount:0;
-        $userInfo["fans"] = $userInfo["fans_count"];//前端字段使用不一致添加
-        // 获取贵族信息
-        $nobleInfo = $this->userModel->getUserNobleInfo($user_id);
+
+        //关注人数,粉丝人数
+        $follow_num = Db::name('user_follow')->where(['uid'=>$user_id])->count('id');
+        $fans_num   = Db::name('user_follow')->where(['follow_uid'=>$user_id])->count('id');
+        $userinfo['follow_num'] = $follow_num;
+        $userinfo['fans_num'] = $fans_num;
+
         // 查看者是否已关注
         $userInfo["is_follow"] = $this->is_follow($this->auth->id,$user_id);
+        $userInfo['is_friend'] = $this->is_friend($this->auth->id,$user_id);
+        $userInfo['is_black']  = $this->is_black($this->auth->id,$user_id);
 
-        $userInfo = json_decode(json_encode($userInfo),true);
-        $userInfo = array_merge($userInfo,$nobleInfo);
 
         // 获取用户在派对直播间情况信息
         $redis = new Redis();
@@ -111,8 +88,6 @@ class UserCenter extends Common
             $party = \app\common\model\Party::where('id',$livingUserPartyId)->field('id,room_type')->find();
             $userInfo['party_info'] = ['party_id' => $party['id'], 'room_type' => $party['room_type']];
         }
-        
-        $userInfo['is_black'] = $this->is_black($this->auth->id,$user_id);
 
         $memberinfo = Db::name('guild_member')->alias('m')->field('m.id as `member_id`,m.user_id,guild.name,guild.image,guild.member,guild.desc')->join('guild','m.guild_id = guild.id','LEFT')->where(['m.user_id'=>$user_id,'m.status'=>1])->find();
         if ($memberinfo) {
@@ -131,15 +106,7 @@ class UserCenter extends Common
             $guildStatus = (int)$guildInfo['status'];
         }
         $userInfo['guild_status'] = $guildStatus;//家族状态:公会状态:0=待审核,1=正常,-1=已解散,-2无公会
-        //动态
-        //技能
-        //礼物
-        if (empty($this->auth->power)) {
-            $power = UserPower::where(['user_id'=>$user_id])->find();
-        } else {
-            $power = $this->auth->power;
-        }
-        $userInfo['user_power'] = $power;
+
         //访客记录
         if ($this->auth->id != $user_id) {
             $visit_data = [
@@ -155,16 +122,6 @@ class UserCenter extends Common
             }
         }
 
-        //贡献等级
-        $charm_info = Db::name('user_config_charm')->where('level',$userInfo['charm_level'])->find();
-        $userInfo['charm_image'] = localpath_to_netpath($charm_info['image']);
-        $userInfo['charm_color'] = $charm_info['color'];
-
-        //财富等级
-        $wealth_info = Db::name('user_config_wealth')->where('level',$userInfo['wealth_level'])->find();
-        $userInfo['wealth_image'] = localpath_to_netpath($wealth_info['image']);
-        $userInfo['wealth_color'] = $wealth_info['color'];
-
         $this->success("获取成功!",$userInfo);
     }
 

+ 3 - 61
application/common/model/User.php

@@ -115,8 +115,8 @@ class User extends Model
     {
         if (!$value) {
             //如果不需要启用首字母头像,请使用
-            //$value = '/assets/img/avatar.png';
-            $value = letter_avatar($data['nickname']);
+            $value = '/assets/img/avatar.png';
+            //$value = letter_avatar($data['nickname']);
         }
         return $value;
     }
@@ -153,63 +153,7 @@ class User extends Model
         return $value;
     }
 
-    /**
-     * 变更会员余额
-     * @param int    $money   余额
-     * @param int    $user_id 会员ID
-     * @param string $memo    备注
-     */
-    /*public static function money($money, $user_id, $memo)
-    {
-        return;//作废
-        $user = self::get($user_id);
-        if ($user && $money != 0) {
-            $before = $user->money;
-            //$after = $user->money + $money;
-            $after = function_exists('bcadd') ? bcadd($user->money, $money, 2) : $user->money + $money;
-            //更新会员信息
-            $user->save(['money' => $after]);
-            //写入日志
-            MoneyLog::create(['user_id' => $user_id, 'money' => $money, 'before' => $before, 'after' => $after, 'detail' => $memo]);
-        }
-    }*/
 
-    /**
-     * 变更会员积分
-     * @param int    $score   积分
-     * @param int    $user_id 会员ID
-     * @param string $memo    备注
-     */
-    /*public static function score($score, $user_id, $memo)
-    {
-        $user = self::get($user_id);
-        if ($user && $score != 0) {
-            $before = $user->score;
-            $after = $user->score + $score;
-            $level = self::nextlevel($after);
-            //更新会员信息
-            $user->save(['score' => $after, 'level' => $level]);
-            //写入日志
-            ScoreLog::create(['user_id' => $user_id, 'score' => $score, 'before' => $before, 'after' => $after, 'memo' => $memo]);
-        }
-    }*/
-
-    /**
-     * 根据积分获取等级
-     * @param int $score 积分
-     * @return int
-     */
-    /*public static function nextlevel($score = 0)
-    {
-        $lv = array(1 => 0, 2 => 30, 3 => 100, 4 => 500, 5 => 1000, 6 => 2000, 7 => 3000, 8 => 5000, 9 => 8000, 10 => 10000);
-        $level = 1;
-        foreach ($lv as $key => $value) {
-            if ($score >= $value) {
-                $level = $key;
-            }
-        }
-        return $level;
-    }*/
 
     /**
      * 根据排行信息获取用户信息
@@ -245,7 +189,7 @@ class User extends Model
                     "nickname" => $userIdKeyList[$k]["nickname"],
                     "gender" => $userIdKeyList[$k]["gender"], // 性别
                     "level" => $userIdKeyList[$k]["level"], // 积分等级
-                    "jewel" => $v, // 财富数
+//                    "jewel" => $v, // 财富数
                 ];
                 $rank ++;
             }
@@ -449,11 +393,9 @@ class User extends Model
         if (!empty($userInfo)) {
             $userId = isset($userInfo['id']) ? $userInfo['id'] : 0;
             $ageId = isset($userInfo['age_id']) ? $userInfo['age_id'] : 0;
-            $constellationId = isset($userInfo['constellation_id']) ? $userInfo['constellation_id'] : 0;
             $provinceId = isset($userInfo['province_id']) ? $userInfo['province_id'] : 0;
             $cityId = isset($userInfo['city_id']) ? $userInfo['city_id'] : 0;
             $userInfo['age_text'] = $this->getAgeTextAttr(false,['age_id' => $ageId]);
-            $userInfo['constellation_text'] = $this->getConstellationTextAttr(false,['constellation_id' => $constellationId]);
             $areaWhere['id'] = ['in',[$provinceId,$cityId]];
             $areaData = Db::name('shopro_area')->where($areaWhere)->column('id,name');
             $userInfo['province_text'] = isset($areaData[$provinceId]) ? $areaData[$provinceId] : '';

+ 1 - 0
application/extra/site.php

@@ -136,4 +136,5 @@ return [
     'index_pipei_switch' => '1',
     'index_pipei_oneday_user_times' => '-1',
     'pipei_oneday_vipuser_times' => '-1',
+    'kefu_userids' => '2,3,4',
 ];