|
@@ -1196,430 +1196,56 @@ 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日');
|
|
|
- }
|
|
|
+ //视频分类列表
|
|
|
+ public function videotype() {
|
|
|
+ $type = input('type', 0, 'intval'); //分类类型:0=老年大学,1=普法课堂
|
|
|
+ if (!in_array($type, [0, 1])) {
|
|
|
+ $this->error('参数错误');
|
|
|
}
|
|
|
|
|
|
- $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, num')
|
|
|
- ->where($where)->page($this->page, $this->pagenum)->order('weigh, id desc')->select();
|
|
|
+ $list = Db::name('video_type')->field('id, name, image')->where(['type' => $type])
|
|
|
+ ->page($this->page, $this->pagenum)->order('weigh, id')->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, num, 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 gameplacearea() {
|
|
|
- $id = input('id', 0, 'intval'); //排位赛id
|
|
|
- if (!$id) {
|
|
|
- $this->error('参数缺失');
|
|
|
- }
|
|
|
- $where['game_id'] = $id;
|
|
|
-
|
|
|
- $hu_game_place = Db::name('game_place');
|
|
|
- $list = $hu_game_place->field('city_id id')->where($where)->group('city_id')->select();
|
|
|
- if ($list) {
|
|
|
- $hu_area = Db::name('area');
|
|
|
- foreach ($list as &$v) {
|
|
|
- $v['name'] = $hu_area->where(['id' => $v['id']])->value('name');
|
|
|
- $area_list = $hu_game_place->field('area_id id')->where(['game_id' => $id, 'city_id' => $v['id']])->group('area_id')->select();
|
|
|
- foreach ($area_list as &$value) {
|
|
|
- $value['name'] = $hu_area->where(['id' => $value['id']])->value('name');
|
|
|
- }
|
|
|
-
|
|
|
- $v['area_list'] = $area_list;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('场地列表区域', $list);
|
|
|
+ $this->success('分类', $list);
|
|
|
}
|
|
|
|
|
|
- //场地列表
|
|
|
- public function gameplace() {
|
|
|
- $id = input('id', 0, 'intval'); //排位赛id
|
|
|
- $area_id = input('area_id', 0, 'intval'); //区id
|
|
|
- if (!$id) {
|
|
|
- $this->error('参数缺失');
|
|
|
+ //视频列表
|
|
|
+ public function video() {
|
|
|
+ $type_id = input('type_id', 0, 'intval'); //分类id
|
|
|
+ if (!$type_id) {
|
|
|
+ $this->error('您的网络开小差了~');
|
|
|
}
|
|
|
|
|
|
- $where['game_id'] = $id;
|
|
|
- if ($area_id) {
|
|
|
- $where['area_id'] = $area_id;
|
|
|
- }
|
|
|
- $where['status'] = 1;
|
|
|
-
|
|
|
- $list = Db::name('game_place')->field('id, name, image')
|
|
|
- ->where($where)->order('id')->select();
|
|
|
+ $list = Db::name('video')->field('id, title, image')->where(['video_type_id' => $type_id, 'status' => 1, 'inject_status' => 2])
|
|
|
+ ->page($this->page, $this->pagenum)->order('weigh, id desc')->select();
|
|
|
|
|
|
$list = list_domain_image($list, ['image']);
|
|
|
-
|
|
|
- $this->success('场地列表', $list);
|
|
|
+ $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);
|
|
|
- }
|
|
|
-
|
|
|
- //赛前备战区(1v1)
|
|
|
- public function gameprepare() {
|
|
|
- $id = input('id', 0, 'intval'); //排位赛id
|
|
|
- if (!$id) {
|
|
|
- $this->error('参数缺失');
|
|
|
- }
|
|
|
- //查询是否已经报名
|
|
|
- $game_people = Db::name('game_people')->where(['user_id' => $this->auth->id, 'game_id' => $id, 'status' => 1])->find();
|
|
|
- if (!$game_people) {
|
|
|
- $this->error('您尚未报名该比赛');
|
|
|
- }
|
|
|
- if ($game_people['num'] != 1) {
|
|
|
- $this->error('您的网络开小差了');
|
|
|
- }
|
|
|
-
|
|
|
- $where['game_id'] = $id;
|
|
|
- $where['game_place_id'] = $game_people['game_place_id'];
|
|
|
- $where['status'] = 1;
|
|
|
-
|
|
|
- $list = Db::name('game_people')->field('user_id')->where($where)->page($this->page, $this->pagenum)->order('id')->select();
|
|
|
- if ($list) {
|
|
|
- $hu_user = Db::name('user');
|
|
|
- $hu_rank = Db::name('rank'); //段位
|
|
|
- foreach ($list as &$v) {
|
|
|
- $user_info = $hu_user->field('nickname, avatar, rank_id')->where(['id' => $v['user_id']])->find();
|
|
|
- $v['nickname'] = $user_info['nickname'];
|
|
|
- $v['avatar'] = one_domain_image($user_info['avatar']);
|
|
|
- $rank = $hu_rank->where(['id' => $user_info['rank_id']])->value('name');
|
|
|
- $v['rank'] = $rank ? : '';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $game_image = Db::name('game')->where(['id' => $id])->value('image');
|
|
|
- $return_data['image'] = one_domain_image($game_image);
|
|
|
- $return_data['list'] = $list;
|
|
|
-
|
|
|
- $this->success('备战区', $return_data);
|
|
|
- }
|
|
|
-
|
|
|
- //赛前组队区(多v多)
|
|
|
- public function gameteam() {
|
|
|
- $id = input('id', 0, 'intval'); //排位赛id
|
|
|
- if (!$id) {
|
|
|
- $this->error('参数缺失');
|
|
|
- }
|
|
|
- //查询是否已经报名
|
|
|
- $hu_game_people = Db::name('game_people');
|
|
|
- $game_people = $hu_game_people->where(['user_id' => $this->auth->id, 'game_id' => $id, 'status' => 1])->find();
|
|
|
- if (!$game_people) {
|
|
|
- $this->error('您尚未报名该比赛');
|
|
|
- }
|
|
|
- if ($game_people['num'] <= 1) {
|
|
|
- $this->error('您的网络开小差了');
|
|
|
- }
|
|
|
-
|
|
|
- $where['game_id'] = $id;
|
|
|
- $where['game_place_id'] = $game_people['game_place_id'];
|
|
|
- $where['status'] = 1;
|
|
|
- $where['group'] = ['gt', 0];
|
|
|
-
|
|
|
-
|
|
|
- $group = $hu_game_people->field('group')->where($where)/*->page($this->page, $this->pagenum)*/->group('group')->order('id')->select();
|
|
|
- $list = [];
|
|
|
- if ($group) {
|
|
|
- $hu_user = Db::name('user');
|
|
|
- $arr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
|
|
- foreach ($group as $k =>&$value) {
|
|
|
- $group_team_info = [];
|
|
|
- $group_team_info['group_id'] = $value['group'];
|
|
|
- $group_team_info['group_name'] = $k > 25 ? (string)($k + 1) : $arr[$k];
|
|
|
- $people_list = $hu_game_people->field('user_id, is_leader')->where($where)->where(['group' => $value['group']])->order('is_leader desc')->select();
|
|
|
- foreach ($people_list as &$v) {
|
|
|
- $user_info = $hu_user->field('nickname, avatar')->where(['id' => $v['user_id']])->find();
|
|
|
- $v['nickname'] = $user_info['nickname'];
|
|
|
- $v['avatar'] = one_domain_image($user_info['avatar']);
|
|
|
- }
|
|
|
- $group_team_info['group_list'] = $people_list;
|
|
|
- array_push($list, $group_team_info);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $game_image = Db::name('game')->where(['id' => $id])->value('image');
|
|
|
- $return_data['image'] = one_domain_image($game_image);
|
|
|
- $return_data['list'] = $list;
|
|
|
- $this->success('备战区', $return_data);
|
|
|
- }
|
|
|
-
|
|
|
- //创建队伍
|
|
|
- public function setteam() {
|
|
|
- $id = input('id', 0, 'intval'); //排位赛id
|
|
|
+ //视频详情
|
|
|
+ public function videoinfo() {
|
|
|
+ $id = input('id', 0, 'intval'); //视频id
|
|
|
if (!$id) {
|
|
|
- $this->error('参数缺失');
|
|
|
- }
|
|
|
- //查询是否已经报名
|
|
|
- $hu_game_people = Db::name('game_people');
|
|
|
- $game_people = $hu_game_people->where(['user_id' => $this->auth->id, 'game_id' => $id, 'status' => 1])->find();
|
|
|
- if (!$game_people) {
|
|
|
- $this->error('您尚未报名该比赛');
|
|
|
- }
|
|
|
- if ($game_people['num'] <= 1) {
|
|
|
- $this->error('您的网络开小差了');
|
|
|
- }
|
|
|
- if ($game_people['group'] > 0) {
|
|
|
- $this->error('您已经有队伍了');
|
|
|
- }
|
|
|
-
|
|
|
- $data['group'] = $this->auth->id;
|
|
|
- $data['is_leader'] = 1;
|
|
|
- $data['now_num'] = 1;
|
|
|
- $data['updatetime'] = time();
|
|
|
-
|
|
|
- $rs = $hu_game_people->where(['id' => $game_people['id'], 'group' => 0])->setField($data);
|
|
|
- if (!$rs) {
|
|
|
$this->error('您的网络开小差了');
|
|
|
}
|
|
|
|
|
|
- $this->success('创建成功');
|
|
|
- }
|
|
|
-
|
|
|
- //加入队伍
|
|
|
- public function addteam() {
|
|
|
- $id = input('id', 0, 'intval'); //排位赛id
|
|
|
- $group_id = input('group_id', 0, 'intval'); //小组id
|
|
|
- if (!$id || !$group_id) {
|
|
|
- $this->error('参数缺失');
|
|
|
- }
|
|
|
- //查询是否已经报名
|
|
|
- $hu_game_people = Db::name('game_people');
|
|
|
- $game_people = $hu_game_people->where(['user_id' => $this->auth->id, 'game_id' => $id, 'status' => 1])->find();
|
|
|
- if (!$game_people) {
|
|
|
- $this->error('您尚未报名该比赛');
|
|
|
- }
|
|
|
- if ($game_people['num'] <= 1) {
|
|
|
- $this->error('您的网络开小差了');
|
|
|
- }
|
|
|
- if ($game_people['group'] > 0) {
|
|
|
- $this->error('您已经有队伍了');
|
|
|
- }
|
|
|
-
|
|
|
- $group_info = $hu_game_people->where(['game_id' => $id, 'group' => $group_id])->find();
|
|
|
- if (!$group_info) {
|
|
|
- $this->error('该队伍已经解散');
|
|
|
- }
|
|
|
- if ($group_info['now_num'] >= $game_people['num']) {
|
|
|
- $this->error('该队伍人数已到上线');
|
|
|
- }
|
|
|
-
|
|
|
- //开启redis
|
|
|
- $redis = new \Redis();
|
|
|
- $redis->connect(config('redis_host'), config('redis_port'));
|
|
|
- if (config('redis_pwd')) {
|
|
|
- $redis->auth(config('redis_pwd'));
|
|
|
- }
|
|
|
- if(config('redis_selectdb') > 0){
|
|
|
- $redis->select(config('redis_selectdb'));
|
|
|
- }
|
|
|
- //是否可以操作: 1可以 其他 不可以
|
|
|
- $game_people_status = $redis->lPop('game_people' . $id . '_' . $group_id);
|
|
|
- if ($game_people_status != 1) {
|
|
|
- $this->error('网络繁忙,请稍后再试');
|
|
|
- }
|
|
|
-
|
|
|
- $data['group'] = $group_id;
|
|
|
- $data['now_num'] = $group_info['now_num'] + 1;
|
|
|
- $data['updatetime'] = time();
|
|
|
-
|
|
|
- //开启事务
|
|
|
- Db::startTrans();
|
|
|
- //修改信息
|
|
|
- $rs = $hu_game_people->where(['id' => $game_people['id'], 'group' => 0])->setField($data);
|
|
|
- if (!$rs) {
|
|
|
- Db::rollback();
|
|
|
- $redis->rPush('game_people' . $id . '_' . $group_id, 1);
|
|
|
- $this->error('您的网络开小差了');
|
|
|
- }
|
|
|
- //修改队伍其他信息
|
|
|
- $rt = $hu_game_people->where(['game_id' => $id, 'group' => $group_id, 'now_num' => $group_info['now_num']])->setField('now_num', $group_info['now_num'] + 1);
|
|
|
- if (!$rt) {
|
|
|
- Db::rollback();
|
|
|
- $redis->rPush('game_people' . $id . '_' . $group_id, 1);
|
|
|
- $this->error('您的网络开小差了');
|
|
|
- }
|
|
|
-
|
|
|
- Db::commit();
|
|
|
- $redis->rPush('game_people' . $id . '_' . $group_id, 1);
|
|
|
- $this->success('加入成功');
|
|
|
- }
|
|
|
-
|
|
|
- //排行榜
|
|
|
- public function rankinglist() {
|
|
|
- $city_id = input('city_id', 0, 'intval'); //市id
|
|
|
- $area_id = input('area_id', 0, 'intval'); //区id
|
|
|
-
|
|
|
- if (!$city_id && !$area_id) {
|
|
|
- $this->error('请选择查看地区');
|
|
|
+ $info = Db::name('video')->field('id, title, image, desc, is_pay, status, inject_status, seriesid, programid, movieid')
|
|
|
+ ->where(['id' => $id])->find();
|
|
|
+ if (!$info) {
|
|
|
+ $this->error('数据不存在');
|
|
|
}
|
|
|
-
|
|
|
- $where = [];
|
|
|
- if ($city_id) {
|
|
|
- $where['city_id'] = $city_id;
|
|
|
+ if ($info['status'] != 1) {
|
|
|
+ $this->error('视频丢失');
|
|
|
}
|
|
|
- if ($area_id) {
|
|
|
- $where['area_id'] = $area_id;
|
|
|
+ if ($info['inject_status'] != 2) {
|
|
|
+ $this->error('视频丢失');
|
|
|
}
|
|
|
|
|
|
- $list = Db::name('user')->field('id, nickname, avatar, win_num, lose_num, power_value, rank_id')->where($where)->page($this->page, $this->pagenum)->order('power_value desc')->select();
|
|
|
-
|
|
|
- $list = list_domain_image($list, ['avatar']);
|
|
|
- if ($list) {
|
|
|
- $hu_rank = Db::name('rank');
|
|
|
- foreach ($list as $k => &$v) {
|
|
|
- $rank_name = $hu_rank->where(['id' => $v['rank_id']])->value('name');
|
|
|
- $v['rank_name'] = $rank_name ? : '';
|
|
|
- $v['rank'] = $this->page * $this->pagenum + $k + 1;
|
|
|
- }
|
|
|
- }
|
|
|
+ $info['image'] = one_domain_image($info['image']);
|
|
|
|
|
|
- $this->success('排行榜', $list);
|
|
|
+ $this->success('详情', $info);
|
|
|
}
|
|
|
-
|
|
|
}
|