|
@@ -16,6 +16,7 @@ class Trainactive extends Api
|
|
|
protected $noNeedRight = ['test2'];
|
|
|
|
|
|
|
|
|
+ //获取培训详情
|
|
|
public function info()
|
|
|
{
|
|
|
$id = input('id');
|
|
@@ -24,23 +25,46 @@ class Trainactive extends Api
|
|
|
$this->success('', $info);
|
|
|
}
|
|
|
|
|
|
+ //签到成功
|
|
|
public function signin(){
|
|
|
$sign_image = input('sign_image','');
|
|
|
if(empty($sign_image)){
|
|
|
$this->error();
|
|
|
}
|
|
|
|
|
|
+ //
|
|
|
$id = input('id');
|
|
|
$info = Db::name('train_active')->where('id',$id)->find();
|
|
|
if(empty($info)){
|
|
|
$this->error('不存在的培训活动');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//判断
|
|
|
+ if($info['status'] != 1){
|
|
|
+ $this->error('该培训已下架');
|
|
|
+ }
|
|
|
+ if($info['userauth_status'] == 0 && $this->auth->idcard_status != 1){
|
|
|
+ $this->error('您未实名,不能签到该培训活动');
|
|
|
+ }
|
|
|
+ if(!in_array($this->auth->id,$info['user_ids'])){
|
|
|
+ $this->error('您不能签到该培训活动');
|
|
|
+ }
|
|
|
+
|
|
|
+ $map = [
|
|
|
+ 'train_id' => $id,
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ ];
|
|
|
+ $check = Db::name('user_train')->where($map)->find();
|
|
|
+ if($check){
|
|
|
+ $this->error('您已经签过到了');
|
|
|
+ }
|
|
|
|
|
|
//签到
|
|
|
$status = 1;
|
|
|
+ if(time() > $info['sign_endtime']){
|
|
|
+ $status = 0;//迟到
|
|
|
+ }
|
|
|
+
|
|
|
$data = [
|
|
|
'train_id' => $id,
|
|
|
'user_id' => $this->auth->id,
|
|
@@ -48,7 +72,6 @@ class Trainactive extends Api
|
|
|
'status' => $status,
|
|
|
'sign_image' => $this->auth->id,
|
|
|
];
|
|
|
-
|
|
|
Db::name('user_train')->insertGetId($data);
|
|
|
$this->success('签到成功');
|
|
|
}
|