Game.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <?php
  2. /**
  3. * 游戏管理控制器
  4. */
  5. namespace app\mcpsapi\controller;
  6. use think\Db;
  7. use think\Env;
  8. use think\Exception;
  9. use app\common\logic\Member as MemberService;
  10. use app\common\model\GamePoint;
  11. use GuzzleHttp\Client;
  12. use app\common\model\ServerInfo;
  13. class Game extends Guild
  14. {
  15. protected $_model;
  16. protected $_channelId;
  17. // 特殊处理的 IOS游戏id 数组
  18. protected $gameIOS;
  19. // 游戏平台
  20. protected $_platform = [
  21. 0 => '安卓',
  22. 1 => 'IOS'
  23. ];
  24. // 游戏状态
  25. protected $_status = [
  26. 0 => ['index'=>1,'value'=>'正常'],
  27. 1 => ['index'=>2,'value'=>'白名单'],
  28. // 3 => '下架',
  29. ];
  30. //新闻类型
  31. protected $_type = [
  32. 1 => '资讯',
  33. 2 => '麻花网络',
  34. 3 => '评测',
  35. 4 => '攻略',
  36. 5 => '视频',
  37. 6 => '活动',
  38. 7 => '更新',
  39. 8 => '新闻',
  40. 9 => '充值活动'
  41. ];
  42. // todo 显示的新闻类型
  43. private $_newsType
  44. = array(
  45. 6 => '活动' ,
  46. 7 => '更新' ,
  47. 8 => '新闻' ,
  48. 9 => '充值活动'
  49. );
  50. private $_newsTypeList = ['6','7','8','9'];
  51. // 游戏等级
  52. protected $gameLevel = ['S' , 'A1' , 'A2' , 'B1' , 'B2' , 'B3' , 'B4' , 'C' , 'D'];
  53. protected function _initialize()
  54. {
  55. parent::_initialize();
  56. $this->_model = model('Game');
  57. $guildInfo = session('guild_info');
  58. $this->_channelId = $guildInfo['channel_id'];
  59. $this->_level = $guildInfo['level'];
  60. $this->gameIOS = config('gameIOS');
  61. }
  62. /**
  63. * 获取游戏列表
  64. * @return [type] [description]
  65. */
  66. public function getGameList()
  67. {
  68. $page = input('page',1);
  69. $pageSize = input('pageSize',10);
  70. $where = $this->_getCondition();
  71. switch ($this->_level) {
  72. case '3':
  73. $exist_game = Db::name('cy_sdkgamelist')->where(['channel_id'=>$this->_channelId])->column('gameid');
  74. $apply_game = Db::name('nw_game_package_apply')->where(['channel_id'=>$this->_channelId,'apply_status'=>0])->column('game_id');//白名单申请列表
  75. $list = $this->_model->alias('game')
  76. ->join('cy_gameinfo info', 'game.id = info.game_id')
  77. ->field(['game.id', 'game.name', 'info.mobileicon', 'game.type', 'game.subject', 'game.cooperation_status','info.platform','game.pinyin'])
  78. ->where($where)
  79. ->where("game.is_default = 0 and game.cooperation_status != 3")
  80. ->where(['game.id'=>['not in',$exist_game]])
  81. ->order('game.id desc')
  82. ->paginate($pageSize,false,['page'=>$page])->toArray();
  83. if ($list['data']) {
  84. foreach ($list['data'] as $key => $value) {//在申请表的话并且状态是申请中 0 吧对应的游戏状态改成4
  85. $list['data'][$key]['cooperation_status'] = in_array($value['id'],$apply_game)?'apply':$list['data'][$key]['cooperation_status'];
  86. }
  87. }
  88. return json(['data'=>$list,'code'=>20000,'msg'=>'获取游戏列表成功']);
  89. break;
  90. case '1':
  91. $list = $this->_model->alias('game')
  92. ->join('cy_gameinfo info', 'game.id = info.game_id')
  93. ->join('nw_game_channel_divide devide','game.id = devide.game_id and devide.channel_id = '.$this->_channelId,'left')
  94. ->field(['game.id', 'game.name', 'info.mobileicon', 'game.type', 'game.subject', 'game.cooperation_status','info.platform','game.pinyin','ratio'])
  95. ->where($where)
  96. ->where("game.is_default = 0 and game.cooperation_status != 3")
  97. ->order('game.id desc')
  98. ->paginate($pageSize,false,['page'=>$page])->toArray();
  99. if (!empty($list['data']) ) {
  100. foreach ($list['data'] as $key => $value) {
  101. if (empty($list['data'][$key]['ratio'])) {
  102. $list['data'][$key]['ratio'] = db::name('cy_game')->where(['id'=>$value['id']])->value('channel_split_ratio');
  103. }
  104. }
  105. }
  106. return json(['data'=>$list,'code'=>20000,'msg'=>'获取游戏列表成功']);
  107. break;
  108. default:
  109. $list = $this->_model->alias('game')
  110. ->join('cy_gameinfo info', 'game.id = info.game_id')
  111. ->field(['game.id', 'game.name', 'info.mobileicon', 'game.type', 'game.subject', 'game.cooperation_status','info.platform','game.pinyin'])
  112. ->where($where)
  113. ->where("game.is_default = 0 and game.cooperation_status != 3")
  114. ->order('game.id desc')
  115. ->paginate($pageSize,false,['page'=>$page])->toArray();
  116. return json(['data'=>$list,'code'=>20000,'msg'=>'获取游戏列表成功']);
  117. break;
  118. }
  119. }
  120. /**
  121. * 获取搜索菜单列表
  122. * @param string $value [description]
  123. */
  124. public function getGameMenu()
  125. {
  126. $meue = [];
  127. $meue['game_platform'] = $this->_platform;
  128. $meue['game_status'] = $this->_status;
  129. $meue['game_type'] = $this->_getType();
  130. $meue['game_subject'] = $this->_getSubject();
  131. $meue['game_list'] = $this->gameList();
  132. return json(['data'=>$meue,'code'=>20000,'msg'=>'获取搜索菜单列表成功']);
  133. }
  134. /**
  135. * 我的游戏链接read
  136. * @param string $value [description]
  137. */
  138. public function myGameLink()
  139. {
  140. $page = input('page',1);
  141. $pageSize = input('pageSize',10);
  142. $platform = input('platform');
  143. $level = input('level');//账号类型
  144. $gameName = input('gameName', '', 'trim');
  145. $accountName = input('accountName', '', 'trim');
  146. $condition = [];
  147. $condition['game.game_kind'] = 2;
  148. if (is_numeric($platform)) {
  149. $condition['info.platform'] = (int)$platform;
  150. }
  151. if (! empty($gameName)) {
  152. $condition['game.name'] = ['LIKE', '%' . $gameName . '%'];
  153. }
  154. if (! empty($accountName)) {
  155. $level == 2 && $condition['p_channel.name'] = ['LIKE', $accountName . '%'];
  156. $level == 3 && $condition['channel.name'] = ['LIKE', $accountName . '%'];
  157. }
  158. $account_level = Db::name('nw_channel')->where(['id' => $this->_channelId])->value('level');
  159. switch ($account_level) {
  160. case '1'://B账号
  161. $list = model('SdkGameList')->alias('sdk')
  162. ->join('cy_game game', 'game.id = sdk.gameid AND game.cooperation_status != 3 AND (game.is_default = 0)')
  163. ->join('cy_gameinfo info', 'game.id = info.game_id', 'left')
  164. ->join('nw_channel channel', 'sdk.channel_id = channel.id', 'left')
  165. ->join('nw_channel p_channel', 'channel.parent_id = p_channel.id AND p_channel.level = 2', 'left')
  166. ->field(
  167. [
  168. 'game.id', 'game.name', 'info.mobileicon','game.pinyin','info.platform',
  169. 'sdk.id' => 'sdk_id','sdk.filename', 'sdk.update_time', 'sdk.upload_status','sdk.package_type','sdk.channel_id','channel.name' =>'c_name','p_channel.name'=>'b_name','sdk.remark','game.pinyin'
  170. ]
  171. )
  172. ->where(['channel.id_path' => ['LIKE', '%,' . $this->_channelId . ',%']])
  173. ->where($condition)
  174. ->order('sdk.update_time desc')
  175. ->paginate(['list_rows'=>$pageSize,'page'=>$page])->toArray();
  176. break;
  177. case '2'://B-
  178. $list = model('SdkGameList')->alias('sdk')
  179. ->join('cy_game game', 'game.id = sdk.gameid AND game.cooperation_status != 3 AND (game.is_default = 0)')
  180. ->join('cy_gameinfo info', 'game.id = info.game_id', 'left')
  181. ->join('nw_channel channel', 'sdk.channel_id = channel.id', 'left')
  182. ->field(
  183. [
  184. 'game.id', 'game.name', 'info.mobileicon','game.pinyin','info.platform',
  185. 'sdk.id' => 'sdk_id','sdk.filename', 'sdk.update_time', 'sdk.upload_status','sdk.package_type','sdk.channel_id','channel.name' =>'c_name','sdk.remark','game.pinyin'
  186. ]
  187. )
  188. ->where(['channel.id_path' => ['LIKE', '%,' . $this->_channelId . ',%']])
  189. ->where($condition)
  190. ->order('sdk.update_time desc')
  191. ->paginate(['list_rows'=>$pageSize,'page'=>$page])->toArray();
  192. break;
  193. case '3'://C
  194. $list = model('SdkGameList')->alias('sdk')
  195. ->join('cy_game game', 'game.id = sdk.gameid AND game.cooperation_status != 3 AND (game.is_default = 0)')
  196. ->join('cy_gameinfo info', 'game.id = info.game_id', 'left')
  197. ->join('nw_channel channel', 'sdk.channel_id = channel.id', 'left')
  198. ->field(
  199. [
  200. 'game.id', 'game.name', 'info.mobileicon','game.pinyin','info.platform',
  201. 'sdk.id' => 'sdk_id','sdk.filename', 'sdk.update_time', 'sdk.upload_status','sdk.package_type','sdk.channel_id','channel.name' =>'c_name','sdk.remark','game.pinyin'
  202. ]
  203. )
  204. ->where('channel.id = '.$this->_channelId)
  205. ->where($condition)
  206. ->order('sdk.update_time desc')
  207. ->paginate(['list_rows'=>$pageSize,'page'=>$page])->toArray();
  208. break;
  209. default:
  210. $list = [];
  211. break;
  212. }
  213. if (!isset($list['data'])) {
  214. return json(['data'=>$list,'code'=>10038,'msg'=>'暂无数据']);
  215. }
  216. foreach ($list['data'] as $key => $value) {
  217. $short_link = db('nw_promotion_short_link')->where(['game_id'=>$value['id'],'channel_id'=>$value['channel_id'],'package_type'=>$value['package_type']])->value('short_link');
  218. if (!empty($short_link)) {
  219. $share_url = API_DOMAIN.'/'.$short_link;
  220. }else{
  221. $share_url = API_DOMAIN.'/game_promotion/index/game_id/'.$value['id'].'/channel_id/'.$value['channel_id'].'/package_type/'.$value['package_type'];
  222. }
  223. $list['data'][$key]['down_url'] = APK_DOWN_DOMAIN.'/sygame/'.$value['pinyin'].'/'.$value['filename'];
  224. $list['data'][$key]['share_url'] = $share_url;
  225. if ($value['upload_status'] == 0) {
  226. $list['data'][$key]['upload_status'] = time() - $value['update_time'] >= PACKAGE_TIME_OUT?2:0;
  227. }
  228. }
  229. return json(['data'=>$list,'code'=>20000,'msg'=>'获取游戏列表成功']);
  230. }
  231. /**
  232. * 批量注册列表
  233. * @param string $value [description]
  234. */
  235. public function myBatchLog()
  236. {
  237. $page = input('page',1);
  238. $list_rows = input('pageSize',10);
  239. $gameid = input('gameid');
  240. $status = input('status');
  241. $create_time = input('create_time');
  242. $where = [];
  243. if (! empty($gameid)) {
  244. $where['log.game_id'] = $gameid;
  245. }
  246. if (! empty($status) || $status==='0') {
  247. $where['log.status'] = $status;
  248. }
  249. if (! empty($create_time)) {
  250. $where['log.create_time'] = [['>=', strtotime($create_time .'0:0:0')],['<=', strtotime(date($create_time .'23:59:59'))]];
  251. }
  252. $list = Db::name('nw_batch_reg')
  253. ->alias('log')
  254. ->join('cy_game game', 'log.game_id = game.id')
  255. ->field('log.id as log_id,log.tal_cnt,log.status,FROM_UNIXTIME(log.create_time) as create_time,log.channel_id,log.remark,game.name')
  256. ->where($where)
  257. ->where(['channel_id'=>$this->_channelId,'game.game_kind'=>2])
  258. ->where("game.is_default = 0 and game.cooperation_status != 3")
  259. ->order('log.create_time desc')
  260. ->paginate(['list_rows'=>$list_rows,'page'=>$page])->toArray();
  261. $gameList = model('Common/Game')->getAllByCondition('id,name',['game_kind'=>2,'cooperation_status'=>['NOT IN',[0,3]]],'','self');
  262. return json(['data'=>$list,'code'=>20000,'gameList'=>$gameList,'msg'=>'获取批量注册记录成功']);
  263. }
  264. /**
  265. * 批量注册具体数据列表
  266. * @param string $value [description]
  267. */
  268. public function myBatchLogList()
  269. {
  270. $log_id = input('log_id',0);
  271. $page = input('page',1);
  272. $list_rows = input('pageSize',10);
  273. if (empty($log_id) || !isset($log_id)) {
  274. return json(['data'=>'','code'=>10023,'msg'=>'log_id参数错误']);
  275. }
  276. $list = Db::name('nw_batch_reg_log')->alias('log')
  277. ->field('log.id,log.account,log.status,log.channel_id,game.name')
  278. ->where(['log.log_id'=>$log_id,'log.channel_id'=>$this->_channelId])
  279. ->join('cy_game game', 'log.game_id = game.id')
  280. ->where("game.is_default = 0 and game.cooperation_status != 3")
  281. ->paginate(['list_rows'=>$list_rows,'page'=>$page])->toArray();
  282. return json(['data'=>$list,'code'=>20000,'msg'=>'获取批量注册详情成功']);
  283. }
  284. /**
  285. * 批量注册
  286. */
  287. public function doBatchReg()
  288. {
  289. if ($this->_level != 3) {
  290. return json(['data'=>'','code'=>10023,'msg'=>'只有推广员能增加账号!']);
  291. }
  292. $game_id = input('game_id');
  293. $str = input('account_str');
  294. if (empty($game_id) || !isset($game_id)) {
  295. return json(['data'=>'','code'=>10023,'msg'=>'game_id参数错误']);
  296. }
  297. $str = array_filter(explode(',', $str));
  298. if (count($str)>=100) {
  299. return json(['data'=>'','code'=>10025,'msg'=>'批量注册一次性最多支持100条账号注册']);//校验长度
  300. }
  301. foreach ($str as $key => $value) {
  302. //校验账号规则
  303. if (!preg_match('/^[a-zA-Z]{1}[a-zA-Z0-9]{5,19}$/i',$value)) {
  304. unset($str[$key]);
  305. }
  306. }
  307. $str = array_values($str);
  308. $where = [];
  309. // $where['gameid'] = $game_id;
  310. $where['username'] = ['in',$str];
  311. $accountList = Db::name('cy_memberstwo')->where($where)-> column('username');//取出重复的值
  312. if ($accountList) {//重复的情况下去除重复反馈给前端
  313. $str = array_diff($str, $accountList);
  314. $msg = implode(',', $accountList);
  315. return json(['data'=>implode(',', $str),'code'=>20000,'msg'=>'账号:'.$msg.'重复以去除,请确认其他账号是否继续创建','type'=>1]);//校验长度
  316. }
  317. // 判断该游戏是否处于白名单状态,若是,则判断是否有分包记录,没有的话,禁止注册关联
  318. if(!empty($game_id)) {
  319. $game_info = model('game')->where(['id' => $game_id])->find();
  320. // 处于白名单状态
  321. if(2 == $game_info['cooperation_status']) {
  322. $conditions = array();
  323. $conditions['gameid'] = $game_id;
  324. $conditions['channel_id'] = $this->_channelId;
  325. $subPackageCnt = model('SdkGameList')->where($conditions)->count();
  326. if(!$subPackageCnt){
  327. return json(['data'=>'','code'=>10023,'msg'=>'该游戏处于白名单状态,无法新增']);
  328. }
  329. }
  330. }
  331. //都符合的情况下写入数据
  332. Db::startTrans();
  333. try {
  334. //1. 添加到批次表
  335. $channelModel = Db::name('nw_batch_reg');
  336. $log_id = $channelModel->insertGetId([
  337. 'game_id' => $game_id,
  338. 'status' => 1,
  339. 'create_time' => NOW_TIMESTAMP,
  340. 'tal_cnt' => count($str),
  341. 'channel_id' => $this->_channelId
  342. ]);
  343. if (!$log_id) {
  344. return json(['data'=>'','code'=>10015,'msg'=>"添加批次信息失败"]);
  345. }
  346. $cont = [];
  347. foreach ($str as $key => $value) {
  348. $cont[$key]['game_id'] = $game_id;
  349. $cont[$key]['account'] = $value;
  350. $cont[$key]['log_id'] = $log_id;
  351. $cont[$key]['status'] = 1;
  352. $cont[$key]['channel_id'] = $this->_channelId;
  353. }
  354. $res = Db::name('nw_batch_reg_log')->insertAll($cont);
  355. if (!$res) {
  356. return json(['data'=>'','code'=>10015,'msg'=>"添加批次信息日志失败"]);
  357. }
  358. $data = [];
  359. foreach ($str as $key => $value) {
  360. $data['reg_time'] = NOW_TIMESTAMP;
  361. $data['login_time'] = NOW_TIMESTAMP;
  362. $data['ip'] = request()->ip();
  363. $data['gameid'] = $game_id;
  364. $data['username'] = $value;
  365. $data['password'] = auth_code('b123456', "ENCODE", Env::get('auth_key'));
  366. $data['channel_id'] = $this->_channelId;
  367. Db::startTrans();
  368. try {
  369. $member_id = Db::table('cy_members')->insertGetId($data);
  370. if ($member_id) {
  371. // 插入玩家历史记录
  372. Db::table('cy_member_history')->insert([
  373. 'userid' => $member_id,
  374. 'password' => auth_code('b123456', "ENCODE", Env::get('auth_key')),
  375. 'ip' => request()->ip(1),
  376. 'create_time' => NOW_TIMESTAMP
  377. ]);
  378. //插入用户扩展记录
  379. Db::table('cy_memberstwo')->insert([
  380. 'userid' => $member_id,
  381. 'username' => $data['username'],
  382. 'realname' => -1,
  383. 'idcard' => -1,
  384. 'create_time' => NOW_TIMESTAMP
  385. ]);
  386. // 登录时 绑定该游戏的归属渠道
  387. Db::table('cy_member_channel_game_rel')->insert([
  388. 'member_id' => $member_id,
  389. 'channel_id' => $data['channel_id'],
  390. 'game_id' => $data['gameid'],
  391. 'mcgr_createtime' => time(),
  392. // 'update_time' => time(),
  393. 'mcgr_ip' => request()->ip()
  394. ]);
  395. } else {
  396. throw new Exception("注册失败!");
  397. }
  398. Db::commit();
  399. } catch (Exception $e) {
  400. Db::rollback();
  401. return json(['data'=>'','code'=>10015,'msg'=>"添加失败: " . $e->getMessage()]);
  402. }
  403. }
  404. Db::commit();
  405. } catch (\Exception $e) {
  406. Db::rollback();
  407. return json(['data'=>'','code'=>10015,'msg'=>"添加失败: " . $e->getMessage()]);
  408. }
  409. return json(['data'=>'','code'=>20000,'msg'=>"注册成功"]);
  410. }
  411. /**
  412. * 已接游戏备注
  413. * @param string $value [description]
  414. * @return [type] [description]
  415. */
  416. public function toEditGameLink()
  417. {
  418. $sdk_id = input('sdk_id');
  419. $data = [];
  420. $data['remark'] = $remark = input('remark');
  421. if (empty($sdk_id)) {
  422. return json(['data'=>$meue,'code'=>10021,'msg'=>'sdk_id参数错误']);
  423. }
  424. $res = model('SdkGameList')->update($data, ['id'=>$sdk_id]);
  425. if ($res) {
  426. return json(['data'=>'','code'=>20000,'msg'=>'修改成功']);
  427. }else{
  428. return json(['data'=>'','code'=>10022,'msg'=>'修改失败']);
  429. }
  430. }
  431. /**
  432. * 获取游戏区服信息
  433. * @param string $value [description]
  434. * @return [type] [description]
  435. */
  436. public function getSeverList()
  437. {
  438. $gameId = input('game_id', 0, 'intval');
  439. $res = Db::name('nw_game_server')->field('servername,serverid')->where(['game_id'=>$gameId])->select();
  440. return json(['data'=>$res,'code'=>20000,'msg'=>'获取区服列表成功']);
  441. }
  442. // 获取游戏名称
  443. protected function _getGameName($gameId)
  444. {
  445. return model('Game')->where(['id' => $gameId])->value('name');
  446. }
  447. // 所有游戏类型
  448. protected function _getType()
  449. {
  450. return Db::table('cy_gametype')->field("id as 'index',name as 'value'")->select();
  451. }
  452. // 所有游戏题材
  453. protected function _getSubject()
  454. {
  455. return Db::table('cy_gamesubject')->field("id as 'index',name as 'value'")->select();
  456. }
  457. // 公共搜索条件
  458. protected function _getCondition($self = 'false')
  459. {
  460. $status = input('status');
  461. $platform = input('platform');
  462. $type = input('type', 0, 'intval');
  463. $subject = input('subject', 0, 'intval');
  464. $gameName = input('gameName', '', 'trim');
  465. $gameid = input('gameid');
  466. if ($self) {
  467. $package_type = input('package_type','');
  468. }
  469. $condition = [];
  470. $condition['game.game_kind'] = 2;
  471. if (! empty($gameName)) {
  472. $condition['game.name'] = ['LIKE', '%' . $gameName . '%'];
  473. }
  474. if (! empty($subject)) {
  475. $condition['game.subject'] = $subject;
  476. }
  477. if (! empty($type)) {
  478. $condition['game.type'] = $type;
  479. }
  480. if (is_numeric($status)) {
  481. $condition['game.cooperation_status'] = (int)$status;
  482. } else {
  483. $condition['game.cooperation_status'] = ['IN', [1, 2]];
  484. }
  485. if (is_numeric($platform)) {
  486. $condition['info.platform'] = (int)$platform;
  487. }
  488. //包体类型
  489. if ($package_type!='') {
  490. $condition['sdk.package_type'] = (int)$package_type;
  491. }
  492. return $condition;
  493. }
  494. /**
  495. * 获取游戏列表
  496. * @return mixed
  497. */
  498. public function gameList(){
  499. return model('Common/Game')->getAllByCondition('id,name',['game_kind'=>2,'cooperation_status'=>['neq',0]],'','self');
  500. }
  501. /**
  502. * 获取所有游戏区服列表
  503. * @return mixed
  504. */
  505. public function gameServerList(){
  506. $page = input('page',1);
  507. $pageSize = input('pageSize',10);
  508. $game_id = input('game_id');
  509. $server_id = input('server_id');
  510. $where = [];
  511. if (!empty($game_id)) {
  512. $where['game.id'] = $game_id;
  513. }
  514. if (!empty($server_id)) {
  515. $where['server.serverid'] = $server_id;
  516. }
  517. $res = Db::name('cy_game')->alias('game')
  518. ->join('nw_game_server server','game.id = server.game_id')
  519. ->field(['game.id as game_id','game.name as game_name','servername','server.serverid as server_id'])
  520. ->where(['game_kind'=>2])
  521. ->where($where)
  522. ->where("game.is_default = 0 and game.cooperation_status != 3")
  523. ->paginate($pageSize,false,['page'=>$page])->toArray();
  524. if ($res['data']) {
  525. $rank = ($page-1)*10;
  526. foreach ($res['data'] as $key => $value) {
  527. $rank ++ ;
  528. $res['data'][$key]['rank'] = $rank;
  529. }
  530. }
  531. return json(['data'=>$res,'code'=>20000,'msg'=>'获取游戏列表成功']);
  532. }
  533. /**
  534. * 下载excel模板
  535. * @return [type] [description]
  536. */
  537. public function download()
  538. {
  539. $type = input('type',1);
  540. switch ($type) {
  541. case '1'://玩家模板
  542. return json(['data'=>"https://static.weilongwl.com/xls/2020091615435f61c21a56abb.xls",'code'=>20000,'msg'=>'下载链接']);
  543. break;
  544. case '2'://子会长模板
  545. return json(['data'=>"https://static.weilongwl.com/xls/2020091615395f61c11895e73.xls",'code'=>20000,'msg'=>'下载链接']);
  546. break;
  547. default:
  548. return json(['data'=>'','code'=>15000,'msg'=>'参数错误']);
  549. break;
  550. }
  551. }
  552. }