feat: 扫码签到功能

This commit is contained in:
2026-03-19 17:41:23 +08:00
parent e2c8ae752d
commit a62ff78b82
9 changed files with 493 additions and 357 deletions

View File

@@ -1,6 +1,6 @@
<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者,助力商协会发展
// | 麦沃德科技赋能开发者,助力商协会发展
// +----------------------------------------------------------------------
// | Copyright (c) 20172024 www.wdsxh.cn All rights reserved.
// +----------------------------------------------------------------------
@@ -42,7 +42,8 @@ class Activity extends Model
'state_text',
'is_verifying_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, [
'page' => $path,
'check_path' => false,
'env_version' => 'trial', // 正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版
]);
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
@@ -202,6 +204,48 @@ class Activity extends Model
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' => 'trial', // 正式版为 "release",体验版为 "trial",开发版为 "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()
{
return ['2' => __('Points_status 2'), '1' => __('Points_status 1')];
@@ -216,6 +260,4 @@ class Activity extends Model
{
return ['1' => __('启用单独证书'), '2' => __('使用统一证书')];
}
}