...
|
...
|
@@ -20,18 +20,18 @@ class Bind extends Api |
|
|
/**
|
|
|
* @ApiTitle (输入学号绑定信息)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiParams (name="xh", type="string", required=true, description="学号")
|
|
|
* @ApiParams (name="unique", type="string", required=true, description="手环id")
|
|
|
* @ApiReturn ({
|
|
|
"code":"状态码",
|
|
|
"msg": "提示消息",
|
|
|
"data": {}
|
|
|
})
|
|
|
*/
|
|
|
public function inputSno()
|
|
|
public function inputUnique()
|
|
|
{
|
|
|
$sno = $this->request->param('sno');
|
|
|
$unique = $this->request->param('unique');
|
|
|
$user = $this->auth->getUserinfo();
|
|
|
if (empty($sno)) {
|
|
|
if (empty($unique)) {
|
|
|
$this->error('参数错误', ['status' => 2]);
|
|
|
}
|
|
|
$is_bind = db('user')->where('id', $user['id'])->value('bind_study');
|
...
|
...
|
@@ -41,7 +41,7 @@ class Bind extends Api |
|
|
Db::startTrans();
|
|
|
try {
|
|
|
db('study')
|
|
|
->where('sno', $sno)
|
|
|
->where('unique', $unique)
|
|
|
->update([
|
|
|
'user_id' => $user['id'],
|
|
|
'updatetime' => time()
|
...
|
...
|
@@ -63,7 +63,7 @@ class Bind extends Api |
|
|
/**
|
|
|
* @ApiTitle (扫码绑定信息)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiParams (name="sno", type="string", required=true, description="学号")
|
|
|
* @ApiParams (name="unique", type="string", required=true, description="手环id[条形码编号]")
|
|
|
* @ApiReturn ({
|
|
|
"code":"状态码",
|
|
|
"msg": "提示消息",
|
...
|
...
|
@@ -72,9 +72,9 @@ class Bind extends Api |
|
|
*/
|
|
|
public function scanCode()
|
|
|
{
|
|
|
$sno = $this->request->param('sno');
|
|
|
$unique = $this->request->param('unique');
|
|
|
$user = $this->auth->getUserinfo();
|
|
|
if (empty($sno)) {
|
|
|
if (empty($unique)) {
|
|
|
$this->error('参数错误', ['status' => 2]);
|
|
|
}
|
|
|
$is_bind = db('user')->where('id', $user['id'])->value('bind_study');
|
...
|
...
|
@@ -84,7 +84,7 @@ class Bind extends Api |
|
|
Db::startTrans();
|
|
|
try {
|
|
|
db('study')
|
|
|
->where('sno', $sno)
|
|
|
->where('unique', $unique)
|
|
|
->update([
|
|
|
'user_id' => $user['id'],
|
|
|
'updatetime' => time()
|
...
|
...
|
@@ -100,7 +100,7 @@ class Bind extends Api |
|
|
Db::rollback();
|
|
|
$this->error('参数错误', $e->getMessage());
|
|
|
}
|
|
|
$data = db('study')->where('sno', $sno)->field('id,grade,name,sno')->find();
|
|
|
$data = db('study')->where('unique', $unique)->field('id,grade,name')->find();
|
|
|
$this->success('绑定成功', $data);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -145,7 +145,6 @@ class Bind extends Api |
|
|
"data": {
|
|
|
"name": "姓名",
|
|
|
"gender": "性别",
|
|
|
"sno": "学号"
|
|
|
}
|
|
|
})
|
|
|
*/
|
...
|
...
|
@@ -156,7 +155,7 @@ class Bind extends Api |
|
|
if (empty($unique) && empty($items_id)) {
|
|
|
$this->error('参数错误', ['status' => 2]);
|
|
|
}
|
|
|
$study = db('study')->where('unique', $unique)->field('id,grade_id,name,sno,team_id,earn_score')->find();
|
|
|
$study = db('study')->where('unique', $unique)->field('id,grade_id,name,team_id,earn_score')->find();
|
|
|
$item = db('item')->where('id', $items_id)->field('score,title,campus_id')->find();
|
|
|
$team = \db('team')->where('id', $study['team_id'])->field('title,score')->find();
|
|
|
$sum1 = $team['score'] + $item['score']; //合计战队总分
|
...
|
...
|
@@ -188,7 +187,7 @@ class Bind extends Api |
|
|
Db::rollback();
|
|
|
$this->error('连接错误', ['status' => 3]);
|
|
|
}
|
|
|
$data = db('study')->where('unique', $unique)->field('name,gender,sno')->find();
|
|
|
$data = db('study')->where('unique', $unique)->field('name,gender')->find();
|
|
|
$this->success('扫码成功', $data);
|
|
|
}
|
|
|
|
...
|
...
|
|