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

user表的active_time 作废

lizhen_gitee 6 місяців тому
батько
коміт
c1577b287b

+ 3 - 6
application/api/controller/Index.php

@@ -46,18 +46,15 @@ class Index extends Api
 //            '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],
         ];
 
         //排序
-        $order = 'user.is_active desc, user.active_time desc';
+        $order = 'user.is_active desc, user.logintime desc';
         if (in_array($type,[0,1])) {
             if ($this->auth->gender == 1) {
-                // $order = 'user.is_active desc, user.active_time desc, uw.get_money desc';
-                $order = 'user.is_active desc, user.active_time desc';
+                $order = 'user.is_active desc, user.logintime desc';
             } else {
-                // $order = 'user.is_active desc, user.active_time desc, uw.pay_money desc';
-                $order = 'user.is_active desc, user.active_time desc';
+                $order = 'user.is_active desc, user.logintime desc';
             }
         }
         if ($type == 0) {

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

@@ -1251,7 +1251,6 @@ class User extends Api
 
     //修改用户活跃1
     public function useractive(){
-        Db::name('user')->where('id',$this->auth->id)->update(['is_active' => 1,'active_time' => time()]);
         $this->success('success');
     }
 

+ 1 - 183
application/api/controller/Usercenter.php

@@ -314,188 +314,6 @@ class Usercenter extends Api
         return $result;
     }
 
-    //这里不用连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);
-
-    }
-
-    //因为接受者拿不到发起者的uid,废弃了
-    //视频和语音,接收方使用,如果是性别劣势方,检查钱是否够用
-    public function video_audio_moneycheck(){
-        //检测用户,发起方的uid
-        $to_user_id = input_post('from_user_id');
-        $to_user_info = Db::name('user')->field('id,real_status,gender')->where('id',$to_user_id)->find();
-        if(!$to_user_info){
-            $this->error('不存在的用户');
-        }
-
-        //扣费金币
-        $type = input_post('type','video');       //类型
-        $price = $type == 'video' ? config('site.video_min_price') : config('site.audio_min_price');
-
-        //发起用户的分数,被发起用户的分数。按性别给分
-        $auth_level = 0;
-        $tous_level = 0;
-
-        //打分
-        if($this->auth->gender == 0 && $this->auth->real_status == 1){
-            $auth_level = 30;//实名女最高
-        }
-        if($this->auth->gender == 0 && $this->auth->real_status != 1){
-            $auth_level = 20;//未实名女次之
-        }
-        if($this->auth->gender == 1){
-            $auth_level = 10;//男性最低
-        }
-        if($to_user_info['gender'] == 0 && $to_user_info['real_status'] == 1){
-            $tous_level = 30;
-        }
-        if($to_user_info['gender'] == 0 && $to_user_info['real_status'] != 1){
-            $tous_level = 20;
-        }
-        if($to_user_info['gender'] == 1){
-            $tous_level = 10;
-        }
-
-        //同性不收钱
-        //都是男的,不扣钱
-        //都是实名认证的女性,不扣钱
-        //都是未实名认证的女性,不扣钱
-        if($auth_level == $tous_level){
-            $price = 0;
-            $this->success('success');
-        }
-
-
-        //扣钱uid,收钱uid,收钱free_video
-        //分数少扣钱,分数多收益
-        if($auth_level < $tous_level){
-            $kou_user = $this->auth->id;
-        }else{
-            $kou_user = $to_user_info['id'];
-        }
-
-        //需要扣我的(接收方的)钱,判断钱是否够
-        if($price > 0 && $kou_user == $this->auth->id){
-            Db::startTrans();
-            $gold = model('wallet')->getWallet($kou_user,'gold');
-            if(bccomp($price,$gold) == 1){
-                Db::rollback();
-                $this->error('金币不足');
-            }
-            Db::commit();
-        }
-        $this->success('success');
-    }
-
 
     /**
      * 是否关注
@@ -1498,7 +1316,7 @@ $resArray['money'] = $money;  //返回给前端的计算结果
             $query = Db::name('user')
                 ->field('id,nickname,username,avatar')
                 ->where($map)
-                ->order('is_active desc, active_time desc');
+                ->order('is_active desc, logintime desc');
 
             if ($size == 1){
                 $query->limit(10);

+ 2 - 0
application/common/controller/Api.php

@@ -381,6 +381,7 @@ class Api
     protected function user_active(){
         if($this->auth->isLogin()){
             db('user_active')->where('user_id',$this->auth->id)->update(['requesttime'=>time()]);
+
             if($this->auth->is_active == 0){
                 $update['is_active'] = 1;
                 $update['cityname'] = $this->ip_to_address()['cityname'];
@@ -388,6 +389,7 @@ class Api
                 db('user')->where('id',$this->auth->id)->update($update);
 
                 $this->auth->setuser('cityname',$update['cityname']);
+                $this->auth->setuser('is_active',1);
             }
         }
     }

+ 0 - 4
application/common/library/Auth.php

@@ -196,10 +196,6 @@ class Auth
             $this->_logined = true;
             $this->_token = $token;
 
-            //记录用户访问时间
-            Db::name('user')->where(['id' => $user_id])->setField(['is_active' => 1,'active_time' => time()]);
-            Db::name('user_active')->where(['user_id' => $user_id])->setField('requesttime', time());
-
             //初始化成功的事件
             Hook::listen("user_init_successed", $this->_user);