...
|
...
|
@@ -39,14 +39,14 @@ class Bind extends Api |
|
|
if (empty($unique)) {
|
|
|
$this->error('参数错误', ['status' => 2]);
|
|
|
}
|
|
|
// $res = \db('study')->where('unique',$unique)->value('user_id');
|
|
|
// if (!empty($res)){
|
|
|
// $this->error('当前学生已经被绑定了');
|
|
|
// }
|
|
|
$res = \db('study')->where('unique',$unique)->value('user_id');
|
|
|
if (!empty($res)){
|
|
|
$this->error('当前学生已经被绑定了');
|
|
|
}
|
|
|
$is_bind = db('user')->where('id', $user['id'])->value('bind_study');
|
|
|
// if ($is_bind == 1) {
|
|
|
// $this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind);
|
|
|
// }
|
|
|
if ($is_bind == 1) {
|
|
|
$this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind);
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
db('study')
|
...
|
...
|
@@ -87,14 +87,14 @@ class Bind extends Api |
|
|
if (empty($unique)) {
|
|
|
$this->error('参数错误', ['status' => 2]);
|
|
|
}
|
|
|
// $res = \db('study')->where('unique',$unique)->value('user_id');
|
|
|
// if (!empty($res)){
|
|
|
// $this->error('当前学生已经被绑定了');
|
|
|
// }
|
|
|
$res = \db('study')->where('unique',$unique)->value('user_id');
|
|
|
if (!empty($res)){
|
|
|
$this->error('当前学生已经被绑定了');
|
|
|
}
|
|
|
$is_bind = db('user')->where('id', $user['id'])->value('bind_study');
|
|
|
// if ($is_bind == 1) {
|
|
|
// $this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind);
|
|
|
// }
|
|
|
if ($is_bind == 1) {
|
|
|
$this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind);
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
db('study')
|
...
|
...
|
@@ -229,38 +229,8 @@ class Bind extends Api |
|
|
if (empty($unique) && empty($id)) {
|
|
|
$this->error('参数错误', ['status' => 2]);
|
|
|
}
|
|
|
$study = db('study')->where('unique', $unique)->field('id,grade,name,team,earn_score')->find();
|
|
|
$item = db('item')->where('id', $id)->field('score,title,campus_id')->find();
|
|
|
$team = \db('team')->where('title', $study['team'])->field('title,score')->find();
|
|
|
$sum1 = $team['score'] + $item['score']; //合计战队总分
|
|
|
$sum2 = $study['earn_score'] + $item['score']; //合计个人总分
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
db('study_score_log')->insert([
|
|
|
'item_id' => $id,
|
|
|
'campus_id' => $item['campus_id'],
|
|
|
'study_id' => $study['id'],
|
|
|
'team' => $study['team'],
|
|
|
'score' => $item['score'],
|
|
|
'memo' => $study['name'] . '参加' . $item['title'] . '加分',
|
|
|
'createtime' => time()
|
|
|
]);
|
|
|
db('study')
|
|
|
->where('id', $study['id'])
|
|
|
->update([
|
|
|
'earn_score' => $sum2,
|
|
|
]);
|
|
|
\db('team')
|
|
|
->where('title', $study['team'])
|
|
|
->update([
|
|
|
'score' => $sum1,
|
|
|
'updatetime' => time()
|
|
|
]);
|
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error('连接错误', ['status' => 3]);
|
|
|
}
|
|
|
$model = new StudyScoreLog();
|
|
|
$model->addScore($id,$unique);
|
|
|
$data = db('study')->where('unique', $unique)->field('name,gender')->find();
|
|
|
if ($data['gender'] == 1){
|
|
|
$data['gender'] = '男';
|
...
|
...
|
|