feat: 扫码签到功能
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 麦沃德科技赋能开发者,助力商协会发展
|
||||
// | 麦沃德科技赋能开发者,助力商协会发展
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2017~2024 www.wdsxh.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
@@ -516,6 +516,55 @@ class ActivityApply extends Api
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Desc 签到(单纯签到功能不涉核销)
|
||||
*
|
||||
* @param type $param
|
||||
* @return type
|
||||
* Created by jsasg
|
||||
*/
|
||||
public function checked_in()
|
||||
{
|
||||
if(!$this->request->isGet()) {
|
||||
$this->error('请求类型错误');
|
||||
}
|
||||
|
||||
if (!$this->auth->isLogin()) {
|
||||
$this->error('请先登录');
|
||||
}
|
||||
|
||||
// 活动id
|
||||
$id = $this->request->get('id');
|
||||
$activity = (new \app\api\model\wdsxh\activity\Activity())->where('id',$id)->find();
|
||||
if (empty($activity)) {
|
||||
$this->error('活动不存在');
|
||||
}
|
||||
if (3 == $activity['state'] || time() > $activity['end_time']) {
|
||||
$this->error('活动已结束');
|
||||
}
|
||||
|
||||
|
||||
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
|
||||
$activity_apply = $this->model->where('activity_id',$id)->where('wechat_id',$wechat_id)->find();
|
||||
// 如果用户未报名,不能签到
|
||||
if(empty($activity_apply)) {
|
||||
$this->error('您还未报名该活动');
|
||||
}
|
||||
// 如果已签到,不能再次签到
|
||||
if ('checked_in' == $activity_apply['check_in_status']) {
|
||||
$this->error('您已签到');
|
||||
}
|
||||
|
||||
// 设置已签到
|
||||
$activity_apply->check_in_status = 'checked_in';
|
||||
$activity_apply->checked_in_at = time();
|
||||
if ($activity_apply->save()) {
|
||||
$this->success('签到成功');
|
||||
}
|
||||
|
||||
$this->error('签到失败');
|
||||
}
|
||||
|
||||
private function handle_custom_data($data)
|
||||
{
|
||||
$custom_field = array('name','mobile');
|
||||
@@ -530,7 +579,3 @@ class ActivityApply extends Api
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user