Screen.php
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace app\api\controller;
use app\common\controller\Api;
/**
* 数据大屏
* @ApiWeigh (95)
*/
class Screen extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* @ApiTitle (大屏管理)
* @ApiMethod (POST)
* @ApiReturn ({"code":状态码,
"msg":"提示信息"
"time": "时间戳",
"data": "大屏图片",
"time": "当前时间",
"campus": "活动名称",
"team_rank": 战队排行[从高到底排],
"study_rank": 个人排行[每个战队中从高到低排]
}
*/
public function index(){
$time = time();
$list = [];
$data = db('screen')->find();
$list['images'] = cdnurl($data['images'],true);
if ($data['starttime']<=$time && $data['endtime']>=$time){
$day = intval(($data['endtime']-$time)/86400);
$hour = intval((($data['endtime']-$time)%86400)/3600);
$minute = intval(((($data['endtime']-$time)%86400)%3600)/60);
$second = intval(((($data['endtime']-$time)%86400)%3600)%60);
$list['count_down'] = "距离活动结束还有".$day."天".$hour."时".$minute."分".$second."秒";
}else if ($data['endtime']<=$time){
$list['count_down'] = "距离活动结束还有00天00时00分00秒";
}
$list['screen_name'] = $data['title'];
$list['campus_name'] = db('campus c')
->where('c.id',$data['campus_id'])
->value('title');
$list['time'] = date('Y-m-d H:i:s',time());
$list['team_rank'] = \db('study_score_log')
->field('SUM(score) as sum_score,team_id')
->where('campus_id',$data['campus_id'])
->group('team_id')
->order('sum_score DESC')
->limit(4)
->select();
$list['study_rank'] = db('study_score_log')
->field('study_id,SUM(score) as sum_score,team_id')
->where('campus_id',$data['campus_id'])
->order('sum_score DESC')
->group('study_id')
->limit('0,10')
->select();
$this->success('获取成功',$list);
}
}