Browse Source

视频匹配修改,语音匹配

lizhen_gitee 3 years ago
parent
commit
9e0a5484e2
1 changed files with 62 additions and 8 deletions
  1. 62 8
      application/api/controller/Usercenter.php

+ 62 - 8
application/api/controller/Usercenter.php

@@ -51,6 +51,8 @@ class Usercenter extends Api
     public function testredis(){
         //redis_set(1,125);
         dump(redis_get(1));
+        $a = cache('?mt_matching_uid_1','',['type'=>'Redis']);
+        dump($a);
     }
 
     public function test(){
@@ -227,7 +229,7 @@ class Usercenter extends Api
             'price' => 0,
         ];
 
-        $check = Db::name('user_video_log')->where($map)->find();
+        $check = Db::name('user_match_video_log')->where($map)->find();
 
         //设置价格
         $price = config('site.video_min_price');
@@ -244,7 +246,7 @@ class Usercenter extends Api
             'to_user_id' => $to_user_id,
         ];
 
-        $log_id = Db::name('user_video_log')->insertGetId($data);
+        $log_id = Db::name('user_match_video_log')->insertGetId($data);
         if(!$log_id){
             Db::rollback();
             $this->error('扣费失败');
@@ -252,7 +254,7 @@ class Usercenter extends Api
 
         //扣费
         if(!empty($check) && $log_id){
-            $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$price,11,'','user_video_log',$log_id);
+            $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$price,11,'','user_match_video_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();
                 $this->error($rs['msg']);
@@ -263,11 +265,61 @@ class Usercenter extends Api
         $this->success('success');
     }
 
+    //语音匹配
+    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,
+            'real_status' => 1,
+            'idcard_status' => 1,
+            //打开视频开关的
+            'open_match_video' => 1,
+            'id' => ['NOT IN',$my_follow]
+        ];*/
+        $map = [];
+
+        $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);
+        $this->success('success',$lists);
+    }
+
     //视频匹配
     public function getvideouser(){
 
         //判断资格
-        /*$start = strtotime(date('Y-m-d'));
+        $start = strtotime(date('Y-m-d'));
         $end   = $start + 86399;
 
         $map = [
@@ -276,8 +328,8 @@ class Usercenter extends Api
             'price' => 0,
         ];
 
-        $check = Db::name('user_video_log')->where($map)->find();*/
-        $check = true;
+        $check = Db::name('user_match_video_log')->where($map)->find();
+        //$check = true;
 
         //已经用掉免费的了,判断金额
         if($check){
@@ -297,7 +349,7 @@ class Usercenter extends Api
 
 
         //给出备选用户
-        $map = [
+        /*$map = [
             'status' =>1,
             'gender' => $this->auth->gender == 1 ? 0 : 1,
             'real_status' => 1,
@@ -305,13 +357,15 @@ class Usercenter extends Api
             //打开视频开关的
             'open_match_video' => 1,
             'id' => ['NOT IN',$my_follow]
-        ];
+        ];*/
+        $map = [];
 
         $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);
         $this->success('success',$lists);
     }
 
+    //过滤规则
     private function fliter_user($lists){
 
         if(empty($lists)){