| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?php
- /**
- * 一些公用模板控制器
- */
- namespace app\home\controller;
- use app\common\model\ServerInfo;
- use app\common\model\GameHome as Game;
- use app\common\model\Gift;
- use think\Db;
- use think\Config;
- class Layout extends Home
- {
- // 游戏类型
- protected $_gameType = [
- 1 => '角色' ,
- 2 => '动作' ,
- 3 => '休闲' ,
- 4 => '体育' ,
- 5 => '策略' ,
- 6 => '射击' ,
- 8 => '回合' ,
- 9 => '卡牌' ,
- 10 => '放置' ,
- 11 => '竞技' ,
- ];
- // 游戏题材:1仙侠|2武侠|3魔幻|4三国|5西游|6动漫|7传奇|8女生|9 3D|10战争
- protected $_gameSubjct = [
- 1 => '仙侠' ,
- 2 => '武侠' ,
- 3 => '魔幻' ,
- 4 => '三国' ,
- 5 => '西游' ,
- 6 => '动漫' ,
- 7 => '传奇' ,
- 8 => '女生' ,
- 9 => '3D' ,
- 10 => '战争' ,
- ];
-
- /**
- * *开服开测信息
- *
- */
- public function serverinfo() {
-
- $serverInfoModel= new ServerInfo;
- $GiftModel = new Gift();
-
- $gameids = []; //游戏ID
-
- // 开服
- $serverList = Db::connect(config('database_slave'))->table('cy_serverinfo')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->alias('s')
- ->join('cy_game g', 's.gameid=g.id', 'left')
- ->join('cy_sdkgamelist sdk', 'g.id=sdk.gameid and sdk.package_type=0 and sdk.upload_status=1 and sdk.channel_id='.MEMBER_DEFAULT_CHANNEL_ID,'left')
- ->field('s.gameid,g.nickname,s.sername,s.sertime,s.sercertype,g.id,g.pinyin,sdk.filename')
- ->where(['g.cooperation_status' => ['in','0,1,2'],'g.is_show' => 1,'s.type'=>0,'s.isdelete'=>0])
- ->where('s.sertime>'.time().' or s.sertime is null')
- ->order('s.sercertype asc,s.sertime asc')->limit(0,13)->select();
-
- foreach ( $serverList as &$game ) {
- $game['download'] = getDownload($game);
- }
- if(!empty($serverList)){
- $gameids = arrayColumnByObject($serverList, 'gameid');
- }
-
- //开测
- $testList = Db::connect(config('database_slave'))->table('cy_serverinfo')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->alias('s')
- ->join('cy_game g', 's.gameid=g.id', 'left')
- ->join('cy_sdkgamelist sdk', 'g.id=sdk.gameid and sdk.package_type=0 and sdk.upload_status=1 and sdk.channel_id='.MEMBER_DEFAULT_CHANNEL_ID,'left')
- ->field('s.gameid,g.nickname,s.serstatus,s.sertime,g.id,g.pinyin,sdk.filename')
- ->where(['g.cooperation_status' => ['in','0,1,2'],'g.is_show' => 1,'s.type'=>1,'s.isdelete'=>0,'s.sertime'=>['>',strtotime("today")]])
- ->order('s.sertime asc')->limit(0,12)->select();
- foreach ( $testList as &$game ) {
- $game['download'] = getDownload($game);
- }
- if(!empty($testList)){
- $testGameids = arrayColumnByObject($testList, 'gameid');
-
- $gameids = array_unique(array_merge($gameids,$testGameids));
- }
-
- //有效礼包
- $giftList = Db::connect(config('database_slave'))->table('cy_libaoinfo')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->field('id,gameid')
- ->where(['isdelete'=>0,'endtime'=>['>=', NOW_TIMESTAMP],'gameid'=>['in',$gameids]])
- ->where('total-used>0')
- ->column('id','gameid');
-
- $this->assign('serverList', $serverList);
- $this->assign('testList', $testList);
- $this->assign('giftList', $giftList);
- return view('layout/serverinfo');
- }
-
- /**
- * *手游排行
- *
- */
- public function gameRankList()
- {
- $gameModel = new Game;
-
- $gameids = [];
-
- $list = $gameModel->cache(Config::get('QUERY_RESULT_CACHE_TIME'))
- ->alias('game')
- ->join('cy_gameinfo info', 'game.id=info.game_id','left')
- ->join('cy_sdkgamelist sdk', 'game.id=sdk.gameid and sdk.package_type=0 and sdk.upload_status=1 and sdk.channel_id='.MEMBER_DEFAULT_CHANNEL_ID,'left')
- ->field('game.id,game.nickname,game.power,game.pinyin,info.mobileicon,game.type,game.subject,sdk.filename')
- ->where(['game.cooperation_status' => ['in','1,2'],'game.is_show' => 1])
- ->order('game.power desc')
- ->limit(0,10)->select();
- // var_dump($list);
- foreach ( $list as &$game ) {
- $game['mobileicon'] = STATIC_DOMAIN.$game['mobileicon'];
- $game['download'] = getDownload($game);
- }
- $this->assign('gameType', $this->_gameType);
- $this->assign('gameSubjct', $this->_gameSubjct);
- $this->assign('list', $list);
-
- return view('layout/game_rank_list');
- }
-
- /**
- * 推荐礼包
- *
- */
- public function recommendGiftList()
- {
- $GiftModel = new Gift();
-
- $giftList = Db::connect(config('database_slave'))->table('cy_libaoinfo')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->alias('gift')
- ->field('gift.id,gift.title,gift.total,gift.used,gift.endtime,info.mobileicon,g.nickname,gift.gameid')
- ->join('cy_gameinfo info', 'info.game_id = gift.gameid','left')
- ->join('cy_game g', 'gift.gameid=g.id', 'left')
- ->where(['gift.is_top'=> 1,'gift.isdelete'=>0,'gift.endtime'=>['>=', NOW_TIMESTAMP],'g.cooperation_status' => ['in','1,2'],'g.is_show' => 1])
- ->where('gift.total>gift.used')
- ->order('gift.create_time desc')
- ->limit(0,6)->select();
-
- if (!empty($giftList)) { // 标识玩家已领取的礼包
- foreach ($giftList as &$gift) {
- $gift['mobileicon'] = STATIC_DOMAIN.$gift['mobileicon'];
- // 剩余可领的数量占比
- $gift['percent'] = round(($gift['total'] - $gift['used']) / $gift['total'], 2) * 100;
- }
- }
-
- $this->assign('giftList', $giftList);
-
- return view('layout/recommend_gift_list');
- }
- }
|