<?php
|
|
namespace app\api\controller\branch;
|
|
use app\api\controller\Controller;
|
use app\api\model\branch\ActivityUser as ActivityUserModel; // 报名会员
|
use app\common\service\qrcode\ExtractService;
|
use xin\helper\Func;
|
|
/**
|
* 活动报名控制器
|
*/
|
class ActivityUser extends Controller
|
{
|
/**
|
* 某活动报名的用户列表
|
*/
|
public function lists()
|
{
|
$model = new ActivityUserModel;
|
$list = $model->getListForActivity($this->postData(), true);
|
return $this->renderSuccess('', compact('list'));
|
}
|
|
|
/**
|
* 用户报名的活动列表
|
*/
|
public function listsForUser()
|
{
|
$user = $this->getUser();
|
$model = new ActivityUserModel;
|
$list = $model->getListForUser($user['user_id'], $this->postData());
|
return $this->renderSuccess('', compact('list'));
|
}
|
|
/**
|
*报名详情
|
*/
|
public function detail($order_id)
|
{
|
$detail = ActivityUserModel::detail($order_id, ['activity.image']);
|
return $this->renderSuccess('', compact('detail'));
|
}
|
|
/**
|
* 获取核销二维码(废弃)
|
*/
|
public function qrcode($order_id, $source)
|
{
|
$user = $this->getUser();
|
$Qrcode = new ExtractService(
|
$this->app_id,
|
$user,
|
$order_id,
|
$source,
|
'activityUser-' . $order_id,
|
'activityUser'
|
);
|
return $this->renderSuccess('',[
|
'qrcode' => $Qrcode->getImage(),
|
]);
|
}
|
|
// 签到
|
public function verify($activity_id)
|
{
|
$model = new ActivityUserModel;
|
$user = $this->getUser();
|
if ($model->onVerify($user, $activity_id, $this->postData())) {
|
return $this->renderSuccess('签到成功');
|
}
|
// 如果判断到没有报名。需要处理朋友帮报的情况
|
$error = $model->getError();
|
if ($error && $error == 'not_reg') {
|
return $this->renderSuccess('', [
|
'result' => 'not_reg'
|
]);
|
}
|
return $this->renderError($error ?:'签到失败');
|
}
|
}
|