Gameaid.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /** 礼包 -- 控制器
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/10/24
  6. * Time: 10:47
  7. */
  8. namespace app\home\controller;
  9. use think\Db;
  10. use think\Config;
  11. use app\common\model\GameHome as GameModel;
  12. class Gameaid extends Home
  13. {
  14. private $_type = [
  15. '1' => '加速版',
  16. '2' => '跳过版',
  17. ];
  18. /**
  19. * 初始化操作
  20. */
  21. protected function _initialize()
  22. {
  23. parent::_initialize();
  24. }
  25. /**
  26. * 加速游戏
  27. */
  28. public function index(){
  29. $where = [
  30. 'b.is_show' => 1,
  31. 'b.cooperation_status' => ['in',[1,2]]
  32. ];
  33. $list = Db::connect(config('database_slave'))->table('cy_gameaid')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->alias('a')
  34. ->join('cy_game b','b.id = a.gameid')
  35. ->join('cy_gameinfo info', 'b.id=info.game_id', 'left')
  36. ->field('a.*,b.nickname,info.mobileicon,b.pinyin')
  37. ->where($where)
  38. ->order('a.create_time desc')
  39. ->paginate(10, false, array('query' => input('get.')))
  40. ->each(function ($item, $key){
  41. $item['filename'] = Db::connect(config('database_slave'))->table('cy_sdkgamelist')->where(['package_type'=>1,'gameid'=>$item['gameid'],'channel_id'=>MEMBER_DEFAULT_CHANNEL_ID])->value('filename');
  42. $item['mobileicon'] = getGameIcon($item['mobileicon']);
  43. return $item;
  44. });
  45. $adInfo = model('Ad')->getPageAd();
  46. $this->assign('list',$list);
  47. $this->assign('type',$this->_type);
  48. $this->assign('adInfo',$adInfo);
  49. $this->assign('page',$list->render());
  50. return $this->fetch();
  51. }
  52. /**
  53. * 光环包下载
  54. */
  55. public function download() {
  56. $gameModel = new GameModel;
  57. $gameid = intval(input('id'));
  58. if(!$gameid) {
  59. $this->_abort404();
  60. }
  61. $detail = $gameModel->cache(Config::get('QUERY_RESULT_CACHE_TIME'))
  62. ->alias('game')
  63. ->join('cy_gameinfo info', 'game.id = info.game_id','left')
  64. ->join('cy_gametype t', 'game.type = t.id','left')
  65. ->join('cy_gamesubject s', 'game.subject = s.id','left')
  66. ->join('cy_sdkgamelist sdk', 'game.id=sdk.gameid and sdk.package_type=1 and sdk.upload_status=1 and sdk.channel_id='.MEMBER_DEFAULT_CHANNEL_ID,'left')
  67. ->field('game.id,game.nickname,game.power,info.androidurl,game.pinyin,info.mobileicon,game.type,game.subject,info.developer,info.bigimage,t.name as typename,s.name as subjectname,info.description,sdk.filename')
  68. ->where(['game.id'=>$gameid,'game.cooperation_status' => ['in','0,1,2'],'game.is_show' => 1])
  69. ->find();
  70. if ( empty($detail)) {
  71. // throw new Exception("游戏不存在或无效");
  72. $this->_abort404();
  73. }
  74. else{
  75. /*$detail['icon'] = getGameIcon($detail['mobileicon']);
  76. $detail['size'] = getSize($detail);
  77. $detail['version'] = getVersion($detail);
  78. $detail['updatetime'] = getUpdateTime($detail);*/
  79. $detail['download'] = getDownload($detail);
  80. /* $detail['screenShot'] = getScreenShot($detail['bigimage']);
  81. $detail['typename'] = getTypename($detail['typename']);
  82. $detail['subjectname'] = getSubjectname($detail['subjectname']);
  83. $detail['developer'] = getDeveloper($detail['developer']);*/
  84. }
  85. $this->assign('detail',$detail);
  86. return $this->fetch();
  87. }
  88. }