Vipinfo.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. /**
  3. * 游戏管理控制器
  4. */
  5. namespace app\guildapi\controller;
  6. use think\Db;
  7. use think\Exception;
  8. use app\common\logic\Member as MemberService;
  9. class Vipinfo extends Guild
  10. {
  11. //游戏平台
  12. protected $_platform = [
  13. 0 => '安卓',
  14. 1 => 'IOS'
  15. ];
  16. //资讯类型
  17. protected $_infoType = [
  18. 1 => '资讯',
  19. 2 => '麻花网络',
  20. 3 => '测评',
  21. 4 => '攻略',
  22. 5 => '视频'
  23. ];
  24. protected function _initialize()
  25. {
  26. parent::_initialize();
  27. $this->articleModel = Db::name('cy_article');
  28. $this->timeLine = config('ARTICLE_AND_CHANNEL_TIMELINE');
  29. $this->_channelid = session('guild_info')['channel_id'];
  30. $this->_menuLimit = model('Channel')->where(['id'=>$this->_channelid])->field('point_show,taptap,parent_id')->find();
  31. }
  32. /**
  33. * 获取最新5条公告
  34. * @return [type] [description]
  35. */
  36. public function getArticleList()
  37. {
  38. $list_rows = input('pageSize',10);
  39. $page = input('page',1);
  40. if (!isset($list_rows) || empty($list_rows)) {
  41. $list_rows = 10;
  42. }
  43. //公告 取为5条
  44. $articleList = Db::name('nw_game_article')->alias('a')
  45. ->where(['a.is_show' => 1, 'a.show_time' => ['LT', request()->time()] ])
  46. ->order('a.create_time', 'desc')
  47. ->paginate(['list_rows'=>$list_rows,'page'=>$page])->toArray();
  48. $readList = Db::name('nw_game_article_read')
  49. ->where(['channel_id'=>$this->_channelid])
  50. ->column('game_article_id','id');
  51. if ($articleList) {
  52. foreach ($articleList['data'] as $key => $value) {
  53. $articleList['data'][$key]['show_time'] = date("Y-m-d",$value['show_time']);
  54. if (in_array($value['id'], $readList)) {
  55. $articleList['data'][$key]['status'] = 1;
  56. }else{
  57. $articleList['data'][$key]['status'] = 0;
  58. }
  59. }
  60. return json(['data'=>$articleList,'code'=>20000,'msg'=>'获取公告成功']);
  61. }
  62. return json(['data'=>[],'code'=>20000,'msg'=>'暂无公告']);
  63. }
  64. /**
  65. * 获取所有未读公告
  66. * @return [type] [description]
  67. */
  68. public function getUnreadArticleList()
  69. {
  70. //所有公告
  71. $articleList = Db::name('nw_game_article')->alias('a')
  72. ->where(['a.is_show' => 1, 'a.show_time' => ['LT', request()->time()] ])
  73. ->order('a.create_time', 'desc')->select();
  74. $readList = Db::name('nw_game_article_read')
  75. ->where(['channel_id'=>$this->_channelid])
  76. ->column('game_article_id','id');
  77. $out = [];
  78. foreach ($articleList as $key => $value) {
  79. if (!in_array($value['id'], $readList)) {
  80. $out[] = $value;
  81. }
  82. }
  83. return json(['data'=>$out,'code'=>20000,'msg'=>'获取未读公告成功']);
  84. }
  85. /**
  86. * 查看公告
  87. * @return [type] [description]
  88. */
  89. public function seeAoYouNotice(){
  90. $id = input('id',0,'intval');
  91. if (empty($id)){
  92. return json(['data'=>[],'code'=>10017,'msg'=>'公告参数错误']);
  93. }
  94. // 记录 该渠道已读了该 游戏活动
  95. $data = ['game_article_id'=>$id,'channel_id'=>$this->_channelid];
  96. $res = Db::name('nw_game_article_read')->where($data)->find();
  97. if (empty($res)){
  98. $data['create_time'] = time();
  99. Db::name('nw_game_article_read')->insertGetId($data);
  100. return json(['data'=>[],'code'=>20000,'msg'=>'添加阅读记录成功']);
  101. }
  102. return json(['data'=>[],'code'=>20000,'msg'=>'已阅读过该公告']);
  103. }
  104. /**
  105. * 获取资讯列表
  106. * @return [type] [description]
  107. */
  108. public function getInfoList()
  109. {
  110. $list_rows = input('pageSize',10);
  111. $page = input('page',1);
  112. $where = $this->_getCondition();
  113. $infoList = Db::name('cy_article')->alias('article')->field(['article.zhiding','article.gameId','article.id','article.title','article.type','article.create_time','content.content'])->where($where)->join('cy_content content', 'article.id=content.id','left')->order('article.zhiding desc,article.id desc')->paginate(['list_rows'=>$list_rows,'page'=>$page])->toArray();
  114. if ($infoList) {
  115. foreach ($infoList['data'] as $key => $value) {
  116. $infoList['data'][$key]['create_time'] = date("Y-m-d H:i:s",$value['create_time']);
  117. $infoList['data'][$key]['type'] = $this->_infoType[$value['type']];
  118. }
  119. return json(['data'=>$infoList,'code'=>20000,'msg'=>'获取资讯成功','dataList'=>$this->gameList()]);
  120. }
  121. return json(['data'=>[],'code'=>20000,'msg'=>'暂无资讯','dataList'=>$this->gameList()]);
  122. }
  123. /**
  124. * 获取搜索菜单列表
  125. * @param string $value [description]
  126. */
  127. public function getInfoMenu()
  128. {
  129. $meue = [];
  130. $meue['game_platform'] = $this->_platform;
  131. $meue['infoType'] = $this->_infoType;
  132. $meue['game_list'] = $this->gameList();
  133. return json(['data'=>$meue,'code'=>20000,'msg'=>'获取搜索菜单列表成功']);
  134. }
  135. /**
  136. * 获取游戏列表
  137. * @return mixed
  138. */
  139. public function gameList(){
  140. return model('Common/Game')->getAllByCondition('id,name',['game_kind'=>1,'cooperation_status'=>['neq',0]],'','self');
  141. }
  142. // 公共搜索条件
  143. protected function _getCondition()
  144. {
  145. $type = input('type', 0, 'intval');//资讯类型
  146. $gameid = input('gameid', 0, 'intval');//游戏id
  147. $title = input('title', '', 'trim');//标题
  148. // $status = input('status', 0, 'intval');//阅读类型
  149. $condition = [];
  150. $condition['isdelete'] = 0;
  151. if (! empty($title)) {
  152. $condition['article.title'] = ['LIKE', '%' . $title . '%'];
  153. }
  154. if (! empty($type)) {
  155. $condition['article.type'] = $type;
  156. }
  157. // if (! empty($status)) {
  158. // $condition['article.type'] = $status;
  159. // }
  160. if (! empty($gameid)) {
  161. $condition['article.gameid'] = $gameid;
  162. }
  163. return $condition;
  164. }
  165. public function getChannelInfo(){
  166. // 渠道id
  167. $channelid = $this->_channelid;
  168. // 获取渠道信息
  169. $channelInfo = Db::name('nw_channel')->where(['id'=>$channelid])->find();
  170. return $channelInfo;
  171. }
  172. public function getGameList(){
  173. return Db::name('cy_game')->field('id,name')->order('name asc')->select();
  174. }
  175. protected function _getTypy(){
  176. return Db::table('cy_gametype')->column('name', 'id');
  177. }
  178. }