|
@@ -14,7 +14,7 @@ use Qcloud\Cos\Exception\ServiceResponseException;
|
|
|
*/
|
|
|
class Index extends Api
|
|
|
{
|
|
|
- protected $noNeedLogin = ['banner', 'activelist', 'personaltype', 'personalactivetype', 'car', 'leader', 'personaldirection', 'activeinfo'];
|
|
|
+ protected $noNeedLogin = ['banner', 'activelist', 'personaltype', 'personalactivetype', 'car', 'leader', 'personaldirection', 'activeinfo', 'position', 'gamelist'];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
/**
|
|
@@ -1196,4 +1196,182 @@ class Index extends Api
|
|
|
|
|
|
$this->success('信息', $info);
|
|
|
}
|
|
|
+
|
|
|
+ //擅长位置
|
|
|
+ public function position() {
|
|
|
+ $list = Db::name('position')->field('id, name')->order('weigh, id')->select();
|
|
|
+
|
|
|
+ $this->success('擅长位置', $list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //赛事活动
|
|
|
+ public function gameinfo() {
|
|
|
+ $list = Db::name('game_info')->field('id, name, image, createtime')->page($this->page, $this->pagenum)->order('weigh, id desc')->select();
|
|
|
+ $list = list_domain_image($list, ['image']);
|
|
|
+ if ($list) {
|
|
|
+ foreach ($list as &$v) {
|
|
|
+ $v['createtime'] = date('Y年m月d日');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('赛事活动', $list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //赛事活动详情
|
|
|
+ public function gameinfodetail() {
|
|
|
+ $id = input('id', 0, 'intval');
|
|
|
+ if (!$id) {
|
|
|
+ $this->error('参数缺失');
|
|
|
+ }
|
|
|
+
|
|
|
+ $info = Db::name('game_info')->field('name, content')->where(['id' => $id])->find();
|
|
|
+ if (!$info) {
|
|
|
+ $this->error('您的网络开小差了');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('详情', $info);
|
|
|
+ }
|
|
|
+
|
|
|
+ //排位赛
|
|
|
+ public function gamelist() {
|
|
|
+ $where['signupendtime'] = ['gt', time()];
|
|
|
+ $where['status'] = 0;
|
|
|
+ $where['showstatus'] = 1;
|
|
|
+
|
|
|
+ $list = Db::name('game')->field('id, name, image')
|
|
|
+ ->where($where)->page($this->page, $this->pagenum)->order('weigh, id desc')->select();
|
|
|
+
|
|
|
+ $list = list_domain_image($list, ['image']);
|
|
|
+
|
|
|
+ $this->success('排位赛', $list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //排位赛详情
|
|
|
+ public function gamedetail() {
|
|
|
+ $id = input('id', 0, 'intval'); //排位赛id
|
|
|
+ if (!$id) {
|
|
|
+ $this->error('参数缺失');
|
|
|
+ }
|
|
|
+
|
|
|
+ $info = Db::name('game')->field('id, name, desc, image, price, signupendtime, activecontent, status, showstatus')->where(['id' => $id])->find();
|
|
|
+ if (!$info) {
|
|
|
+ $this->error('您的网络开小差了');
|
|
|
+ }
|
|
|
+ if ($info['showstatus'] != 1) {
|
|
|
+ $this->error('比赛已经下架');
|
|
|
+ }
|
|
|
+
|
|
|
+ $info['signupendtime'] = date('Y.m.d H:i', $info['signupendtime']);
|
|
|
+ $info['image'] = one_domain_image($info['image']);
|
|
|
+ //查询是否报名
|
|
|
+ $info['sign_up'] = Db::name('game_people')->where(['user_id' => $this->auth->id, 'game_id' => $id, 'status' => 1])->count('id');
|
|
|
+
|
|
|
+ $this->success('详情', $info);
|
|
|
+ }
|
|
|
+
|
|
|
+ //场地列表
|
|
|
+ public function gameplace() {
|
|
|
+ $id = input('id', 0, 'intval'); //排位赛id
|
|
|
+ $area_id = input('area_id', 0, 'intval'); //区id
|
|
|
+ if (!$id || !$area_id) {
|
|
|
+ $this->error('参数缺失');
|
|
|
+ }
|
|
|
+
|
|
|
+ $where['game_id'] = $id;
|
|
|
+ $where['area_id'] = $area_id;
|
|
|
+ $where['status'] = 1;
|
|
|
+
|
|
|
+ $list = Db::name('game_place')->field('id, name, image')
|
|
|
+ ->where($where)->page($this->page, $this->pagenum)->order('id')->select();
|
|
|
+
|
|
|
+ $list = list_domain_image($list, ['image']);
|
|
|
+
|
|
|
+ $this->success('场地列表', $list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //报名比赛
|
|
|
+ public function signupgame() {
|
|
|
+ $id = input('id', 0, 'intval'); //排位赛id
|
|
|
+ $game_place_id = input('place_id', 0, 'intval'); //场地id
|
|
|
+
|
|
|
+ if (!$id || !$game_place_id) {
|
|
|
+ $this->error('参数缺失');
|
|
|
+ }
|
|
|
+ //比赛信息
|
|
|
+ $game_info = Db::name('game')->find($id);
|
|
|
+ if (!$game_info) {
|
|
|
+ $this->error('您的网络开小差了');
|
|
|
+ }
|
|
|
+ if ($game_info['status'] != 0 || $game_info['showstatus'] != 1) {
|
|
|
+ $this->error('当前比赛已不能报名');
|
|
|
+ }
|
|
|
+ if ($game_info['signupendtime'] < time()) {
|
|
|
+ $this->error('比赛已经截止报名');
|
|
|
+ }
|
|
|
+ //查询是否已报名
|
|
|
+ $game_people = Db::name('game_people')->where(['user_id' => $this->auth->id, 'game_id' => $id])->find();
|
|
|
+ if ($game_people) {
|
|
|
+ if ($game_people['status'] == 1) {
|
|
|
+ $this->error('您已经报名了');
|
|
|
+ }
|
|
|
+ if ($game_people['status'] == 2) {
|
|
|
+ $this->error('您正在申请退款,暂不能报名');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $data['user_id'] = $this->auth->id;
|
|
|
+ $data['game_id'] = $id;
|
|
|
+ $data['game_place_id'] = $game_place_id;
|
|
|
+ $data['price'] = $game_info['price'];
|
|
|
+ $data['starttime'] = $game_info['starttime'];
|
|
|
+ $data['endtime'] = $game_info['endtime'];
|
|
|
+ $data['num'] = $game_info['num'];
|
|
|
+ $data['status'] = 0;
|
|
|
+ $data['createtime'] = time();
|
|
|
+ $data['updatetime'] = time();
|
|
|
+
|
|
|
+ //开启事务
|
|
|
+ Db::startTrans();
|
|
|
+ //添加记录
|
|
|
+ if ($game_people) {
|
|
|
+ $rs = Db::name('game_people')->where(['id' => $game_people['id'], 'status' => $game_people['status']])->setField($data);
|
|
|
+ } else {
|
|
|
+ $rs = Db::name('game_people')->insertGetId($data);
|
|
|
+ }
|
|
|
+ if (!$rs) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('您的网络开小差了');
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成支付订单记录
|
|
|
+ $rechar_order['user_id'] = $this->auth->id;
|
|
|
+ $rechar_order['order_no'] = date('YmdHis', time()) . $this->auth->id . rand(10000000, 99999999); //微信订单编号
|
|
|
+ $rechar_order['money'] = $game_info['price'];
|
|
|
+ $rechar_order['purpose'] = 1; //充值用途:1=支付订单,2=充值,3=开通会员
|
|
|
+ $rechar_order['pay_type'] = 'wechat';
|
|
|
+ $rechar_order['relation_id'] = $game_people ? $game_people['id'] : $rs;
|
|
|
+ $rechar_order['createtime'] = time();
|
|
|
+
|
|
|
+ $result = Db::name('rechar_order')->insertGetId($rechar_order);
|
|
|
+ if (!$result) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('网络延迟,请稍后再试');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
+ //构建支付链接数据
|
|
|
+ $wxData['body'] = '报名比赛支付';
|
|
|
+ $wxData['out_trade_no'] = $rechar_order['order_no'];
|
|
|
+ $wxData['total_fee'] = $game_info['price'];
|
|
|
+// $wxData['total_fee'] = 0.01;
|
|
|
+ $wxData['openid'] = $this->auth->openid;
|
|
|
+
|
|
|
+// require_once($_SERVER['DOCUMENT_ROOT'] . '/Plugins/Weixin/WxPay/WxPay.php');
|
|
|
+ $wxPay = new wxpay\WxPay(config('wxchatpay'));
|
|
|
+ $doResult = $wxPay->WxPayJs($wxData);
|
|
|
+
|
|
|
+ $this->success('微信支付参数返回成功', $doResult);
|
|
|
+ }
|
|
|
+
|
|
|
}
|