|
@@ -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){
|
|
|
|