作者 景琛

后台快速检索

... ... @@ -41,7 +41,9 @@ class StudyScoreLog extends Model
$list = [];
//判断当前项目是否在学生所属场次内
$item_ids = explode(',',$ronda['item_ids']);
if (in_array($id,$item_ids)){
if (!in_array($id,$item_ids)){
return null;
}
foreach ($score as $k) {
$sum_score += $k;
}
... ... @@ -56,9 +58,9 @@ class StudyScoreLog extends Model
Db::startTrans();
try {
//得分加入学生表中
$study->allowField(true)->save(['earn_score' => $stu['earn_score'] + $sum_score], ['id' => $stu['id']]);
$study->allowField(true)->save(['earn_score'=>$stu['earn_score'] + $sum_score],['id'=>$stu['id']]);
//得分加入战队表
$teams->allowField(true)->save(['score' => $team['score'] + $sum_score], ['id' => $team['id']]);
$teams->allowField(true)->save(['score'=>$team['score'] + $sum_score],['id'=>$team['id']]);
//得分写入学生分数记录
$data = [
'item_id' => $id,
... ... @@ -71,22 +73,22 @@ class StudyScoreLog extends Model
];
$this->allowField(true)->save($data);
//学生场次得分
$study_ronda = \db('study_ronda_score')->where(['sid' => $stu['id'], 'team_id' => $team['id'], 'ronda_id' => $ronda['id']])->find();
if (empty($study_ronda)) {
$study_ronda = \db('study_ronda_score')->where(['sid'=>$stu['id'],'team_id'=>$team['id'],'ronda_id'=>$ronda['id']])->find();
if (empty($study_ronda)){
\db('study_ronda_score')
->insert([
'sid' => $stu['id'],
'team_id' => $team['id'],
'ronda_id' => $ronda['id'],
'score' => $sum_score
'sid'=>$stu['id'],
'team_id'=>$team['id'],
'ronda_id'=>$ronda['id'],
'score'=>$sum_score
]);
} else {
}else{
\db('study_ronda_score')
->where([
'sid' => $stu['id'],
'team_id' => $team['id'],
'ronda_id' => $ronda['id']
])->update(['score' => ($study_ronda['score'] + $sum_score)]);
'sid'=>$stu['id'],
'team_id'=>$team['id'],
'ronda_id'=>$ronda['id']
])->update(['score'=>($study_ronda['score'] + $sum_score)]);
}
//学生得分存入item_study_score表中
$find = \db('item_study_score')
... ... @@ -115,19 +117,19 @@ class StudyScoreLog extends Model
])
->update(['score' => ($find['score'] + $sum_score)]);
}
//战队得分
$team_score = \db('team_score')->where(['ronda_id' => $ronda['id'], 'team_id' => $team['id']])->find();
if (empty($team_score)) {
//战队得分
$team_score = \db('team_score')->where(['ronda_id'=>$ronda['id'],'team_id'=>$team['id']])->find();
if (empty($team_score)){
\db('team_score')
->insert([
'ronda_id' => $ronda['id'],
'team_id' => $team['id'],
'score' => $sum_score
]);
} else {
->insert([
'ronda_id'=>$ronda['id'],
'team_id'=>$team['id'],
'score' =>$sum_score
]);
}else{
\db('team_score')
->where(['ronda_id' => $ronda['id'], 'team_id' => $team['id']])
->update(['score' => ($team_score['score'] + $sum_score)]);
->where(['ronda_id'=>$ronda['id'],'team_id'=>$team['id']])
->update(['score'=> ($team_score['score'] + $sum_score)]);
}
//学生维度得分
foreach ($list as $key => $value) {
... ... @@ -153,8 +155,6 @@ class StudyScoreLog extends Model
Db::rollback();
$e->getMessage();
}
}else{
return null;
}
}
}
\ No newline at end of file
... ...