|
@@ -5,6 +5,8 @@ namespace app\api\controller;
|
|
|
use app\common\controller\Api;
|
|
|
use think\Db;
|
|
|
use think\cache;
|
|
|
+use app\utils\RedisKeyEnum;
|
|
|
+use app\utils\RedisUtil;
|
|
|
/**
|
|
|
* 投票
|
|
|
*/
|
|
@@ -19,6 +21,7 @@ class Subject extends Api
|
|
|
public function info(){
|
|
|
|
|
|
$find = Db::name('vote_subject')->where('id',1)->find();
|
|
|
+ $find['image'] = localpath_to_netpath($find['image']);
|
|
|
if(!$find){
|
|
|
$this->error('没有进行中的投票活动');
|
|
|
}
|
|
@@ -56,6 +59,7 @@ class Subject extends Api
|
|
|
//以上两者都没有,按钮:投票
|
|
|
|
|
|
foreach($lists as $key => $val){
|
|
|
+ $val['video_file'] = localpath_to_netpath($val['video_file']);
|
|
|
|
|
|
$val['video_thumb'] = '';
|
|
|
if(!empty($val['video_file'])){
|
|
@@ -80,7 +84,7 @@ class Subject extends Api
|
|
|
}
|
|
|
|
|
|
$map = [
|
|
|
- 'player_id' => $player_id,
|
|
|
+ 'id' => $player_id,
|
|
|
];
|
|
|
|
|
|
$info = Db::name('vote_player')->where($map)->find();
|
|
@@ -91,6 +95,14 @@ class Subject extends Api
|
|
|
$info['video_thumb'] = $info['video_file'].'?x-oss-process=video/snapshot,t_0,m_fast,f_jpg';
|
|
|
}
|
|
|
|
|
|
+ //获取播放地址和秒数
|
|
|
+ $videoVod = new \app\common\library\Video();
|
|
|
+ $video_PlayInfo = $videoVod->getPlayInfo($info['vodid']);
|
|
|
+ $video_PlayInfo = $video_PlayInfo->PlayInfoList->PlayInfo;
|
|
|
+
|
|
|
+ $info['video_file'] = $video_PlayInfo[0]->PlayURL;
|
|
|
+ $info['video_seconds'] = ceil($video_PlayInfo[0]->Duration);
|
|
|
+
|
|
|
//名次
|
|
|
/*$players = Db::name('vote_player')->where(['subject_id'=>$info['subject_id'],'status'=>1])->order('votes desc,id desc')->column('id,votes');
|
|
|
$id_arr = array_keys($players);
|
|
@@ -113,12 +125,17 @@ class Subject extends Api
|
|
|
//今天,用户答对的次数,也就是答题获得的票数
|
|
|
$question_vote = RedisUtil::getInstance(RedisKeyEnum::EAXM_RIGHT.date('Y-m-d').':'.$this->auth->id)->get();
|
|
|
|
|
|
- //基础票数,答题票数
|
|
|
+ //基础票数
|
|
|
$jcps = $gift_votes - $today_record;
|
|
|
if($jcps < 0){
|
|
|
$jcps = 0;
|
|
|
}
|
|
|
+
|
|
|
+ //答题票数
|
|
|
$dtps = $question_vote - ( ($today_record - $gift_votes) <= 0 ? 0 : ($today_record - $gift_votes) );
|
|
|
+ if($dtps < 0){
|
|
|
+ $dtps = 0;
|
|
|
+ }
|
|
|
|
|
|
//今日投票记录
|
|
|
$player_ids = Db::name('vote_record')->where('user_id',$this->auth->id)->where('createdate',strtotime(date('Y-m-d')))->column('player_id');
|
|
@@ -129,7 +146,7 @@ class Subject extends Api
|
|
|
$lists = Db::name('vote_player')->field('id,title,votes')
|
|
|
->where($map)->order('votes desc,id desc')->select();
|
|
|
|
|
|
-
|
|
|
+ //
|
|
|
$result = [
|
|
|
'info' => $info,
|
|
|
'jcps' => $jcps,
|