作者 开飞机的舒克

网页大屏优化

... ... @@ -31,34 +31,30 @@ class Screen extends Api
$data = db('screen')->find();
$list['images'] = cdnurl($data['images'],true);
$list['count_down'] = $data['endtime'];
$list['screen_name'] = $data['title'];
$list['campus_name'] = db('campus c')
->where('c.id',$data['campus_id'])
->value('title');
$list['screen_name'] = db('ronda')->where('id',$data['ronda_id'])->value('title');
$list['campus_name'] = $data['campus'];
$list['time'] = date('Y-m-d H:i:s',time());
$list['team_rank'] = \db('study_score_log')
->field('SUM(score) as sum_score,team,campus_ids')
->whereIn('campus_ids',$data['campus_id'])
->group('team')
->order('sum_score DESC')
->paginate(4)
->each(function ($item,$key){
$res = db('study_score_log')->whereIn('campus_ids',$item['campus_ids'])->sum('score');
$item['team_name'] = db('team')->where('title',$item['team'])->value('title');
$item['team_score'] = db('team')->where('title',$item['team'])->value('score');
$item['score'] = floor($item['sum_score']);
$item['percent'] = round(($item['score']*0.6) / $res * 100,2);
$item['study'] = db('study_score_log l')
->distinct('l.study_id')
->join('study s','l.study_id = s.id')
->whereIn('l.campus_ids',$item['campus_ids'])
->where('s.team',$item['team'])
->field('s.name,sum(score) as sum_score')
->order('sum_score','desc')
->group('study_id')
->select();
return $item;
});
$list['team_rank'] = \db('team_score')
->where('ronda_id',$data['ronda_id'])
->order('score DESC')
->paginate(4);
// ->each(function ($item,$key){
// $res = db('study_score_log')->whereIn('campus_ids',$item['campus_ids'])->sum('score');
// $item['team_name'] = db('team')->where('title',$item['team'])->value('title');
// $item['team_score'] = db('team')->where('title',$item['team'])->value('score');
// $item['score'] = floor($item['sum_score']);
// $item['percent'] = round(($item['score']*0.6) / $res * 100,2);
// $item['study'] = db('study_score_log l')
// ->distinct('l.study_id')
// ->join('study s','l.study_id = s.id')
// ->whereIn('l.campus_ids',$item['campus_ids'])
// ->where('s.team',$item['team'])
// ->field('s.name,sum(score) as sum_score')
// ->order('sum_score','desc')
// ->group('study_id')
// ->select();
// return $item;
// });
$this->success('获取成功',$list);
}
... ...