Переглянути джерело

删除无用代码之:匹配视频用户,匹配语音用户,匹配私聊用户

lizhen_gitee 10 місяців тому
батько
коміт
0a4966fb9c

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

@@ -68,24 +68,8 @@ class Usercenter extends Api
         'is_hideaddress', 'is_recommend','is_cohabit', 'live_id', 'is_house', 'car_id', 'chest_id', 'waist'
     ];
 
-    public function testredis(){
-        //redis_matching_set(1,125);
-        dump(redis_matching_get(1));
-        $a = cache('?mt_matching_uid_1','',['type'=>'Redis']);
-        dump($a);
-    }
 
-    public function test(){
-        $a = [1,4,10,22,66,36,102,45,23,52,35,76,7];
-        $b = [1,10,7,102];
-        $c = [10,102];
 
-        //dump(array_intersect($a,$b));
-        $data = array_merge($c,$b);
-        dump($data);
-        dump(array_flip(array_flip($data)));
-        dump(array_flip([]));
-    }
 
     //获取他人用户信息,留下足迹
     public function getuserinfo(){
@@ -516,249 +500,6 @@ class Usercenter extends Api
     }
 
 
-    //语音匹配
-    public function getaudiouser(){
-
-        //判断资格
-        /*$start = strtotime(date('Y-m-d'));
-        $end   = $start + 86399;
-
-        $map = [
-            'user_id' => $this->auth->id,
-            'createtime' => ['between',[$start,$end]],
-            'price' => 0,
-        ];
-
-        $check = Db::name('user_match_audio_log')->where($map)->find();*/
-        $check = true;
-
-        //已经用掉免费的了,判断金额
-        if($check){
-            $price = config('site.audio_min_price');
-            $gold = model('wallet')->getWallet($this->auth->id,'gold');
-
-            if($gold < $price){
-                $this->error('您的金币已经不足,请充值');
-            }
-        }
-
-        //找到互关的人,排除
-        //$follow_me = Db::name('user_follow')->where('follow_uid',$this->auth->id)->column('uid');
-        //dump($follow_me);
-        //$my_follow = Db::name('user_follow')->where(['uid'=>$this->auth->id,'follow_uid'=>['IN',$follow_me]])->column('follow_uid');
-        //dump($my_follow);exit;
-
-
-        //给出备选用户
-        $map = [
-            'status' =>1,                                       //未封禁用户
-            'gender' => $this->auth->gender == 1 ? 0 : 1,       //异性
-            'is_online' => 0,                                   //不在语聊间的
-            'is_livebc' => 0,                                   //不在直播的
-            'is_active' => 1,                                   //在线的
-            //'real_status' => 1,                                 //真人认证
-            //'idcard_status' => 1,                               //实名认证
-            'open_match_audio' => 1,                            //打开语聊开关
-            //'id' => ['NOT IN',$my_follow]                       //不是好友的
-        ];
-
-        $lists = Db::name('user')->field('id,cityname,status,gender,real_status,tag_ids')->where($map)->order('logintime desc')->page($this->page,100)->select();
-        $lists = $this->fliter_user($lists,10);
-
-        $result = [];
-        if(!empty($lists)){
-            foreach($lists as $key => $val){
-                $result[] = ['id'=>$val];
-            }
-        }
-
-        //tag任务赠送金币
-        //语音匹配奖励  +5金币
-        if(!empty($result)){
-            $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,11);
-            if($task_rs === false){
-                $this->error('完成任务赠送奖励失败');
-            }
-        }
-
-        $this->success('success',$result);
-    }
-
-    //视频匹配
-    public function getvideouser(){
-
-        //判断资格
-        /*$start = strtotime(date('Y-m-d'));
-        $end   = $start + 86399;
-
-        $map = [
-            'user_id' => $this->auth->id,
-            'createtime' => ['between',[$start,$end]],
-            'price' => 0,
-        ];
-
-        $check = Db::name('user_match_video_log')->where($map)->find();*/
-        $check = true;
-
-        //已经用掉免费的了,判断金额
-        if($check){
-            $price = config('site.video_min_price');
-            $gold = model('wallet')->getWallet($this->auth->id,'gold');
-
-            if($gold < $price){
-                $this->error('您的金币已经不足,请充值');
-            }
-        }
-
-        //找到互关的人,排除
-        //$follow_me = Db::name('user_follow')->where('follow_uid',$this->auth->id)->column('uid');
-        //dump($follow_me);
-        //$my_follow = Db::name('user_follow')->where(['uid'=>$this->auth->id,'follow_uid'=>['IN',$follow_me]])->column('follow_uid');
-        //dump($my_follow);exit;
-
-
-        //给出备选用户
-        $map = [
-            'status' =>1,                                       //未封禁用户
-            'gender' => $this->auth->gender == 1 ? 0 : 1,       //异性
-            'is_online' => 0,                                   //不在语聊间的
-            'is_livebc' => 0,                                   //不在直播的
-            'is_active' => 1,                                   //在线的
-            //'real_status' => 1,                                 //真人认证
-            //'idcard_status' => 1,                               //实名认证
-            'open_match_video' => 1,                            //打开视频开关的
-           // 'id' => ['NOT IN',$my_follow]                       //不是好友的
-        ];
-
-        $lists = Db::name('user')->field('id,cityname,status,gender,real_status,tag_ids')->where($map)->order('logintime desc')->page($this->page,100)->select();
-        $lists = $this->fliter_user($lists,10);
-
-        $result = [];
-        if(!empty($lists)){
-            foreach($lists as $key => $val){
-                $result[] = ['id'=>$val];
-            }
-        }
-
-        //tag任务赠送金币
-        //视频匹配奖励  +5金币
-        if(!empty($result)){
-            $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,12);
-            if($task_rs === false){
-                $this->error('完成任务赠送奖励失败');
-            }
-        }
-        $this->success('success',$result);
-    }
-
-    //聊天匹配
-    public function gettypinguser(){
-
-        //找到互关的人,排除
-        //$follow_me = Db::name('user_follow')->where('follow_uid',$this->auth->id)->column('uid');
-        //dump($follow_me);
-        //$my_follow = Db::name('user_follow')->where(['uid'=>$this->auth->id,'follow_uid'=>['IN',$follow_me]])->column('follow_uid');
-        //dump($my_follow);exit;
-
-        //给出备选用户
-        $map = [
-            'status' =>1,                                        //未封禁用户
-            'gender' => $this->auth->gender == 1 ? 0 : 1,        //异性
-            //'real_status' => 1,                                 //真人认证
-            //'idcard_status' => 1,                               //实名认证
-            //'is_active' => 1,                                   //在线的
-            //打开聊天开关的
-            'open_match_typing' => 1,                            //打开文字聊天开关的
-            //'id' => ['NOT IN',$my_follow]                        //不是好友的
-        ];
-
-        $lists = Db::name('user')->field('id,cityname,status,gender,real_status,tag_ids')->where($map)->order('logintime desc')->page($this->page,100)->select();
-        //$lists = $this->fliter_user($lists,100);
-        $lists = array_column($lists,'id');
-
-        $result = [];
-        if(!empty($lists)){
-            /*foreach($lists as $key => $val){
-                $result[] = ['id'=>$val];
-            }*/
-            $result = Db::name('user')->field('id,nickname,username,avatar,audio_bio')->where(['id'=>['IN',$lists]])->select();
-            $result = list_domain_image($result,['avatar,audio_bio']);
-        }
-
-        //tag任务赠送金币
-        //缘分匹配奖励  +5金币
-        if(!empty($result)){
-            $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,10);
-            if($task_rs === false){
-                $this->error('完成任务赠送奖励失败');
-            }
-        }
-        $this->success('success',$result);
-    }
-
-    //过滤规则
-    private function fliter_user($lists,$number = 1){
-
-        if(empty($lists)){
-            return $lists;
-        }
-        //dump($lists);
-
-        //过滤掉通话中的
-        foreach($lists as $key => $val){
-            if(redis_matching_get($val['id']) == 1){
-                unset($lists[$key]);
-            }
-        }
-
-        //预留全部
-        $all_result = array_column($lists,'id');
-        //dump($all_result);
-
-        //提取同城的
-        $citydata = [];
-        foreach($lists as $key => $val){
-            if( !empty($this->auth->cityname) && $this->auth->cityname == $val['cityname'] ){
-                $citydata[] = $val['id'];
-            }
-        }
-        //dump($citydata);
-
-        //有标签交集的
-        $tagdata = [];
-        foreach($lists as $key => $val){
-            if( !empty($this->auth->tag_ids) && !empty($val['tag_ids']) ){
-
-                $auth_tag_ids = explode(',',$this->auth->tag_ids);
-                $val_tag_ids  = explode(',',$val['tag_ids']);
-                if(count(array_intersect($auth_tag_ids,$val_tag_ids)) > 0){
-                    $tagdata[] = $val['id'];
-                }
-            }
-        }
-        //dump($tagdata);
-
-        //双条件都满足
-        $double_data = [];
-        if(!empty($citydata) && !empty($tagdata)){
-            $double_data = array_intersect($citydata,$tagdata);
-        }
-        //dump($double_data);
-        if(count($double_data) >= $number){
-            return $double_data;
-        }
-
-        //两种条件合并,去重。空数组合并没影响
-        $merge_data = array_merge($citydata,$tagdata);
-        $merge_data = array_flip(array_flip($merge_data));
-        //dump($merge_data);
-        if(count($merge_data) >= $number){
-            return $merge_data;
-        }
-
-        return $all_result;
-    }
-
     /**
      * 是否关注
      */
@@ -1781,7 +1522,6 @@ $resArray['money'] = $money;  //返回给前端的计算结果
             }
 
             $lists = $query->select();
-            //$lists = $this->fliter_user($lists,100);
 
             $lists = list_domain_image($lists,['avatar,audio_bio']);
 
@@ -1849,7 +1589,6 @@ $resArray['money'] = $money;  //返回给前端的计算结果
             ->order('is_active desc, active_time desc')
             ->page($this->page,100)
             ->select();
-        //$lists = $this->fliter_user($lists,100);
 
         $lists = list_domain_image($lists,['avatar,audio_bio']);
 

+ 0 - 17
application/index/controller/Test.php

@@ -6,23 +6,6 @@ use think\Db;
 use Redis;
 class Test
 {
-    //显示所有人,匹配状态
-    public function showredis(){
-        $list = Db::name('user')->order('id desc')->column('id');
-        foreach($list as $key => $id){
-            dump($id.':'.redis_matching_get($id));
-            echo '<br/>';
-        }
-        exit;
-    }
-    //清除所有人,匹配状态
-    public function clearredis(){
-        $list = Db::name('user')->order('id desc')->column('id');
-        foreach($list as $key => $id){
-            $a = redis_matching_set($id,0);
-        }
-        exit;
-    }
 
 
     public function test1(){

+ 1 - 8
thinkphp/helper.php

@@ -364,14 +364,7 @@ if (!function_exists('cache')) {
      * @param string    $tag 缓存标签
      * @return mixed
      */
-    function redis_matching_set($name,$value,$expire = null){
-        $cache = Cache::connect(['type'=>'Redis']);
-        return $cache->set('mt_matching_uid_'.$name, $value, $expire);
-    }
-    function redis_matching_get($name){
-        $cache = Cache::connect(['type'=>'Redis']);
-        return $cache->get('mt_matching_uid_'.$name);
-    }
+
     function cache($name, $value = '', $options = null, $tag = null)
     {
         if (is_array($options)) {