lizhen_gitee 4 miesięcy temu
rodzic
commit
b35499dfc9

+ 0 - 181
application/api/controller/newvote/Player.php

@@ -12,65 +12,6 @@ class Player extends Api
     protected $noNeedLogin = [];
     protected $noNeedRight = ['*'];
 
-    //报名
-    public function join(){
-        $subject_info = Db::name('vote_subject')->where('status',1)->order('id desc')->find();
-        if(!$subject_info){
-            $this->error('没有投票正在进行');
-        }
-        $subject_id = $subject_info['id'];
-
-        $video_file = input('video_file','');
-        $mobile = input('mobile','');
-
-        if(!$video_file || !$mobile){
-            $this->error('视频、联系电话都不能为空');
-        }
-
-        //check
-        $map = [
-            'subject_id' => $subject_id,
-            'user_id'    => $this->auth->id,
-        ];
-        $check = Db::name('vote_player')->where($map)->find();
-        if($check){
-            $this->error('您已经报名了该投票');
-        }
-
-        $data = [
-            'subject_id' => $subject_id,
-            'user_id' => $this->auth->id,
-            'mobile' => $mobile,
-            'video_file' => $video_file,
-            'createtime' => time(),
-            'updatetime' => time(),
-            'status' => 0,
-        ];
-
-        $log_id = Db::name('vote_player')->insertGetId($data);
-
-        //邀请并参赛
-        if($this->auth->intro_uid){
-
-            //我得10票
-            $rs_vote = model('wallet')->lockChangeAccountRemain($this->auth->id,'votenum',10,25,$this->auth->intro_uid.'邀请我参赛得票');
-            if($rs_vote['status'] === false){
-                Db::rollback();
-                $this->error($rs_vote['msg']);
-            }
-
-            //我的上级得10票
-            $rs_vote = model('wallet')->lockChangeAccountRemain($this->auth->intro_uid,'votenum',10,24,'我邀请'.$this->auth->id.'参赛得票');
-            if($rs_vote['status'] === false){
-                Db::rollback();
-                $this->error($rs_vote['msg']);
-            }
-        }
-
-        $this->success('报名成功,请等待审核',$log_id);
-    }
-
-    //完全抛出vip等级问题,只要有票随便投
     //给选手投票
     public function record(){
         $player_id = input('player_id','');
@@ -151,129 +92,7 @@ class Player extends Api
         return $result;
     }
 
-    //投票大检查
-    private function record_check_old($uid,$player_id){
-        $result = array(
-            'status'=>false,
-            'msg'=>'',
-            'votes'=>0,
-            'renqi'=>0,
-        );
-
-        /*$result = array(
-            'status'=>true,
-            'msg'=>'',
-            'votes'=>1,
-            'renqi'=>0,
-        );
-        return $result;*/
-
-        //会员等级
-        $user_wallet = model('wallet')->getWallet($uid);
-        $vip_level = $user_wallet['vip_level'];
-        if($user_wallet['vip_endtime'] < time()){
-            $vip_level = 0;
-        }
-
-        $starttime = strtotime(date('Y-m-d'));
-        $endtime   = $starttime + 86399;
-
-        //投票配置
-        $vote_config = Db::name('vote_vip')->column('vip_level,votes,renqi');
-
-        if($vip_level == 0){
-            $vote_num   = $vote_config[0]['votes'];
-            $vote_renqi = $vote_config[0]['renqi'];
-            //注册用户每日可投3票,3票不可投票同一选手
-            $map = [
-                'user_id' => $uid,
-                'createtime' => ['BETWEEN',[$starttime,$endtime]],
-            ];
-            $todaycheck = Db::name('vote_record')->where($map)->count('id');
-            if($todaycheck >= $vote_num){
-                $result['msg'] = '普通用户每日只能投'.$vote_num.'票';
-                return $result;
-            }
 
-            //3票不可投票同一选手
-            $map = [
-                'user_id' => $uid,
-                'player_id' => $player_id,
-                'createtime' => ['BETWEEN',[$starttime,$endtime]],
-            ];
-            $todaycheck = Db::name('vote_record')->where($map)->find();
-            if($todaycheck){
-                $result['msg'] = '今天已经投过该选手一次了';
-                return $result;
-            }
-
-            $result['status'] = true;
-            $result['votes']  = 1;
-            $result['renqi']  = $vote_renqi;
-            return $result;
-        }
-        elseif($vip_level == 10){
-            $vote_num   = $vote_config[10]['votes'];
-            $vote_renqi = $vote_config[10]['renqi'];
-            //g1每日3票,可以给同一人,每票附加1人气
-            $map = [
-                'user_id' => $uid,
-                'createtime' => ['BETWEEN',[$starttime,$endtime]],
-            ];
-            $todaycheck = Db::name('vote_record')->where($map)->count('id');
-            if($todaycheck >= $vote_num){
-                $result['msg'] = 'VIPG1用户每日只能投'.$vote_num.'票';
-                return $result;
-            }
-
-            $result['status'] = true;
-            $result['votes']  = 1;
-            $result['renqi']  = $vote_renqi;
-            return $result;
-        }
-        elseif($vip_level == 20){
-            $vote_num   = $vote_config[20]['votes'];
-            $vote_renqi = $vote_config[20]['renqi'];
-            //g2每日3票,可以给同一人,每票附加5人气
-            $map = [
-                'user_id' => $uid,
-                'createtime' => ['BETWEEN',[$starttime,$endtime]],
-            ];
-            $todaycheck = Db::name('vote_record')->where($map)->count('id');
-            if($todaycheck >= $vote_num){
-                $result['msg'] = 'VIPG2用户每日只能投'.$vote_num.'票';
-                return $result;
-            }
-
-            $result['status'] = true;
-            $result['votes']  = 1;
-            $result['renqi']  = $vote_renqi;
-            return $result;
-        }
-        elseif($vip_level == 30){
-            $vote_num   = $vote_config[30]['votes'];
-            $vote_renqi = $vote_config[30]['renqi'];
-            //g3每日5票,可以给同一人,每票附加15人气
-            $map = [
-                'user_id' => $uid,
-                'createtime' => ['BETWEEN',[$starttime,$endtime]],
-            ];
-            $todaycheck = Db::name('vote_record')->where($map)->count('id');
-            if($todaycheck >= $vote_num){
-                $result['msg'] = 'VIPG3用户每日只能投'.$vote_num.'票';
-                return $result;
-            }
-
-            $result['status'] = true;
-            $result['votes']  = 1;
-            $result['renqi']  = $vote_renqi;
-            return $result;
-        }
-
-        //口袋错误
-        $result['msg'] = '错误的会员等级';
-        return $result;
-    }
 
 
 }

+ 13 - 119
application/api/controller/newvote/Subject.php

@@ -13,59 +13,16 @@ class Subject extends Api
     protected $noNeedLogin = ['*'];
     protected $noNeedRight = ['*'];
 
-    /*public function lists(){
-        $status = input('status','all');  //1未开始2进行中3结束
-        if(!in_array($status,[1,2,3,'all'])){
-            $this->error('状态错误');
-        }
-
-        $where = ['status'=>1];
-
-        if($status == 1){
-            $where['begintime'] = ['gt',time()];
-        }
-        if($status == 2){
-            $where['begintime'] = ['lt',time()];
-            $where['endtime'] = ['gt',time()];
-        }
-        if($status == 3){
-            $where['endtime'] = ['lt',time()];
-        }
 
-        $lists = Db::name('vote_subject')->field('id,title,image,zhandian,jubandanwei,begintime,endtime')->where($where)->order('id desc')->autopage()->select();
-        $lists = list_domain_image($lists,['image']);
-        foreach($lists as $key => &$item){
-            $status_text = '进行中';
-            $status = 2;
-
-            if(time() < $item['begintime']){
-                $status_text = '未开始';
-                $status = 1;
-            }
-            if(time() > $item['endtime']){
-                $status_text = '已结束';
-                $status = 3;
-            }
-
-            $item['status_text'] = $status_text;
-            $item['status_time'] = $status;
-        }
-
-        $this->success(1,$lists);
-    }*/
 
     //进行中的唯一一个投票活动
     public function info(){
-        /*$id = input('id');
-        if(!$id){
-            $this->error();
-        }*/
 
         $find = Db::name('vote_subject')->where('status',1)->order('id desc')->find();
         if(!$find){
             $this->error('没有进行中的投票活动');
         }
-        $find = info_domain_image($find,['video_file','banner_images']);
+        $find = info_domain_image($find,['video_file']);
 
         $this->success(1,$find);
     }
@@ -102,15 +59,7 @@ class Subject extends Api
         $this->success('分享链接', $rs['link']);
     }
 
-    //发现列表
-    public function playerlist_find(){
-        $lists = Db::name('user')
-            ->field('id,nickname,avatar')
-            ->orderRaw('rand()')->page(1,9)->select();
-        $lists = list_domain_image($lists,['avatar']);
 
-        $this->success(1,$lists);
-    }
     //排行榜列表
     public function playerlist_votes(){
         $subject_id = Db::name('vote_subject')->where('status',1)->order('id desc')->value('id');
@@ -119,19 +68,18 @@ class Subject extends Api
         }
 
         $map = [
-            'p.subject_id' => $subject_id,
-            'p.status' => 1,
+            'subject_id' => $subject_id,
+            'status' => 1,
         ];
+
         //搜索
-        $search = input('keyword','');
-        if($search){
-            $map['user.username|user.nickname'] = ['LIKE','%'.$search.'%'];
+        $keyword = input('keyword','');
+        if($keyword){
+            $map['title|suozaidanwei|tuijiangonghui'] = ['LIKE','%'.$keyword.'%'];
         }
 
-        $lists = Db::name('vote_player')->alias('p')
-            ->field('p.id,p.votes,p.user_id,user.nickname,user.avatar,user.bio')
-            ->join('user','p.user_id = user.id','left')
-            ->where($map)->order('p.votes desc,p.id desc')->autopage()->select();
+        $lists = Db::name('vote_player')
+            ->where($map)->order('votes desc,id desc')->autopage()->select();
         $lists = list_domain_image($lists,['avatar']);
 
         $lists = $this->mingci($subject_id,$lists);
@@ -139,36 +87,8 @@ class Subject extends Api
         $this->success(1,$lists);
     }
 
-    //人气榜列表
-    /*public function playerlist_renqi(){
-        $subject_id = input('subject_id');
-        $search = input('keyword','');
-        if(!$subject_id){
-            $this->error();
-        }
-
-        $map = [
-            'p.subject_id' => $subject_id,
-            'p.status' => 1,
-        ];
-        //搜索
-        if($search){
-            $map['user.username|user.nickname'] = ['LIKE','%'.$search.'%'];
-        }
-
-        $lists = Db::name('vote_player')->alias('p')
-            ->field('p.id,p.title,p.content,p.video_file,p.votes,p.renqi,user.nickname,user.avatar')
-            ->join('user','p.user_id = user.id','left')
-            ->where($map)->order('p.renqi desc,p.votes desc,p.id asc')->autopage()->select();
-        $lists = list_domain_image($lists,['video_file','avatar']);
-
-        $lists = $this->renqi($subject_id,$lists);
-
-        $this->success(1,$lists);
-    }*/
-
     //选手详情
-    /*public function playerinfo(){
+    public function playerinfo(){
         $player_id = input('player_id');
         if(!$player_id){
             $this->error();
@@ -179,14 +99,9 @@ class Subject extends Api
         ];
 
         $info = Db::name('vote_player')->alias('p')
-            ->field('p.id,p.mobile,p.video_file,p.votes,p.renqi,p.subject_id,
-            user.nickname,user.avatar,user.birthday,user.height,user.weight,user.role_id')
-            ->join('user','p.user_id = user.id','left')
+            ->field('p.id,p.mobile,p.video_file,p.votes,p.renqi,p.subject_id')
             ->where($map)->find();
-        $info = info_domain_image($info,['video_file','avatar']);
-
-        $info['role_text'] = Db::name('enum_role')->where('id',$info['role_id'])->value('name');
-        $info['age'] = birthtime_to_age($info['birthday']);
+        $info = info_domain_image($info,['video_file']);
 
         //名次
         $players = Db::name('vote_player')->where(['subject_id'=>$info['subject_id'],'status'=>1])->order('votes desc')->column('id,votes');
@@ -197,30 +112,9 @@ class Subject extends Api
         $info['mingci'] = $mingci;
 
         $this->success(1,$info);
-    }*/
-
-
-    //获得我的名次,人气导向
-    private function renqi($subject_id,$list){
-
-        if(empty($list)){
-            return $list;
-        }
-        //准备数据
-        $players = Db::name('vote_player')->where(['subject_id'=>$subject_id,'status'=>1])->order('renqi desc')->column('id,renqi');
-        $id_arr = array_keys($players);
-
-        foreach($list as $key => $val)
-        {
-            $mingci = 1;  //名次
-            $mingci = array_search($val['id'],$id_arr);
-            $mingci++;
-            $list[$key]['mingci'] = $mingci;
-        }
-
-        return $list;
     }
 
+
     //获得我的名次,票数导向
     private function mingci($subject_id,$list){