作者 景琛

后台快速检索

@@ -41,7 +41,9 @@ class StudyScoreLog extends Model @@ -41,7 +41,9 @@ class StudyScoreLog extends Model
41 $list = []; 41 $list = [];
42 //判断当前项目是否在学生所属场次内 42 //判断当前项目是否在学生所属场次内
43 $item_ids = explode(',',$ronda['item_ids']); 43 $item_ids = explode(',',$ronda['item_ids']);
44 - if (in_array($id,$item_ids)){ 44 + if (!in_array($id,$item_ids)){
  45 + return null;
  46 + }
45 foreach ($score as $k) { 47 foreach ($score as $k) {
46 $sum_score += $k; 48 $sum_score += $k;
47 } 49 }
@@ -56,9 +58,9 @@ class StudyScoreLog extends Model @@ -56,9 +58,9 @@ class StudyScoreLog extends Model
56 Db::startTrans(); 58 Db::startTrans();
57 try { 59 try {
58 //得分加入学生表中 60 //得分加入学生表中
59 - $study->allowField(true)->save(['earn_score' => $stu['earn_score'] + $sum_score], ['id' => $stu['id']]); 61 + $study->allowField(true)->save(['earn_score'=>$stu['earn_score'] + $sum_score],['id'=>$stu['id']]);
60 //得分加入战队表 62 //得分加入战队表
61 - $teams->allowField(true)->save(['score' => $team['score'] + $sum_score], ['id' => $team['id']]); 63 + $teams->allowField(true)->save(['score'=>$team['score'] + $sum_score],['id'=>$team['id']]);
62 //得分写入学生分数记录 64 //得分写入学生分数记录
63 $data = [ 65 $data = [
64 'item_id' => $id, 66 'item_id' => $id,
@@ -71,22 +73,22 @@ class StudyScoreLog extends Model @@ -71,22 +73,22 @@ class StudyScoreLog extends Model
71 ]; 73 ];
72 $this->allowField(true)->save($data); 74 $this->allowField(true)->save($data);
73 //学生场次得分 75 //学生场次得分
74 - $study_ronda = \db('study_ronda_score')->where(['sid' => $stu['id'], 'team_id' => $team['id'], 'ronda_id' => $ronda['id']])->find();  
75 - if (empty($study_ronda)) { 76 + $study_ronda = \db('study_ronda_score')->where(['sid'=>$stu['id'],'team_id'=>$team['id'],'ronda_id'=>$ronda['id']])->find();
  77 + if (empty($study_ronda)){
76 \db('study_ronda_score') 78 \db('study_ronda_score')
77 ->insert([ 79 ->insert([
78 - 'sid' => $stu['id'],  
79 - 'team_id' => $team['id'],  
80 - 'ronda_id' => $ronda['id'],  
81 - 'score' => $sum_score 80 + 'sid'=>$stu['id'],
  81 + 'team_id'=>$team['id'],
  82 + 'ronda_id'=>$ronda['id'],
  83 + 'score'=>$sum_score
82 ]); 84 ]);
83 - } else { 85 + }else{
84 \db('study_ronda_score') 86 \db('study_ronda_score')
85 ->where([ 87 ->where([
86 - 'sid' => $stu['id'],  
87 - 'team_id' => $team['id'],  
88 - 'ronda_id' => $ronda['id']  
89 - ])->update(['score' => ($study_ronda['score'] + $sum_score)]); 88 + 'sid'=>$stu['id'],
  89 + 'team_id'=>$team['id'],
  90 + 'ronda_id'=>$ronda['id']
  91 + ])->update(['score'=>($study_ronda['score'] + $sum_score)]);
90 } 92 }
91 //学生得分存入item_study_score表中 93 //学生得分存入item_study_score表中
92 $find = \db('item_study_score') 94 $find = \db('item_study_score')
@@ -115,19 +117,19 @@ class StudyScoreLog extends Model @@ -115,19 +117,19 @@ class StudyScoreLog extends Model
115 ]) 117 ])
116 ->update(['score' => ($find['score'] + $sum_score)]); 118 ->update(['score' => ($find['score'] + $sum_score)]);
117 } 119 }
118 - //战队得分  
119 - $team_score = \db('team_score')->where(['ronda_id' => $ronda['id'], 'team_id' => $team['id']])->find();  
120 - if (empty($team_score)) { 120 + //战队得分
  121 + $team_score = \db('team_score')->where(['ronda_id'=>$ronda['id'],'team_id'=>$team['id']])->find();
  122 + if (empty($team_score)){
121 \db('team_score') 123 \db('team_score')
122 - ->insert([  
123 - 'ronda_id' => $ronda['id'],  
124 - 'team_id' => $team['id'],  
125 - 'score' => $sum_score  
126 - ]);  
127 - } else { 124 + ->insert([
  125 + 'ronda_id'=>$ronda['id'],
  126 + 'team_id'=>$team['id'],
  127 + 'score' =>$sum_score
  128 + ]);
  129 + }else{
128 \db('team_score') 130 \db('team_score')
129 - ->where(['ronda_id' => $ronda['id'], 'team_id' => $team['id']])  
130 - ->update(['score' => ($team_score['score'] + $sum_score)]); 131 + ->where(['ronda_id'=>$ronda['id'],'team_id'=>$team['id']])
  132 + ->update(['score'=> ($team_score['score'] + $sum_score)]);
131 } 133 }
132 //学生维度得分 134 //学生维度得分
133 foreach ($list as $key => $value) { 135 foreach ($list as $key => $value) {
@@ -153,8 +155,6 @@ class StudyScoreLog extends Model @@ -153,8 +155,6 @@ class StudyScoreLog extends Model
153 Db::rollback(); 155 Db::rollback();
154 $e->getMessage(); 156 $e->getMessage();
155 } 157 }
156 - }else{  
157 - return null;  
158 - } 158 +
159 } 159 }
160 } 160 }