...
|
...
|
@@ -234,6 +234,68 @@ class Bind extends Api |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (活动现场[手动输入])
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiParams (name="id", type="string", required=true, description="项目id")
|
|
|
* @ApiParams (name="unique", type="string", required=true, description="条形码唯一标识")
|
|
|
* @ApiReturn ({
|
|
|
"code":"状态码",
|
|
|
"msg": "提示消息",
|
|
|
"data": {
|
|
|
"name": "姓名",
|
|
|
"gender": "性别",
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function inputBar()
|
|
|
{
|
|
|
$id = $this->request->param('id');
|
|
|
$unique = $this->request->param('unique');
|
|
|
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]);
|
|
|
}
|
|
|
$data = db('study')->where('unique', $unique)->field('name,gender')->find();
|
|
|
if ($data['gender'] == 1){
|
|
|
$data['gender'] = '男';
|
|
|
}else{
|
|
|
$data['gender'] = '女';
|
|
|
}
|
|
|
$this->success('扫码成功', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (绑定后获取头像昵称)
|
|
|
*/
|
|
|
public function study(){
|
...
|
...
|
|