作者 开飞机的舒克

接口重写

... ... @@ -194,9 +194,9 @@ class Index extends Api
}
$data = \db('study_score_log l')
->distinct('l.team_id')
->join('team t', 't.id = l.team_id')
->join('team t', 't.title = l.team')
->where('l.campus_id', $campus)
->field('t.title,t.score,l.team_id,l.campus_id')
->field('t.title,t.score,l.team,l.campus_id')
->order('t.score DESC')
->paginate($row, false, ['page' => $page])
->each(function ($item, $key) {
... ...
... ... @@ -37,14 +37,14 @@ class Screen extends Api
->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,campus_id')
->field('SUM(score) as sum_score,team,campus_id')
->where('campus_id',$data['campus_id'])
->group('team_id')
->group('team')
->order('sum_score DESC')
->paginate(4)
->each(function ($item,$key){
$res = db('study_score_log')->where('campus_id',$item['campus_id'])->sum('score');
$item['team_name'] = db('team')->where('id',$item['team_id'])->value('title');
$item['team_name'] = db('team')->where('title',$item['team'])->value('title');
$item['score'] = floor($item['sum_score']);
$item['percent'] = round(($item['score']*0.6) / $res * 100,2);
$item['study'] = db('study_score_log l')
... ... @@ -52,7 +52,7 @@ class Screen extends Api
->join('study s','l.study_id = s.id')
->where([
'l.campus_id'=>$item['campus_id'],
's.team_id'=>$item['team_id']
's.team'=>$item['team']
])
->field('s.name,sum(score) as sum_score')
->order('sum_score','desc')
... ...
此 diff 太大无法显示。