|
@@ -14,7 +14,7 @@ class Player extends Api
|
|
|
protected $noNeedLogin = ['playerlist'];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
- //选手列表
|
|
|
+ //待绑定选手列表
|
|
|
public function playerlist(){
|
|
|
$subject_id = 1;
|
|
|
|
|
@@ -54,7 +54,6 @@ class Player extends Api
|
|
|
if(!$this->apiLimit('操作太快了,休息一下吧'));
|
|
|
|
|
|
$player_id = input('player_id','');
|
|
|
-
|
|
|
if(!$player_id){
|
|
|
$this->error();
|
|
|
}
|
|
@@ -68,18 +67,16 @@ class Player extends Api
|
|
|
Db::startTrans();
|
|
|
|
|
|
//检查选手
|
|
|
- $player_info = Db::name('vote_player')->field('id,subject_id,votes,score')->where(['id'=>$player_id,'status'=>1])->lock(true)->find();
|
|
|
+ $player_info = Db::name('vote_player')->field('id,subject_id,votes')->where(['id'=>$player_id])->lock(true)->find();
|
|
|
if(!$player_info){
|
|
|
Db::rollback();
|
|
|
$this->error('不存在的选手');
|
|
|
}
|
|
|
- $subject_id = $player_info['subject_id'];
|
|
|
-
|
|
|
|
|
|
+ //给选手加票
|
|
|
$update_data = [
|
|
|
'votes' => $player_info['votes'] + 1,
|
|
|
];
|
|
|
- //入库
|
|
|
$update_rs = Db::name('vote_player')->where('id',$player_id)->update($update_data);
|
|
|
if($update_rs === false){
|
|
|
Db::rollback();
|
|
@@ -89,7 +86,7 @@ class Player extends Api
|
|
|
//日志
|
|
|
$data = [
|
|
|
'user_id' => $this->auth->id,
|
|
|
- 'subject_id' => $subject_id,
|
|
|
+ 'subject_id' => $player_info['subject_id'],
|
|
|
'player_id' => $player_id,
|
|
|
'createdate' => strtotime(date('Y-m-d')),
|
|
|
'createtime' => time(),
|