Browse Source

删除觅他的匹配规则

lizhen_gitee 1 year ago
parent
commit
b4328840d6
2 changed files with 0 additions and 363 deletions
  1. 0 7
      application/api/controller/User.php
  2. 0 356
      application/api/controller/Usercenter.php

+ 0 - 7
application/api/controller/User.php

@@ -315,8 +315,6 @@ class User extends Api
 //        $tenIm = new Tenim();
 //        $tenIm->loginoutim($this->auth->id);
 
-        //修改用户活跃0
-        Db::name('user')->where('id',$this->auth->id)->update(['is_active' => 0]);
 
         $this->auth->logout();
         $this->success(__('Logout successful'));
@@ -783,11 +781,6 @@ class User extends Api
         $this->success('注销成功');
     }
 
-    //修改用户活跃1
-    public function useractive(){
-        Db::name('user')->where('id',$this->auth->id)->update(['is_active' => 1,'active_time' => time()]);
-        $this->success('success');
-    }
 
     //APP 转化数据统计方案(即:APP 上报对接方案): 广告主上报激活数据,亿米平台搭建服务系统关联点击&下载数据和广告主提供的所有激活数据,将激活数据归因到对应广告。
     public function yimi_advert(){

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

@@ -111,367 +111,11 @@ class Usercenter extends Api
         $this->success('success',$userinfo);
 
     }
-/////////////////////////////////////////////////////////////////////////////////////
-    //这里不用连user_active表,完全使用user表的active_time,user_active表只做离线用
-    //同城
-    public function samecity(){
-        $gender = input_post('gender','all');
-        $agemin = input_post('agemin',0);
-        $agemax = input_post('agemax',100);
-
-        if(empty($this->auth->cityname) || empty($this->auth->longitude) || empty($this->auth->latitude)){
-           // $this->success('success',[]);
-        }
-
-        $map = [
-            'user.status' => 1,
-           // 'user.cityname' => $this->auth->cityname,
-            'user.id' => ['neq',$this->auth->id],
-           // 'user.longitude' => ['neq',''],
-           // 'user.latitude' => ['neq',''],
-           // 'user.is_online|user.is_livebc' => 1, //完全不考虑直播与语聊的权重,只用活跃做排序
-           // 'user.active_time' => ['gt',time()-86400],
-        ];
-        if($gender != 'all'){
-            $map['user.gender'] = $gender;
-        }
-
-        $map['user.birthday'] = ['between',[time() - $agemax * 31536000,time() - $agemin * 31536000]];
-
-        //dump($map);
-        $field = [
-            'user.id','user.username','user.nickname','user.birthday','user.height','user.longitude','user.latitude','user.avatar','user.audio_bio','user.bio','user.gender','user.active_time'
-        ];
-        $list = Db::name('user')->alias('user')->field($field)->where($map)->order('user.active_time desc')->autopage()->select();
-        //dump($list);
-
-        $list = list_domain_image($list,['avatar']);
-
-        foreach($list as $key => $one){
-            $one['age'] = birthtime_to_age($one['birthday']);
-           // $one['distance'] = $this->calc_map_distance([$this->auth->longitude,$this->auth->latitude],[$one['longitude'],$one['latitude']]);
-            $one['distance'] = rand(0,10).'km';
-
-            //状态
-            $one['active_text'] = '刚刚离线';
-            if($one['active_time'] > time()-21600){
-                $one['active_text'] = '1小时内在线';
-            }
-            if($one['active_time'] > time()-3600){
-                $one['active_text'] = '在线';
-            }
-
-            $list[$key] = $one;
-        }
-
-        $this->success('success',$list);
-
-    }
-
-    //附近
-    public function nearuser(){
-        $gender = input_post('gender','all');
-        $agemin = input_post('agemin',0);
-        $agemax = input_post('agemax',100);
-
-        if(empty($this->auth->cityname) || empty($this->auth->longitude) || empty($this->auth->latitude)){
-           // $this->success('success',[]);
-        }
-
-        //经过地图测算和公式推算,经度纬度 0.1即为11公里
-        $map = [
-            'user.status' => 1,
-            ////'user.cityname' => $this->auth->cityname,
-            'user.id' => ['neq',$this->auth->id],
-           // 'user.longitude' => ['between',[$this->auth->longitude - 0.1,$this->auth->longitude + 0.1]],
-           // 'user.latitude' => ['between',[$this->auth->latitude - 0.1,$this->auth->latitude + 0.1]],
-            // 'user.is_online|user.is_livebc' => 1, //完全不考虑直播与语聊的权重,只用活跃做排序
-           // 'user.active_time' => ['gt',time()-86400],
-        ];
-        if($gender != 'all'){
-            $map['user.gender'] = $gender;
-        }
-
-        $map['user.birthday'] = ['between',[time() - $agemax * 31536000,time() - $agemin * 31536000]];
-
-        //dump($map);
-        $field = [
-            'user.id','user.username','user.nickname','user.birthday','user.height','user.longitude','user.latitude','user.avatar','user.audio_bio','user.bio','user.gender','user.active_time'
-        ];
 
-        $list = Db::name('user')->alias('user')->field($field)->where($map)->order('user.active_time desc')->autopage()->select();
-        //dump($list);exit;
 
-        $list = list_domain_image($list,['avatar']);
 
-        foreach($list as $key => $one){
-            $one['age'] = birthtime_to_age($one['birthday']);
-            //$one['distance'] = $this->calc_map_distance([$this->auth->longitude,$this->auth->latitude],[$one['longitude'],$one['latitude']]);
-            $one['distance'] = rand(0,10).'km';
 
-            //状态
-            $one['active_text'] = '刚刚离线';
-            if($one['active_time'] > time()-21600){
-                $one['active_text'] = '1小时内在线';
-            }
-            if($one['active_time'] > time()-3600){
-                $one['active_text'] = '在线';
-            }
-            
-            $list[$key] = $one;
-        }
-
-        $this->success('success',$list);
-
-    }
-
-
-
-    //语音匹配
-    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]                       //不是好友的
-            'id' => ['BETWEEN',[368,382]]
-        ];
-
-        $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]                       //不是好友的
-            'id' => ['BETWEEN',[368,382]]
-        ];
-
-        $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]                        //不是好友的
-            'id' => ['BETWEEN',[368,382]]
-        ];
-
-        $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;
-    }