Service.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?php
  2. /** 开服开测 -- 控制器
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/10/24
  6. * Time: 10:47
  7. */
  8. namespace app\mobile\controller;
  9. use think\Db;
  10. use think\Config;
  11. class Service extends Mobile
  12. {
  13. protected $serstatus = [
  14. 1 => '预告',
  15. 2 => '开服',
  16. 3 => '删档内测',
  17. 4 => '不删档内测',
  18. 5 => '公测'
  19. ];
  20. /**
  21. * 初始化操作
  22. */
  23. protected function _initialize()
  24. {
  25. parent::_initialize();
  26. }
  27. /**
  28. * 开服
  29. */
  30. public function index(){
  31. $this->getList(0);
  32. $this->assign('kfkc','kf');
  33. return $this->fetch();
  34. }
  35. /**
  36. * 开测
  37. */
  38. public function kc(){
  39. $this->getList(1);
  40. $this->assign('kfkc','kc');
  41. return $this->fetch('index');
  42. }
  43. /**
  44. * 开服、开测--列表
  45. */
  46. public function getList($type) {
  47. /*$type = $this->request->param('t',1,'intval');*/
  48. if (!in_array($type,[0,1])) $type = 0;
  49. $kfkc = '';
  50. if ($type == 0){
  51. $kfkc = '开服';
  52. }else{
  53. $kfkc = '开测';
  54. }
  55. $where = [
  56. 'a.type'=>$type,
  57. 'a.isdelete'=>0,
  58. 'b.is_show' => 1,
  59. 'b.cooperation_status' => ['in',[0,1,2]]
  60. ];
  61. $nowtime = NOW_TIMESTAMP;
  62. $list = model('ServerInfo')->cache(Config::get('QUERY_RESULT_CACHE_TIME'))->alias('a')
  63. ->join('cy_game b','b.id = a.gameid')
  64. ->join('cy_gameinfo info', 'b.id=info.game_id', 'left')
  65. ->join('cy_gamesubject s', 'b.subject=s.id', 'left')
  66. ->join('cy_gametype t', 'b.type=t.id', 'left')
  67. ->join('cy_sdkgamelist sdk', 'b.id=sdk.gameid and sdk.package_type=0 and sdk.upload_status=1 and sdk.channel_id='.MEMBER_DEFAULT_CHANNEL_ID,'left')
  68. ->field('a.*,info.mobileicon,info.androidurl,info.platform,b.nickname,b.pinyin,t.name as typename, s.name as subjectname,sdk.filename')
  69. ->where($where)
  70. ->where("( ( a.sertime > {$nowtime} and a.sercertype = 1 ) or a.sercertype = 2 )")
  71. ->order('a.sercertype asc,a.sertime asc')
  72. ->paginate(10, false, array('query' => input('get.')));
  73. $arr = [
  74. 'td' => [] ,
  75. 'tm' => [] ,
  76. ];
  77. $td = date("Y-m-d");
  78. $tm = date("Y-m-d",strtotime("+1 day"));
  79. $datTime = strtotime(date("Y-m-d 23:59:59",strtotime("+1 day")));
  80. foreach ($list as &$v){
  81. $v['mobileicon'] = "http://static.46yx.com/".$v['mobileicon'];
  82. $v['filename'] = model('SdkGameList')->where(['package_type'=>0,'gameid'=>$v['gameid'],'channel_id'=>MEMBER_DEFAULT_CHANNEL_ID])->value('filename');
  83. $gameInfo = array();
  84. $gameInfo['id'] = $v['gameid'];
  85. $gameInfo['pinyin'] = $v['pinyin'];
  86. $gameInfo['androidurl'] = $v['androidurl'];
  87. $gameInfo['platform'] = $v['platform'];
  88. $v['typename'] = getTypename($v['typename']);
  89. $v['subjectname'] = getSubjectname($v['subjectname']);
  90. $v['size'] = getSize($gameInfo);
  91. $v['subscribe'] = 1; // 预约游戏
  92. $v['serstatusName'] = isset($this->serstatus[$v['serstatus']]) ? $this->serstatus[$v['serstatus']] : '';
  93. $v['libaonum'] = model('Gift')->where(['isdelete'=>0,'gameid'=>$v['gameid'],'endtime'=>['gt',NOW_TIMESTAMP]])->where('total > used')->count('id');
  94. if ($v['sercertype'] == 1 && $td == date("Y-m-d",$v['sertime']) ){
  95. $arr['td'][] = $v;
  96. if( $v['sertime'] <= $nowtime + 60*60){
  97. $v['subscribe'] = 0;
  98. }
  99. }
  100. if ($v['sercertype'] == 1 && $tm == date("Y-m-d",$v['sertime']) ){
  101. $arr['tm'][] = $v;
  102. }
  103. if ($v['sercertype'] == 1 && $datTime < $v['sertime'] ){
  104. $arr[date('m月d日',$v['sertime']).$kfkc][] = $v;
  105. }
  106. if ($v['sercertype'] == 2){
  107. $arr['fn'][] = $v;
  108. $v['subscribe'] = 0;
  109. }
  110. $v['hsTime'] = date('H:i',$v['sertime']);
  111. }
  112. empty($list->total()) ? $arr=[] : [];
  113. if ($this->request->isAjax()) $this->jsonResult($arr,1);
  114. $this->assign('today',date('m月d日',$nowtime));
  115. $this->assign('tomorrow',date("m月d日",strtotime("+1 day")));
  116. if($type==0){
  117. $seo['title'] = '最新手游开服表_麻花网络';
  118. }
  119. else{
  120. $seo['title'] = '最新手游开测表_麻花网络';
  121. }
  122. $seo['keywords'] = '手机游戏开服表,手机游戏开测表';
  123. $seo['description'] = '麻花网络提供最新手机游戏开服表和手机游戏开测表,为您获取第一手开服开测信息,让您不错过任意想玩的手机游戏。';
  124. $this->assign('seo',$seo);
  125. $this->assign('list',$arr);
  126. $this->assign('listobj',$list);
  127. $this->assign('page',$list->render());
  128. }
  129. /**
  130. * 订阅游戏
  131. * code = 0 非法操作
  132. * code = 1 订阅成功
  133. * code = 2 用户未登录
  134. * code = 3 未绑定手机号
  135. * code = 4 不可重复订阅
  136. * code = 5 离开服开测时间不足1小时,无法预约
  137. */
  138. public function subscribe(){
  139. $id = $this->request->param('id',0,'intval');
  140. $type = $this->request->param('type','');
  141. if (empty($id) || empty($type) || !in_array($type,['kf','kc'])) $this->error('非法操作!');
  142. $msg = '';
  143. if ($type == 'kf'){
  144. $type = 1;
  145. $msg = '开服';
  146. }else{
  147. $type = 2;
  148. $msg = '开测';
  149. }
  150. $userid = session('front_userid');
  151. if (!$userid){
  152. $this->jsonResult(getMobileEncodeUrl('login'),2,'请先登录!');
  153. }
  154. //判断用户是否订阅
  155. $where = array('userid'=>$userid,'related_id'=>$id);
  156. if( !empty( Db::table('cy_subscribelog')->where($where)->find() ) ) $this->jsonResult([],4,'您已经预约过该'.$msg.'信息。');
  157. // 判断开服开测时间
  158. $info = model('ServerInfo')->where('id',$id)->find();
  159. if (empty($info) || $info['sertime'] < NOW_TIMESTAMP + 60*60) $this->jsonResult([],5,'离'.$msg.'时间不足1小时,无法预约。');
  160. //获取用户手机号
  161. $mobile = model('Members')->where(array('id'=>$userid))->value('mobile');
  162. if(empty($mobile)) $this->jsonResult(getMobileAccountUrl(2),3,'请先绑定手机号!');
  163. $content = model('Subscribelog')->getContent($type,$id);
  164. $data = [
  165. 'userid' => $userid ,
  166. 'username' => session('front_account') ,
  167. 'content' => $content ,
  168. 'mobile' => $mobile ,
  169. 'related_id' => $id ,
  170. 'type' => $type ,
  171. 'create_time' => NOW_TIMESTAMP
  172. ];
  173. $res = model('Subscribelog')->insertGetId($data);
  174. if ($res) $this->jsonResult([],1,'您已成功预约该'.$msg.'信息,届时会以短信形式通知,请留意。');
  175. $this->jsonResult([],0,'非法操作。');
  176. }
  177. }