正在显示
1 个修改的文件
包含
25 行增加
和
26 行删除
@@ -41,10 +41,7 @@ class StudyScoreLog extends Model | @@ -41,10 +41,7 @@ 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 | - $info = "扫码无效"; | ||
45 | - if (!in_array($id,$item_ids)){ | ||
46 | - return null; | ||
47 | - } | 44 | + if (in_array($id,$item_ids)){ |
48 | foreach ($score as $k) { | 45 | foreach ($score as $k) { |
49 | $sum_score += $k; | 46 | $sum_score += $k; |
50 | } | 47 | } |
@@ -59,9 +56,9 @@ class StudyScoreLog extends Model | @@ -59,9 +56,9 @@ class StudyScoreLog extends Model | ||
59 | Db::startTrans(); | 56 | Db::startTrans(); |
60 | try { | 57 | try { |
61 | //得分加入学生表中 | 58 | //得分加入学生表中 |
62 | - $study->allowField(true)->save(['earn_score'=>$stu['earn_score'] + $sum_score],['id'=>$stu['id']]); | 59 | + $study->allowField(true)->save(['earn_score' => $stu['earn_score'] + $sum_score], ['id' => $stu['id']]); |
63 | //得分加入战队表 | 60 | //得分加入战队表 |
64 | - $teams->allowField(true)->save(['score'=>$team['score'] + $sum_score],['id'=>$team['id']]); | 61 | + $teams->allowField(true)->save(['score' => $team['score'] + $sum_score], ['id' => $team['id']]); |
65 | //得分写入学生分数记录 | 62 | //得分写入学生分数记录 |
66 | $data = [ | 63 | $data = [ |
67 | 'item_id' => $id, | 64 | 'item_id' => $id, |
@@ -74,22 +71,22 @@ class StudyScoreLog extends Model | @@ -74,22 +71,22 @@ class StudyScoreLog extends Model | ||
74 | ]; | 71 | ]; |
75 | $this->allowField(true)->save($data); | 72 | $this->allowField(true)->save($data); |
76 | //学生场次得分 | 73 | //学生场次得分 |
77 | - $study_ronda = \db('study_ronda_score')->where(['sid'=>$stu['id'],'team_id'=>$team['id'],'ronda_id'=>$ronda['id']])->find(); | ||
78 | - if (empty($study_ronda)){ | 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)) { | ||
79 | \db('study_ronda_score') | 76 | \db('study_ronda_score') |
80 | ->insert([ | 77 | ->insert([ |
81 | - 'sid'=>$stu['id'], | ||
82 | - 'team_id'=>$team['id'], | ||
83 | - 'ronda_id'=>$ronda['id'], | ||
84 | - 'score'=>$sum_score | 78 | + 'sid' => $stu['id'], |
79 | + 'team_id' => $team['id'], | ||
80 | + 'ronda_id' => $ronda['id'], | ||
81 | + 'score' => $sum_score | ||
85 | ]); | 82 | ]); |
86 | - }else{ | 83 | + } else { |
87 | \db('study_ronda_score') | 84 | \db('study_ronda_score') |
88 | ->where([ | 85 | ->where([ |
89 | - 'sid'=>$stu['id'], | ||
90 | - 'team_id'=>$team['id'], | ||
91 | - 'ronda_id'=>$ronda['id'] | ||
92 | - ])->update(['score'=>($study_ronda['score'] + $sum_score)]); | 86 | + 'sid' => $stu['id'], |
87 | + 'team_id' => $team['id'], | ||
88 | + 'ronda_id' => $ronda['id'] | ||
89 | + ])->update(['score' => ($study_ronda['score'] + $sum_score)]); | ||
93 | } | 90 | } |
94 | //学生得分存入item_study_score表中 | 91 | //学生得分存入item_study_score表中 |
95 | $find = \db('item_study_score') | 92 | $find = \db('item_study_score') |
@@ -119,18 +116,18 @@ class StudyScoreLog extends Model | @@ -119,18 +116,18 @@ class StudyScoreLog extends Model | ||
119 | ->update(['score' => ($find['score'] + $sum_score)]); | 116 | ->update(['score' => ($find['score'] + $sum_score)]); |
120 | } | 117 | } |
121 | //战队得分 | 118 | //战队得分 |
122 | - $team_score = \db('team_score')->where(['ronda_id'=>$ronda['id'],'team_id'=>$team['id']])->find(); | ||
123 | - if (empty($team_score)){ | 119 | + $team_score = \db('team_score')->where(['ronda_id' => $ronda['id'], 'team_id' => $team['id']])->find(); |
120 | + if (empty($team_score)) { | ||
124 | \db('team_score') | 121 | \db('team_score') |
125 | ->insert([ | 122 | ->insert([ |
126 | - 'ronda_id'=>$ronda['id'], | ||
127 | - 'team_id'=>$team['id'], | ||
128 | - 'score' =>$sum_score | 123 | + 'ronda_id' => $ronda['id'], |
124 | + 'team_id' => $team['id'], | ||
125 | + 'score' => $sum_score | ||
129 | ]); | 126 | ]); |
130 | - }else{ | 127 | + } else { |
131 | \db('team_score') | 128 | \db('team_score') |
132 | - ->where(['ronda_id'=>$ronda['id'],'team_id'=>$team['id']]) | ||
133 | - ->update(['score'=> ($team_score['score'] + $sum_score)]); | 129 | + ->where(['ronda_id' => $ronda['id'], 'team_id' => $team['id']]) |
130 | + ->update(['score' => ($team_score['score'] + $sum_score)]); | ||
134 | } | 131 | } |
135 | //学生维度得分 | 132 | //学生维度得分 |
136 | foreach ($list as $key => $value) { | 133 | foreach ($list as $key => $value) { |
@@ -156,6 +153,8 @@ class StudyScoreLog extends Model | @@ -156,6 +153,8 @@ class StudyScoreLog extends Model | ||
156 | Db::rollback(); | 153 | Db::rollback(); |
157 | $e->getMessage(); | 154 | $e->getMessage(); |
158 | } | 155 | } |
159 | - | 156 | + }else{ |
157 | + return null; | ||
158 | + } | ||
160 | } | 159 | } |
161 | } | 160 | } |
-
请 注册 或 登录 后发表评论