...
|
...
|
@@ -27,23 +27,36 @@ class Bind extends Api |
|
|
"data": {}
|
|
|
})
|
|
|
*/
|
|
|
public function inputSno()
|
|
|
public function inputSno()
|
|
|
{
|
|
|
$sno = $this->request->param('sno');
|
|
|
$user = $this->auth->getUserinfo();
|
|
|
if (empty($sno)){
|
|
|
$this->error('参数错误',['status'=>2]);
|
|
|
if (empty($sno)) {
|
|
|
$this->error('参数错误', ['status' => 2]);
|
|
|
}
|
|
|
$data = db('study')->where('sno',$sno)->value('user_id');
|
|
|
if ($data){
|
|
|
$this->error('您当前已经绑定过学生了,请勿重复操作',$data);
|
|
|
}
|
|
|
$is_bind = db('user')->where('id', $user['id'])->value('bind_study');
|
|
|
if ($is_bind == 1) {
|
|
|
$this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind);
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
db('study')
|
|
|
->where('sno',$sno)
|
|
|
->where('sno', $sno)
|
|
|
->update([
|
|
|
'user_id'=>$user['id'],
|
|
|
'updatetime'=>time()
|
|
|
'user_id' => $user['id'],
|
|
|
'updatetime' => time()
|
|
|
]);
|
|
|
\db('user')
|
|
|
->where('id', $user['id'])
|
|
|
->update([
|
|
|
'bind_study' => 1,
|
|
|
'updatetime' => time()
|
|
|
]);
|
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error('参数错误', $e->getMessage());
|
|
|
}
|
|
|
$this->success('绑定成功');
|
|
|
}
|
|
|
|
...
|
...
|
@@ -61,17 +74,34 @@ class Bind extends Api |
|
|
{
|
|
|
$unique = $this->request->param('unique');
|
|
|
$user = $this->auth->getUserinfo();
|
|
|
if (empty($unique)){
|
|
|
$this->error('参数错误',['status'=>2]);
|
|
|
if (empty($unique)) {
|
|
|
$this->error('参数错误', ['status' => 2]);
|
|
|
}
|
|
|
db('study')
|
|
|
->where('unique',$unique)
|
|
|
->update([
|
|
|
'user_id'=>$user['id'],
|
|
|
'updatetime'=>time()
|
|
|
]);
|
|
|
$data = db('study')->where('unique',$unique)->field('id,grade,name,sno')->find();
|
|
|
$this->success('绑定成功',[$data, 'status' => 1]);
|
|
|
$is_bind = db('user')->where('id', $user['id'])->value('bind_study');
|
|
|
if ($is_bind == 1) {
|
|
|
$this->error('您当前已经绑定过学生了,请勿重复操作', $is_bind);
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
db('study')
|
|
|
->where('unique', $unique)
|
|
|
->update([
|
|
|
'user_id' => $user['id'],
|
|
|
'updatetime' => time()
|
|
|
]);
|
|
|
\db('user')
|
|
|
->where('id', $user['id'])
|
|
|
->update([
|
|
|
'bind_study' => 1,
|
|
|
'updatetime' => time()
|
|
|
]);
|
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error('参数错误', $e->getMessage());
|
|
|
}
|
|
|
$data = db('study')->where('unique', $unique)->field('id,grade,name,sno')->find();
|
|
|
$this->success('绑定成功', [$data, 'status' => 1]);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -92,15 +122,16 @@ class Bind extends Api |
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function teachItem(){
|
|
|
public function teachItem()
|
|
|
{
|
|
|
$user = $this->auth->getUserinfo();
|
|
|
$data = db('item')
|
|
|
->where('user_id',$user['id'])
|
|
|
->where('user_id', $user['id'])
|
|
|
->select();
|
|
|
if (empty($data)){
|
|
|
$this->error('当前还未关联项目',['status'=>2]);
|
|
|
if (empty($data)) {
|
|
|
$this->error('当前还未关联项目', ['status' => 2]);
|
|
|
}
|
|
|
$this->success('获取项目成功',[$data, 'status' => 1]);
|
|
|
$this->success('获取项目成功', [$data, 'status' => 1]);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -115,31 +146,32 @@ class Bind extends Api |
|
|
"name": "姓名",
|
|
|
"gender": "性别",
|
|
|
"sno": "学号"
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function Ewm(){
|
|
|
public function Ewm()
|
|
|
{
|
|
|
$items_id = $this->request->param('items_id');
|
|
|
$unique = $this->request->param('unique');
|
|
|
if (empty($unique) && empty($items_id)){
|
|
|
$this->error('参数错误',['status'=>2]);
|
|
|
if (empty($unique) && empty($items_id)) {
|
|
|
$this->error('参数错误', ['status' => 2]);
|
|
|
}
|
|
|
$study = db('study')->where('unique',$unique)->field('id,grade,name,sno,team_id,earn_score')->find();
|
|
|
$rel = \db('item_ronda_rel')->where('item_id',$items_id)->find();
|
|
|
$item = db('item')->where('id',$rel['item_id'])->field('score,title')->find();
|
|
|
$team = \db('team')->where('id',$study['team_id'])->field('title,score')->find();
|
|
|
$study = db('study')->where('unique', $unique)->field('id,grade,name,sno,team_id,earn_score')->find();
|
|
|
$rel = \db('item_ronda_rel')->where('item_id', $items_id)->find();
|
|
|
$item = db('item')->where('id', $rel['item_id'])->field('score,title')->find();
|
|
|
$team = \db('team')->where('id', $study['team_id'])->field('title,score')->find();
|
|
|
$sum1 = $team['score'] + $item['score']; //合计战队总分
|
|
|
$sum2 = $study['earn_score'] + $item['score']; //合计个人总分
|
|
|
$sum2 = $study['earn_score'] + $item['score']; //合计个人总分
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
db('study_score_log')->insert([
|
|
|
'item_id'=>$items_id,
|
|
|
'campus_id'=>$rel['campus_id'],
|
|
|
'study_id'=>$study['id'],
|
|
|
'team_id'=>$study['team_id'],
|
|
|
'score'=>$item['score'],
|
|
|
'memo'=>$study['name'].'参加'.$item['title'].'项目给'.$team['title'].'加分',
|
|
|
'createtime'=>time()
|
|
|
'item_id' => $items_id,
|
|
|
'campus_id' => $rel['campus_id'],
|
|
|
'study_id' => $study['id'],
|
|
|
'team_id' => $study['team_id'],
|
|
|
'score' => $item['score'],
|
|
|
'memo' => $study['name'] . '参加' . $item['title'] . '项目给' . $team['title'] . '加分',
|
|
|
'createtime' => time()
|
|
|
]);
|
|
|
db('study')
|
|
|
->where('id', $study['id'])
|
...
|
...
|
@@ -147,18 +179,18 @@ class Bind extends Api |
|
|
'earn_score' => $sum2,
|
|
|
]);
|
|
|
\db('team')
|
|
|
->where('id',$study['team_id'])
|
|
|
->where('id', $study['team_id'])
|
|
|
->update([
|
|
|
'score' => $sum1,
|
|
|
'updatetime'=>time()
|
|
|
'updatetime' => time()
|
|
|
]);
|
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error('连接错误',['status' => 3]);
|
|
|
$this->error('连接错误', ['status' => 3]);
|
|
|
}
|
|
|
$data = db('study')->where('unique',$unique)->field('name,gender,sno')->find();
|
|
|
$this->success('扫码成功',[$data, 'status' => 1]);
|
|
|
$data = db('study')->where('unique', $unique)->field('name,gender,sno')->find();
|
|
|
$this->success('扫码成功', [$data, 'status' => 1]);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -192,28 +224,29 @@ class Bind extends Api |
|
|
},}
|
|
|
})
|
|
|
*/
|
|
|
public function getScore(){
|
|
|
public function getScore()
|
|
|
{
|
|
|
$user = $this->auth->getUserinfo();
|
|
|
$campus_id = $this->request->param('campus_id');
|
|
|
$sid = \db('study')->where('user_id',$user['id'])->value('id');
|
|
|
$sid = \db('study')->where('user_id', $user['id'])->value('id');
|
|
|
//获取学生的信息
|
|
|
$data['study_info'] = \db('study')->where('id',$sid)->field('avatar,name,earn_score')->find();
|
|
|
$data['study_info'] = \db('study')->where('id', $sid)->field('avatar,name,earn_score')->find();
|
|
|
//获取雷达维度
|
|
|
$data['study_score'] = \db('study_score_log')
|
|
|
->distinct('item_id')
|
|
|
->field('item_id,SUM(score) as sum_score')
|
|
|
->group('item_id')
|
|
|
->where(['campus_id'=>$campus_id,'study_id'=>$sid])
|
|
|
->paginate(3,false)
|
|
|
->each(function ($item,$key){
|
|
|
->where(['campus_id' => $campus_id, 'study_id' => $sid])
|
|
|
->paginate(3, false)
|
|
|
->each(function ($item, $key) {
|
|
|
$item['item_radar'] = \db('item i')
|
|
|
->join('radar r','i.radar_id = r.id')
|
|
|
->where('i.id',$item['item_id'])
|
|
|
->field('i.radar_id,r.title')
|
|
|
->select();
|
|
|
->join('radar r', 'i.radar_id = r.id')
|
|
|
->where('i.id', $item['item_id'])
|
|
|
->field('i.radar_id,r.title')
|
|
|
->select();
|
|
|
return $item;
|
|
|
});
|
|
|
$this->success('获取学生信息成功',[$data, 'status' => 1]);
|
|
|
$this->success('获取学生信息成功', [$data, 'status' => 1]);
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|