Screen.php
2.3 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?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": [
"id": 大屏id,
"school_id": 校区id,
"images": 活动图片,
"starttime": 校区活动开始时间,
"endtime": 校区活动结束时间,
"is_view": 是否展示,
"createtime": 创建时间,
"updatetime": 更新时间,
"count_down": "倒计时",
"team": 战队排行{
"total": 24,
"per_page": 4,
"current_page": 1,
"last_page": 6,
"data": [
{
"title": "坦克战队",
"score": "13.00",
"team_id": 1,
"study": 战队个人排行{
"data": [{
"name": "李四",
"earn_score": "12.00"
},]
})
*/
public function index(){
$time = time();
$data = db('data_screen')->find();
$data['images'] = cdnurl($data['images'],true);
if ($data['starttime']<=$time || $data['endtime']>=$time){
$times = $data['endtime'] - $time;
$data['count_down'] = date('H:i:s',$times);
}
$res = db('campus c')
->join('school s','c.school_id = s.id')
->join('activity a','c.activity_id = a.id')
->where('c.id',$data['campus_id'])
->field('c.activity_id,c.school_id,c.date,s.title as school_name,a.title as activity_name')
->find();
$data['time'] = date('Y-m-d H:i:s',time());
$data['campus'] = $res['date'].$res['school_name'].$res['activity_name'];
$data['team_score'] = \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')
->paginate(4,false);
$data['study_score'] = 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')
->paginate(10);
$this->success('获取成功',[$data, 'status' => 1]);
}
}