Browse Source

用户亲密度

lizhen_gitee 2 months ago
parent
commit
9f2ba88208

+ 0 - 15
application/api/controller/Index.php

@@ -247,21 +247,6 @@ class Index extends Api
 
 
 
-
-
-
-
-    /**
-     * 获取用户协议等 小程序
-     */
-    public function getWebsiteInfoForMini() {
-        $params = $this->request->request("params"); //内容
-        $res = config("site.".$params);
-        if($params == "boxGiftLogo") $res = $this->httpurl(config("site.".$params));
-        $this->success("获取成功!",$res);
-    }
-
-
     /*
      * 获取系统消息列表
      */

+ 151 - 0
application/api/controller/Intimacy.php

@@ -0,0 +1,151 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Cache;
+use think\Db;
+
+/**
+ * 亲密度
+ */
+class Intimacy extends Api
+{
+    protected $noNeedLogin = [''];
+    protected $noNeedRight = '*';
+
+    //消息列表好友/密友
+    public function intimacyfriends() {
+        $type = input('type', 0, 'intval'); //类型:0消息列表好友 1密友 2好友
+
+        $where = [];
+        /*if ($type == 0) {
+            $list = Db::name('user_follow')->field('follow_uid user_id')->where(['uid' => $this->auth->id])->autopage()->order('id desc')->select();
+
+            $mt_user = Db::name('user');
+//            $mt_user_follow = Db::name('user_follow');
+            $mt_user_intimacy = Db::name('user_intimacy');
+            foreach ($list as &$v) {
+                //查询亲密度
+                if ($this->auth->gender == 1) {
+                    $where['uid'] = $this->auth->id;
+                    $where['other_uid'] = $v['user_id'];
+                } else {
+                    $where['other_uid'] = $this->auth->id;
+                    $where['uid'] = $v['user_id'];
+                }
+                $user_intimacy = $mt_user_intimacy->field('value, updatetime')->where($where)->find();
+                $v['value'] = $user_intimacy ? $user_intimacy['value'] : 0;
+                $v['updatetime'] = $user_intimacy ? $user_intimacy['updatetime'] : 0;
+                //查询对方信息
+                $user_info = $mt_user->field('nickname, avatar,birthday,gender,real_status')->where(['id' => $v['user_id']])->find();
+                $v['nickname'] = $user_info['nickname'];
+                $v['avatar'] = one_domain_image($user_info['avatar']);
+                $v['updatetime'] = get_last_time($v['updatetime']);
+                $v['age'] = birthtime_to_age($user_info['birthday']);
+                $v['gender'] = $user_info['gender'];
+                $v['real_status'] = $user_info['real_status'];
+//                $v['status'] = $mt_user_follow->where(['uid' => $this->auth->id, 'follow_uid' => $v['user_id']])->count('id');
+                $v['status'] = 1;
+            }
+        } else {*/
+            if ($this->auth->gender == 1) {
+                $where['uid'] = $this->auth->id;
+                $field = 'other_uid user_id, value, updatetime';
+            } else {
+                $where['other_uid'] = $this->auth->id;
+                $field = 'uid user_id, value, updatetime';
+            }
+            if ($type == 1) { //密友
+                $where['value'] = ['egt', 1000];
+            } elseif ($type == 2) { //好友
+                $where['value'] = ['egt', 100];
+            } else { //消息列表好友
+                $where['value'] = ['egt', 10];
+            }
+
+            $list = Db::name('user_intimacy')->field($field)->where($where)->autopage()->order('updatetime desc')->select();
+
+            $mt_user = Db::name('user');
+            $mt_user_follow = Db::name('user_follow');
+            foreach ($list as &$v) {
+                $user_info = $mt_user->field('nickname, avatar,birthday,gender,real_status,is_active')->where(['id' => $v['user_id']])->find();
+                $v['nickname'] = $user_info['nickname'];
+                $v['avatar'] = one_domain_image($user_info['avatar']);
+                $v['updatetime'] = get_last_time($v['updatetime']);
+                $v['age'] = birthtime_to_age($user_info['birthday']);
+                $v['gender'] = $user_info['gender'];
+                $v['real_status'] = $user_info['real_status'];
+                $v['status'] = $mt_user_follow->where(['uid' => $this->auth->id, 'follow_uid' => $v['user_id']])->count('id');
+                $v['is_active'] = $user_info['is_active'];
+            }
+//        }
+
+        $this->success('success',$list);
+    }
+
+    //亲密度等级信息
+    public function intimacylevel() {
+        $user_id = input('user_id', 0, 'intval'); //对方id
+        if (!$user_id) {
+            $this->error('参数缺失');
+        }
+        if ($this->auth->gender == 0) { //女用户
+            $where['uid'] = $user_id;
+            $where['other_uid'] = $this->auth->id;
+        } else { //男用户
+            $where['uid'] = $this->auth->id;
+            $where['other_uid'] = $user_id;
+        }
+
+        $level = 0; //当前等级
+        $level_name = ''; //当前等级名称
+        $qinmi_sum = 0; //当前亲密度
+        $next_level_diff = 0; //距下一等级亲密度差值
+
+        //亲密度等级列表
+        $list = Db::name('intimacy_level')->field('name,level')->order('value')->select();
+
+        //当前亲密度信息
+        $user_intimacy_info = Db::name('user_intimacy')->where($where)->find();
+        if ($user_intimacy_info) {
+            //当前亲密度
+            $qinmi_sum = $user_intimacy_info['value'];
+            if ($list) {
+                //当前等级信息
+                $level_info = Db::name('intimacy_level')->where(['value' => ['elt', $user_intimacy_info['value']]])->order('id desc')->find();
+                if ($level_info) {
+                    $level = $level_info['level'];
+                    $level_name = $level_info['name'];
+                }
+                //下一等级信息
+                $next_level_info = Db::name('intimacy_level')->where(['value' => ['gt', $user_intimacy_info['value']]])->order('value')->find();
+                if ($next_level_info) {
+                    $next_level_diff = $next_level_info['value'] - $user_intimacy_info['value'];
+                }
+            }
+        } else {
+            $next_level_diff = Db::name('intimacy_level')->order('value')->value('value');
+        }
+        if ($list) {
+            foreach ($list as &$v) {
+                if ($v['level'] < $level) {
+                    $v['is_unlock'] = 1; //当前等级是否解锁: 1已解锁  2当前等级 3未解锁
+                } elseif ($v['level'] == $level) {
+                    $v['is_unlock'] = 2;
+                } else {
+                    $v['is_unlock'] = 3;
+                }
+            }
+        }
+
+        $data['level'] = $level; //当前等级
+        $data['level_name'] = $level_name; //当前等级名称
+        $data['qinmi_sum'] = $qinmi_sum; //当前亲密度
+        $data['next_level_diff'] = $next_level_diff; //距下一等级亲密度差值
+        $data['level_list'] = $list; //等级列表
+
+        $this->success('亲密度等级信息', $data);
+    }
+
+}

+ 0 - 130
application/api/controller/Usercenter.php

@@ -1034,75 +1034,7 @@ $resArray['money'] = $money;  //返回给前端的计算结果
         $this->success('success');
     }
     
-    //消息列表好友/密友
-    public function intimacyfriends() {
-        $type = input('type', 0, 'intval'); //类型:0消息列表好友 1密友 2好友
 
-        $where = [];
-        /*if ($type == 0) {
-            $list = Db::name('user_follow')->field('follow_uid user_id')->where(['uid' => $this->auth->id])->autopage()->order('id desc')->select();
-
-            $mt_user = Db::name('user');
-//            $mt_user_follow = Db::name('user_follow');
-            $mt_user_intimacy = Db::name('user_intimacy');
-            foreach ($list as &$v) {
-                //查询亲密度
-                if ($this->auth->gender == 1) {
-                    $where['uid'] = $this->auth->id;
-                    $where['other_uid'] = $v['user_id'];
-                } else {
-                    $where['other_uid'] = $this->auth->id;
-                    $where['uid'] = $v['user_id'];
-                }
-                $user_intimacy = $mt_user_intimacy->field('value, updatetime')->where($where)->find();
-                $v['value'] = $user_intimacy ? $user_intimacy['value'] : 0;
-                $v['updatetime'] = $user_intimacy ? $user_intimacy['updatetime'] : 0;
-                //查询对方信息
-                $user_info = $mt_user->field('nickname, avatar,birthday,gender,real_status')->where(['id' => $v['user_id']])->find();
-                $v['nickname'] = $user_info['nickname'];
-                $v['avatar'] = one_domain_image($user_info['avatar']);
-                $v['updatetime'] = get_last_time($v['updatetime']);
-                $v['age'] = birthtime_to_age($user_info['birthday']);
-                $v['gender'] = $user_info['gender'];
-                $v['real_status'] = $user_info['real_status'];
-//                $v['status'] = $mt_user_follow->where(['uid' => $this->auth->id, 'follow_uid' => $v['user_id']])->count('id');
-                $v['status'] = 1;
-            }
-        } else {*/
-            if ($this->auth->gender == 1) {
-                $where['uid'] = $this->auth->id;
-                $field = 'other_uid user_id, value, updatetime';
-            } else {
-                $where['other_uid'] = $this->auth->id;
-                $field = 'uid user_id, value, updatetime';
-            }
-            if ($type == 1) { //密友
-                $where['value'] = ['egt', 1000];
-            } elseif ($type == 2) { //好友
-                $where['value'] = ['egt', 100];
-            } else { //消息列表好友
-                $where['value'] = ['egt', 10];
-            }
-
-            $list = Db::name('user_intimacy')->field($field)->where($where)->autopage()->order('updatetime desc')->select();
-
-            $mt_user = Db::name('user');
-            $mt_user_follow = Db::name('user_follow');
-            foreach ($list as &$v) {
-                $user_info = $mt_user->field('nickname, avatar,birthday,gender,real_status,is_active')->where(['id' => $v['user_id']])->find();
-                $v['nickname'] = $user_info['nickname'];
-                $v['avatar'] = one_domain_image($user_info['avatar']);
-                $v['updatetime'] = get_last_time($v['updatetime']);
-                $v['age'] = birthtime_to_age($user_info['birthday']);
-                $v['gender'] = $user_info['gender'];
-                $v['real_status'] = $user_info['real_status'];
-                $v['status'] = $mt_user_follow->where(['uid' => $this->auth->id, 'follow_uid' => $v['user_id']])->count('id');
-                $v['is_active'] = $user_info['is_active'];
-            }
-//        }
-
-        $this->success('success',$list);
-    }
     
     //消息列表通话
     public function calllist() {
@@ -1218,69 +1150,7 @@ $resArray['money'] = $money;  //返回给前端的计算结果
         $this->success('success',$info);
     }
     
-    //亲密度等级信息
-    public function intimacylevel() {
-        $user_id = input('user_id', 0, 'intval'); //对方id
-        if (!$user_id) {
-            $this->error('参数缺失');
-        }
-        if ($this->auth->gender == 0) { //女用户
-            $where['uid'] = $user_id;
-            $where['other_uid'] = $this->auth->id;
-        } else { //男用户
-            $where['uid'] = $this->auth->id;
-            $where['other_uid'] = $user_id;
-        }
-
-        $level = 0; //当前等级
-        $level_name = ''; //当前等级名称
-        $qinmi_sum = 0; //当前亲密度
-        $next_level_diff = 0; //距下一等级亲密度差值
-
-        //亲密度等级列表
-        $list = Db::name('intimacy_level')->field('name,level')->order('value')->select();
-
-        //当前亲密度信息
-        $user_intimacy_info = Db::name('user_intimacy')->where($where)->find();
-        if ($user_intimacy_info) {
-            //当前亲密度
-            $qinmi_sum = $user_intimacy_info['value'];
-            if ($list) {
-                //当前等级信息
-                $level_info = Db::name('intimacy_level')->where(['value' => ['elt', $user_intimacy_info['value']]])->order('id desc')->find();
-                if ($level_info) {
-                    $level = $level_info['level'];
-                    $level_name = $level_info['name'];
-                }
-                //下一等级信息
-                $next_level_info = Db::name('intimacy_level')->where(['value' => ['gt', $user_intimacy_info['value']]])->order('value')->find();
-                if ($next_level_info) {
-                    $next_level_diff = $next_level_info['value'] - $user_intimacy_info['value'];
-                }
-            }
-        } else {
-            $next_level_diff = Db::name('intimacy_level')->order('value')->value('value');
-        }
-        if ($list) {
-            foreach ($list as &$v) {
-                if ($v['level'] < $level) {
-                    $v['is_unlock'] = 1; //当前等级是否解锁: 1已解锁  2当前等级 3未解锁
-                } elseif ($v['level'] == $level) {
-                    $v['is_unlock'] = 2;
-                } else {
-                    $v['is_unlock'] = 3;
-                }
-            }
-        }
-
-        $data['level'] = $level; //当前等级
-        $data['level_name'] = $level_name; //当前等级名称
-        $data['qinmi_sum'] = $qinmi_sum; //当前亲密度
-        $data['next_level_diff'] = $next_level_diff; //距下一等级亲密度差值
-        $data['level_list'] = $list; //等级列表
 
-        $this->success('亲密度等级信息', $data);
-    }
 
     //语音视频随聊
     public function getrandomuser() {