65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
namespace app\controller\api;
|
|
|
|
|
|
use app\common\repositories\marketing\activity\ActivityRepository;
|
|
use app\common\repositories\marketing\activity\RecordRepository;
|
|
use crmeb\basic\BaseController;
|
|
use think\App;
|
|
use think\exception\ValidateException;
|
|
|
|
class Activity extends BaseController{
|
|
|
|
protected $repository;
|
|
|
|
public function __construct(App $app, ActivityRepository $repository){
|
|
parent::__construct($app);
|
|
$this->repository = $repository;
|
|
}
|
|
/**
|
|
* Common: 获取详情
|
|
* Author: wu-hui
|
|
* Time: 2024/03/14 17:22
|
|
* @param $id
|
|
* @return mixed
|
|
*/
|
|
public function detail($id){
|
|
$info = $this->repository->getSearchModel(['id'=>$id])->findOrEmpty()->toArray();
|
|
|
|
return app('json')->success($info);
|
|
}
|
|
/**
|
|
* Common: 申请参加活动
|
|
* Author: wu-hui
|
|
* Time: 2024/03/14 19:09
|
|
* @return mixed
|
|
*/
|
|
public function joinActivity(){
|
|
// 获取申请参数
|
|
$params = $this->request->params([
|
|
['activity_id',0],
|
|
['mer_id',0],
|
|
// 支付相关
|
|
'pay_type',
|
|
'return_url'
|
|
]);
|
|
if($params['activity_id'] <= 0) throw new ValidateException('活动不存在或者已经结束!');
|
|
if($params['mer_id'] <= 0) throw new ValidateException('请选择烟酒店!');
|
|
// 处理数据
|
|
$params['uid'] = $this->request->uid();
|
|
$params['user_info'] = $this->request->userInfo();
|
|
$params['is_app'] = $this->request->isApp();
|
|
|
|
$res = app()->make(RecordRepository::class)->joinActivityHandle($params);
|
|
|
|
if($res) return $res;
|
|
else return app('json')->success("操作成功");
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|