feat: 扫码签到功能
This commit is contained in:
@@ -53,6 +53,7 @@ return [
|
|||||||
'Verification_method 1' => '自助签到(范围1000米)',
|
'Verification_method 1' => '自助签到(范围1000米)',
|
||||||
'Verification_method 2' => '管理员核销',
|
'Verification_method 2' => '管理员核销',
|
||||||
'Applet_activity_qrcode_path' => '活动小程序码',
|
'Applet_activity_qrcode_path' => '活动小程序码',
|
||||||
|
'Checked_in_qrcode' => '签到二维码',
|
||||||
'Points_status' => '设置是否获得积分',
|
'Points_status' => '设置是否获得积分',
|
||||||
'Points_status 1' => '是',
|
'Points_status 1' => '是',
|
||||||
'Points_status 2' => '否',
|
'Points_status 2' => '否',
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ return [
|
|||||||
'State 3' => '退款中',
|
'State 3' => '退款中',
|
||||||
'State 4' => '已退款',
|
'State 4' => '已退款',
|
||||||
'State 5' => '已驳回',
|
'State 5' => '已驳回',
|
||||||
|
'check_in_status' => '签到状态',
|
||||||
|
'checked_in' => '已签到',
|
||||||
|
'unchecked_in' => '未签到',
|
||||||
'Is_sign_in' => '核销状态',
|
'Is_sign_in' => '核销状态',
|
||||||
'Is_sign_in 1' => '已核销',
|
'Is_sign_in 1' => '已核销',
|
||||||
'Is_sign_in 2' => '未核销',
|
'Is_sign_in 2' => '未核销',
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ class Activity extends Model
|
|||||||
'state_text',
|
'state_text',
|
||||||
'is_verifying_text',
|
'is_verifying_text',
|
||||||
'status_text',
|
'status_text',
|
||||||
'applet_activity_qrcode_path'
|
'applet_activity_qrcode_path',
|
||||||
|
'checked_in_qrcode'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@@ -186,6 +187,7 @@ class Activity extends Model
|
|||||||
$response = $app->app_code->getUnlimit($ids, [
|
$response = $app->app_code->getUnlimit($ids, [
|
||||||
'page' => $path,
|
'page' => $path,
|
||||||
'check_path' => false,
|
'check_path' => false,
|
||||||
|
'env_version' => 'develop',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
|
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
|
||||||
@@ -202,6 +204,48 @@ class Activity extends Model
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCheckedInQrcodeAttr($value, $data)
|
||||||
|
{
|
||||||
|
$row = $data;
|
||||||
|
$row['createtime'] = self::where('id',$row['id'])->value('createtime');
|
||||||
|
$save_path = '/uploads/wdsxh/check_in_qrcode/'.$row['id'].'/'.$row['createtime'].'.png';
|
||||||
|
if (is_file(ROOT_PATH."public".$save_path)) {
|
||||||
|
$value = $save_path;
|
||||||
|
} else {
|
||||||
|
if(isset($row['id'])) {
|
||||||
|
$configObj = (new \app\admin\model\wdsxh\Config())->where('id',1)->find();
|
||||||
|
if (!empty($configObj['applet_appid']) && !empty($configObj['applet_secret'])) {
|
||||||
|
$path = 'pagesActivity/index/details';
|
||||||
|
$config = [
|
||||||
|
'app_id' => $configObj['applet_appid'],
|
||||||
|
'secret' => $configObj['applet_secret'],
|
||||||
|
'response_type' => 'array',
|
||||||
|
'log' => [
|
||||||
|
'level' => 'debug',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$app = Factory::miniProgram($config);
|
||||||
|
$scene = http_build_query(['id' => $row['id'], 'op' => 'checked_in']);
|
||||||
|
$response = $app->app_code->getUnlimit($scene, [
|
||||||
|
'page' => $path,
|
||||||
|
'check_path' => false,
|
||||||
|
'env_version' => 'develop',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
|
||||||
|
$response->saveAs('uploads/wdsxh/check_in_qrcode/'.$row['id'], $row['createtime'].'.png');
|
||||||
|
$value = $save_path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($value)) {
|
||||||
|
$value = request()->domain().$value;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
public function getPointsStatusList()
|
public function getPointsStatusList()
|
||||||
{
|
{
|
||||||
return ['2' => __('Points_status 2'), '1' => __('Points_status 1')];
|
return ['2' => __('Points_status 2'), '1' => __('Points_status 1')];
|
||||||
@@ -216,6 +260,4 @@ class Activity extends Model
|
|||||||
{
|
{
|
||||||
return ['1' => __('启用单独证书'), '2' => __('使用统一证书')];
|
return ['1' => __('启用单独证书'), '2' => __('使用统一证书')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,6 @@
|
|||||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('wdsxh/activity/activity_apply/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('wdsxh/activity/activity_apply/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||||
<!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('wdsxh/activity/activity_apply/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
|
<!-- <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('wdsxh/activity/activity_apply/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||||
data-operate-edit="{:$auth->check('wdsxh/activity/activity_apply/edit')}"
|
data-operate-edit="{:$auth->check('wdsxh/activity/activity_apply/edit')}"
|
||||||
|
|||||||
@@ -97,20 +97,31 @@ class Activity extends Api
|
|||||||
$id = $this->request->get('id');
|
$id = $this->request->get('id');
|
||||||
$data = $this->model
|
$data = $this->model
|
||||||
->where('id',$id)
|
->where('id',$id)
|
||||||
->field('id,images,start_time,end_time,name,fees,state activity_state,
|
->field([
|
||||||
contacts,mobile,
|
'id', 'images', 'start_time', 'end_time', 'name', 'fees',
|
||||||
organizing_method,url,address,longitude,latitude,content,
|
'state' => 'activity_state', 'contacts', 'mobile',
|
||||||
is_verifying,refund,
|
'organizing_method', 'url', 'address', 'longitude',
|
||||||
apply_time,
|
'latitude', 'content', 'is_verifying', 'refund',
|
||||||
activity_auth,
|
'apply_time', 'activity_auth', 'points_status', 'points',
|
||||||
points_status,points,
|
'apply_field_state', 'apply_limit_number', 'non_member_registration_status'
|
||||||
apply_field_state,
|
])
|
||||||
apply_limit_number,
|
|
||||||
non_member_registration_status')
|
|
||||||
->find();
|
->find();
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
$this->error('活动不存在');
|
$this->error('活动不存在');
|
||||||
}
|
}
|
||||||
|
if ($data['activity_state'] < 3) {
|
||||||
|
$now = time();
|
||||||
|
// 如果活动未结束,则根据当前时间校验活动状态并更新状态
|
||||||
|
if ($now >= $data['start_time'] && $now <= $data['end_time']) {
|
||||||
|
$data->state = $data['activity_state'] = 2;
|
||||||
|
$data->save();
|
||||||
|
}
|
||||||
|
if ($now > $data['end_time']) {
|
||||||
|
$data->state = $data['activity_state'] = 3;
|
||||||
|
$data->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->auth->isLogin()) {
|
if ($this->auth->isLogin()) {
|
||||||
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
|
$wechat_id = (new UserWechat())->where('user_id',$this->auth->id)->value('id');
|
||||||
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
|
$activityApplyObj = (new \app\api\model\wdsxh\activity\ActivityApply())
|
||||||
@@ -123,6 +134,7 @@ class Activity extends Api
|
|||||||
$data['apply_id'] = '';
|
$data['apply_id'] = '';
|
||||||
$data['reject'] = '';
|
$data['reject'] = '';
|
||||||
} else {
|
} else {
|
||||||
|
$data['check_in_status'] = $activityApplyObj['check_in_status'];
|
||||||
$data['pay_state'] = $activityApplyObj['state'];
|
$data['pay_state'] = $activityApplyObj['state'];
|
||||||
$data['apply_id'] = $activityApplyObj['id'];
|
$data['apply_id'] = $activityApplyObj['id'];
|
||||||
$activityRefundObj = (new Refund())
|
$activityRefundObj = (new Refund())
|
||||||
@@ -490,7 +502,3 @@ class Activity extends Api
|
|||||||
$this->success('请求成功',['show_status'=>$is_status]);
|
$this->success('请求成功',['show_status'=>$is_status]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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)
|
private function handle_custom_data($data)
|
||||||
{
|
{
|
||||||
$custom_field = array('name','mobile');
|
$custom_field = array('name','mobile');
|
||||||
@@ -530,7 +579,3 @@ class ActivityApply extends Api
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -32,6 +32,34 @@ class Activity extends Base
|
|||||||
protected $updateTime = false;
|
protected $updateTime = false;
|
||||||
protected $deleteTime = false;
|
protected $deleteTime = false;
|
||||||
|
|
||||||
|
protected $append = [
|
||||||
|
'actitity_state_trans'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getActitityStateTransAttr($value, $data)
|
||||||
|
{
|
||||||
|
if ($data['activity_state'] < 3) {
|
||||||
|
$now = time();
|
||||||
|
// 如果活动未结束,则根据当前时间校验活动状态并更新状态
|
||||||
|
// 当前时间小于报名截止时间,状态流转处于:报名中
|
||||||
|
if ($now < $data['apply_time']) $value = 1;
|
||||||
|
// 当前时间大于等于报名截止时间小于开始时间,状态流转处于:未开始
|
||||||
|
if ($now >= $data['apply_time'] && $now < $data['start_time']) $value = 2;
|
||||||
|
// 当前时间大于等于开始时间小于等于结束时间,状态流转处于:进行中
|
||||||
|
if ($now >= $data['start_time'] && $now <= $data['end_time']) {
|
||||||
|
$value = 3;
|
||||||
|
}
|
||||||
|
// 当前时间大于结束时间,状态流转处于:已结束
|
||||||
|
if ($now > $data['end_time']) {
|
||||||
|
$value = 4;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 活动结束,状态流转就一直处理:已结束
|
||||||
|
$value = 4;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
protected static function init()
|
protected static function init()
|
||||||
{
|
{
|
||||||
self::afterUpdate(function ($row) {
|
self::afterUpdate(function ($row) {
|
||||||
@@ -65,7 +93,3 @@ class Activity extends Base
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +43,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
{field: 'weigh', title: __('Weigh'), operate: false},
|
{field: 'weigh', title: __('Weigh'), operate: false},
|
||||||
{field: 'status', title: __('Status'), searchList: {"normal":__('Status normal'),"hidden":__('Status hidden')}, formatter: Table.api.formatter.status},
|
{field: 'status', title: __('Status'), searchList: {"normal":__('Status normal'),"hidden":__('Status hidden')}, formatter: Table.api.formatter.status},
|
||||||
{field: 'applet_activity_qrcode_path', title: __('Applet_activity_qrcode_path'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
{field: 'applet_activity_qrcode_path', title: __('Applet_activity_qrcode_path'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
||||||
{field: 'points_status', title: __('Points_status'), searchList: {"1":__('Points_status 1'),"2":__('Points_status 2'),"3":__('Points_status 3')}, formatter: Table.api.formatter.normal},
|
{field: 'checked_in_qrcode', title: __('Checked_in_qrcode'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
||||||
|
{field: 'points_status', title: __('Points_status'), searchList: { "1": __('Points_status 1'), "2": __('Points_status 2'), "3": __('Points_status 3') }, formatter: Table.api.formatter.normal},
|
||||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
||||||
buttons:[
|
buttons:[
|
||||||
{
|
{
|
||||||
@@ -87,11 +88,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
extend: 'data-area=["40%","60%"]',
|
extend: 'data-area=["40%","60%"]',
|
||||||
url: 'wdsxh/activity/activity/verification_applet_code',
|
url: 'wdsxh/activity/activity/verification_applet_code',
|
||||||
visible: function (row) {
|
visible: function (row) {
|
||||||
if(Config.applet_appid !== null && Config.applet_appid !== undefined && Config.applet_appid !== '' && row.is_verifying == '1' && row.verification_method == 1 && row.state != '3'){
|
return false;
|
||||||
return true;
|
// if(Config.applet_appid !== null && Config.applet_appid !== undefined && Config.applet_appid !== '' && row.is_verifying == '1' && row.verification_method == 1 && row.state != '3'){
|
||||||
}else{
|
// return true;
|
||||||
return false;
|
// }else{
|
||||||
}
|
// return false;
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||||||
{field: 'state', title: __('State'), searchList: {"1":__('State 1'),"2":__('State 2'),"3":__('State 3'),"4":__('State 4'),"5":__('State 5')}, formatter: Table.api.formatter.normal},
|
{field: 'state', title: __('State'), searchList: {"1":__('State 1'),"2":__('State 2'),"3":__('State 3'),"4":__('State 4'),"5":__('State 5')}, formatter: Table.api.formatter.normal},
|
||||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||||
{field: 'pay_time', title: __('付款时间'), operate:false},
|
{field: 'pay_time', title: __('付款时间'), operate:false},
|
||||||
|
{field: 'check_in_status', title: __('check_in_status'), searchList: {"checked_in":__('checked_in'),"unchecked_in":__('unchecked_in')}, formatter: Table.api.formatter.normal},
|
||||||
{field: 'is_sign_in', title: __('Is_sign_in'), searchList: {"1":__('Is_sign_in 1'),"2":__('Is_sign_in 2'),"3":__('Is_sign_in 3')}, formatter: Table.api.formatter.normal},
|
{field: 'is_sign_in', title: __('Is_sign_in'), searchList: {"1":__('Is_sign_in 1'),"2":__('Is_sign_in 2'),"3":__('Is_sign_in 3')}, formatter: Table.api.formatter.normal},
|
||||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
||||||
buttons: [
|
buttons: [
|
||||||
|
|||||||
Reference in New Issue
Block a user