作者 开飞机的舒克

大屏数据

@@ -37,13 +37,13 @@ class Screen extends Api @@ -37,13 +37,13 @@ class Screen extends Api
37 ->value('title'); 37 ->value('title');
38 $list['time'] = date('Y-m-d H:i:s',time()); 38 $list['time'] = date('Y-m-d H:i:s',time());
39 $list['team_rank'] = \db('study_score_log') 39 $list['team_rank'] = \db('study_score_log')
40 - ->field('SUM(score) as sum_score,team,campus_id')  
41 - ->where('campus_id',$data['campus_id']) 40 + ->field('SUM(score) as sum_score,team,campus_ids')
  41 + ->whereIn('campus_ids',$data['campus_id'])
42 ->group('team') 42 ->group('team')
43 ->order('sum_score DESC') 43 ->order('sum_score DESC')
44 ->paginate(4) 44 ->paginate(4)
45 ->each(function ($item,$key){ 45 ->each(function ($item,$key){
46 - $res = db('study_score_log')->where('campus_id',$item['campus_id'])->sum('score'); 46 + $res = db('study_score_log')->whereIn('campus_ids',$item['campus_ids'])->sum('score');
47 $item['team_name'] = db('team')->where('title',$item['team'])->value('title'); 47 $item['team_name'] = db('team')->where('title',$item['team'])->value('title');
48 $item['team_score'] = db('team')->where('title',$item['team'])->value('score'); 48 $item['team_score'] = db('team')->where('title',$item['team'])->value('score');
49 $item['score'] = floor($item['sum_score']); 49 $item['score'] = floor($item['sum_score']);
@@ -51,10 +51,8 @@ class Screen extends Api @@ -51,10 +51,8 @@ class Screen extends Api
51 $item['study'] = db('study_score_log l') 51 $item['study'] = db('study_score_log l')
52 ->distinct('l.study_id') 52 ->distinct('l.study_id')
53 ->join('study s','l.study_id = s.id') 53 ->join('study s','l.study_id = s.id')
54 - ->where([  
55 - 'l.campus_id'=>$item['campus_id'],  
56 - 's.team'=>$item['team']  
57 - ]) 54 + ->whereIn('l.campus_ids',$item['campus_ids'])
  55 + ->where('s.team',$item['team'])
58 ->field('s.name,sum(score) as sum_score') 56 ->field('s.name,sum(score) as sum_score')
59 ->order('sum_score','desc') 57 ->order('sum_score','desc')
60 ->group('study_id') 58 ->group('study_id')