OperationManagement.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. <?php
  2. /**
  3. * 运营管理控制器
  4. */
  5. namespace app\admin\controller;
  6. use app\common\model\Game as GameModel;
  7. use app\common\model\SdkGameList;
  8. use app\common\logic\SubPackage as SubChannel;
  9. use app\common\library\FileUpload;
  10. use think\Db;
  11. use think\Exception;
  12. class OperationManagement extends Admin
  13. {
  14. protected $gameModel;
  15. /**
  16. * 不进行父类的登录验证,所以增加构造方法重写了父类的初始化方法
  17. */
  18. protected function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->gameModel = new GameModel;
  22. }
  23. /**
  24. * 手游排行
  25. */
  26. public function gameRankList()
  27. {
  28. $where = [];
  29. //游戏名称
  30. if (input('request.name') != '') {
  31. $where['name'] = ['like', '%' . input('request.name', '', 'trim') . '%'];
  32. }
  33. //查询参数
  34. $param = input('get.');
  35. $list = $this->gameModel->field('id,name,power,power_stat,power_plus')
  36. ->where(['cooperation_status' => ['in', '1,2'],'is_show'=>1,'isdelete'=>0])
  37. ->where($where)
  38. ->order('power desc')
  39. ->paginate(10, false, array('query' => $param));
  40. $this->assign('list', $list);
  41. $this->assign('page', $list->render());
  42. return $this->fetch('game_rank_list');
  43. }
  44. /**
  45. * 手游排行编辑
  46. */
  47. public function gameRankEdit($id)
  48. {
  49. if(empty($id)){
  50. $this->error('游戏ID不能为空');
  51. }
  52. $info = $this->gameModel->field('id,name,power,power_stat,power_plus')
  53. ->where(['id' => $id])
  54. ->find();
  55. if(empty($info)){
  56. $this->error('游戏不存在');
  57. }
  58. if (request()->isPost()) {
  59. $data['power_plus'] = input('post.power_plus');
  60. $result = $this->validate($data, [
  61. ['power_plus', 'require|integer', '请输入修改热度|修改热度必须为整数']
  62. ]);
  63. if (true !== $result) {
  64. $this->error($result);
  65. }
  66. $data['power'] = Db::raw("power_stat+".$data['power_plus']);
  67. $update = $this->gameModel->save($data,['id'=>$id]);
  68. $this->success('手游排行编辑成功', 'gameRankList');
  69. }
  70. $this->assign('info', $info);
  71. return $this->fetch('game_rank_edit');
  72. }
  73. /**
  74. * 热搜列表
  75. */
  76. public function keywordsList()
  77. {
  78. $where = [];
  79. //游戏名称
  80. if (input('request.title') != '') {
  81. $where['title'] = ['like', '%' . input('request.title', '', 'trim') . '%'];
  82. }
  83. //查询参数
  84. $param = input('get.');
  85. $keywordsModel = Db::name('cy_keywords');
  86. $list = $keywordsModel->where($where)
  87. ->order('create_time desc')
  88. ->paginate(10, false, array('query' => $param))
  89. ->each(function ($item, $key){
  90. if ($item['type'] == 2){
  91. $item['title'] = Db::name('cy_game')->where('id',$item['title'])->value('name');
  92. }
  93. return $item;
  94. });
  95. $this->assign('list', $list);
  96. $this->assign('page', $list->render());
  97. return $this->fetch('keywords_list');
  98. }
  99. /**
  100. * 热搜词新增
  101. */
  102. public function keywordsCreate()
  103. {
  104. $keywordsModel = Db::name('cy_keywords');
  105. if (request()->isPost()) {
  106. $data['title'] = input('post.title');
  107. $data['type'] = input('post.type');
  108. $gameid = input('post.gameid');
  109. if ($data['type'] == 2){
  110. $data['title'] = $gameid;
  111. }
  112. $result = $this->validate($data, [
  113. ['title', 'require|max:50', '请输入热搜词名称|热搜词名称不能超过50个字符'],
  114. ['type', 'require|integer', '请输入热搜词类型|热搜词类型必须为整数']
  115. ]);
  116. if (true !== $result) {
  117. $this->error($result);
  118. }
  119. if ($data['type'] == 2){
  120. $res = $keywordsModel->where(['title'=>$data['title']])->find();
  121. if ($res) $this->error('已添加过该游戏');
  122. }
  123. $data['create_time'] = NOW_TIMESTAMP;
  124. $keywordsModel->insert($data);
  125. $this->success('热搜词新增成功', 'keywordsList');
  126. }
  127. $game_list = Db::name('cy_game')->field('id,name')->where(['is_show'=>1,'cooperation_status'=>['in',[1,2]]])->order('name asc')->select();
  128. $this->assign('game_list', $game_list);
  129. return $this->fetch('keywords_new');
  130. }
  131. /**
  132. * 热搜词编辑
  133. */
  134. public function keywordsEdit($id)
  135. {
  136. if(empty($id)){
  137. $this->error('热搜词ID不能为空');
  138. }
  139. $keywordsModel = Db::name('cy_keywords');
  140. $info = $keywordsModel->where(['id' => $id])->find();
  141. if(empty($info)){
  142. $this->error('热搜词不存在');
  143. }
  144. if (request()->isPost()) {
  145. $data['title']= input('post.title');
  146. $data['type'] = input('post.type');
  147. $gameid = input('post.gameid');
  148. if ($data['type'] == 2){
  149. $data['title'] = $gameid;
  150. }
  151. $result = $this->validate($data, [
  152. ['title', 'require|max:50', '请输入热搜词名称|热搜词名称不能超过50个字符'],
  153. ['type', 'require|integer', '请输入热搜词类型|热搜词类型必须为整数']
  154. ]);
  155. if (true !== $result) {
  156. $this->error($result);
  157. }
  158. if ($data['type'] == 2){
  159. $res = $keywordsModel->where(['title'=>$data['title'],'id'=>['neq',$id]])->find();
  160. if ($res) $this->error('已添加过该游戏');
  161. }
  162. $update = $keywordsModel->where(['id'=>$id])->update($data);
  163. $this->success('热搜词编辑成功', 'keywordsList');
  164. }
  165. $this->assign('info', $info);
  166. $game_list = Db::name('cy_game')->field('id,name')->where(['is_show'=>1,'cooperation_status'=>['in',[1,2]]])->order('name asc')->select();
  167. $this->assign('game_list', $game_list);
  168. return $this->fetch('keywords_edit');
  169. }
  170. /**
  171. * 热搜词删除
  172. */
  173. public function keywordsDel($id)
  174. {
  175. if(empty($id)){
  176. $this->error('热搜词ID不能为空');
  177. }
  178. $keywordsModel = Db::name('cy_keywords');
  179. if($keywordsModel->delete(['id'=>$id])){
  180. $this->success('热搜词删除成功', 'keywordsList');
  181. }
  182. else{
  183. $this->error('热搜词删除失败');
  184. }
  185. }
  186. /**
  187. * 广告列表
  188. */
  189. public function adList()
  190. {
  191. $where = [];
  192. $order = input('order','create_time desc','trim');
  193. if($order=='sort_desc'){
  194. $order = 'sort desc';
  195. }
  196. elseif($order=='sort_asc'){
  197. $order = 'sort asc';
  198. }
  199. else{
  200. $order = 'create_time desc';
  201. }
  202. //广告标题
  203. if (input('request.title') != '') {
  204. $where['title'] = ['like', '%' . input('request.title', '', 'trim') . '%'];
  205. }
  206. //投放位置
  207. if (input('request.type') != '') {
  208. $where['type'] = input('request.type');
  209. }
  210. //查询参数
  211. $param = input('get.');
  212. $adModel = Db::name('cy_ad');
  213. $list = $adModel->where($where)
  214. ->order($order)
  215. ->paginate(10, false, array('query' => $param));
  216. $this->assign('list', $list);
  217. $this->assign('page', $list->render());
  218. return $this->fetch('ad_list');
  219. }
  220. /**
  221. * 广告新增
  222. */
  223. public function adCreate()
  224. {
  225. $adModel = Db::name('cy_ad');
  226. if (request()->isPost()) {
  227. $data = ['title'=>input('post.title','','trim'),
  228. 'type' =>input('post.type'),
  229. 'url' =>input('post.url'),
  230. 'sort' =>input('post.sort')
  231. ];
  232. $result = $this->validate($data, [
  233. ['title', 'require|max:50', '请输入广告标题|广告标题不能超过50个字符'],
  234. ['type', 'require|integer', '请选择投放位置|投放位置必须为整数'],
  235. ['url', 'require|max:160', '请输入跳转地址|跳转地址不能超过160个字符'],
  236. ['sort', 'integer', '排序必须为整数']
  237. ]);
  238. if (true !== $result) {
  239. $this->error($result);
  240. }
  241. elseif (!request()->file('image')) {
  242. $this->error('广告图片不能为空! ');
  243. }
  244. $fileUpload = new FileUpload();
  245. // 1.校验
  246. $file_path = $fileUpload->set('allowExt', 'jpg,png')->set('maxsize', 5242880)->set('dir','image/aoyou/')->upload(request()->file('image'));
  247. if ($file_path) {
  248. $data['image'] = $file_path;
  249. } else {
  250. $this->error('广告图片' . $fileUpload->getError());
  251. }
  252. $data['create_time'] = NOW_TIMESTAMP;
  253. if($adModel->insert($data)){
  254. $this->success('广告新增成功', 'adList');
  255. }
  256. else{
  257. $this->error('广告新增失败');
  258. }
  259. }
  260. return $this->fetch('ad_new');
  261. }
  262. /**
  263. * 广告编辑
  264. */
  265. public function adEdit($id)
  266. {
  267. if(empty($id)){
  268. $this->error('广告ID不能为空');
  269. }
  270. $adModel = Db::name('cy_ad');
  271. $info = $adModel->where(['id' => $id])->find();
  272. if(empty($info)){
  273. $this->error('广告不存在');
  274. }
  275. if (request()->isPost()) {
  276. $data = ['title'=>input('post.title','','trim'),
  277. 'type' =>input('post.type'),
  278. 'url' =>input('post.url'),
  279. 'sort' =>input('post.sort')
  280. ];
  281. $result = $this->validate($data, [
  282. ['title', 'require|max:50', '请输入广告标题|广告标题不能超过50个字符'],
  283. ['type', 'require|integer', '请选择投放位置|投放位置必须为整数'],
  284. ['url', 'require|max:160', '请输入跳转地址|跳转地址不能超过160个字符'],
  285. ['sort', 'integer', '排序必须为整数']
  286. ]);
  287. if (true !== $result) {
  288. $this->error($result);
  289. }
  290. $fileUpload = new FileUpload();
  291. $file_path = $fileUpload->set('allowExt', 'jpg,png')->set('maxsize', 5242880)->set('dir','image/aoyou/')->upload(request()->file('image'));
  292. //广告图片上传出错时
  293. if(!empty(request()->file('image')) && empty($file_path))
  294. {
  295. $this->error('广告图片'.$fileUpload->getError());
  296. }
  297. if(!empty($file_path)){
  298. $data['image'] = $file_path;
  299. }
  300. $adModel->where(['id'=>$id])->update($data);
  301. $this->success('广告编辑成功', 'adList');
  302. }
  303. $this->assign('info', $info);
  304. return $this->fetch('ad_edit');
  305. }
  306. /**
  307. * 热搜词删除
  308. */
  309. public function adDel($id)
  310. {
  311. if(empty($id)){
  312. $this->error('广告ID不能为空');
  313. }
  314. $adModel = Db::name('cy_ad');
  315. if($adModel->delete(['id'=>$id])){
  316. $this->success('广告删除成功', 'adList');
  317. }
  318. else{
  319. $this->error('广告删除失败');
  320. }
  321. }
  322. /**
  323. * 光环助手游戏列表
  324. */
  325. public function gameAidList()
  326. {
  327. $where = [];
  328. //游戏名称
  329. if (input('request.gameid')) {
  330. $where['a.gameid'] = input('request.gameid');
  331. }
  332. //游戏类型
  333. if (input('request.type')) {
  334. $where['a.type'] = input('request.type');
  335. }
  336. //查询参数
  337. $param = input('get.');
  338. $gameaidModel = Db::name('cy_gameaid');
  339. $list = $gameaidModel->table('cy_gameaid a,cy_game g')
  340. ->field('g.name,a.id,a.type,a.url,a.create_time')
  341. ->where('a.gameid=g.id')->where($where)
  342. ->order('a.create_time desc')
  343. ->paginate(10, false, array('query' => $param));
  344. $gameList = model('Common/Game')->getAllByCondition('id,name',[],'','self');
  345. $this->assign('list', $list);
  346. $this->assign('page', $list->render());
  347. $this->assign('game_list', $gameList);
  348. return $this->fetch('gameaid_list');
  349. }
  350. /**
  351. * 光环助手游戏新增
  352. */
  353. public function gameAidCreate()
  354. {
  355. $gameaidModel = Db::name('cy_gameaid');
  356. if (request()->isPost()) {
  357. $data = ['gameid' =>input('post.gameid'),
  358. 'type' =>input('post.type'),
  359. 'url' =>input('post.url','','trim'),
  360. 'content' =>input('post.content')
  361. ];
  362. $result = $this->validate($data, [
  363. ['gameid', 'require|integer', '请选择游戏|游戏ID必须为整型'],
  364. ['type', 'require|integer', '请选择类型|类型必须为整数'],
  365. ['url', 'url|max:160', '请输入跳转地址|跳转地址格式不正确|跳转地址不能超过250个字符'],
  366. ]);
  367. if (true !== $result) {
  368. $this->error($result);
  369. }
  370. elseif($gameaidModel->where(['gameid'=>$data['gameid']])->find())
  371. {
  372. $this->error('该游戏已经存在不能重复添加');
  373. }
  374. $data['create_time'] = NOW_TIMESTAMP;
  375. if($gameaidModel->insert($data)){
  376. $this->success('新增成功', 'gameAidList');
  377. }
  378. else{
  379. $this->error('新增失败');
  380. }
  381. }
  382. $gameList = model('Common/Game')->getAllByCondition('id,name',[],'','self');
  383. $this->assign('game_list', $gameList);
  384. return $this->fetch('gameaid_new');
  385. }
  386. /**
  387. * 光环助手游戏编辑
  388. */
  389. public function gameAidEdit($id)
  390. {
  391. if(empty($id)){
  392. $this->error('ID不能为空');
  393. }
  394. $gameaidModel = Db::name('cy_gameaid');
  395. $info = $gameaidModel->where(['id' => $id])->find();
  396. if(empty($info)){
  397. $this->error('光环助手游戏不存在');
  398. }
  399. if (request()->isPost()) {
  400. $data = ['gameid' =>input('post.gameid'),
  401. 'type' =>input('post.type'),
  402. 'url' =>input('post.url','','trim'),
  403. 'content' =>input('post.content')
  404. ];
  405. $result = $this->validate($data, [
  406. ['gameid', 'require|integer', '请选择游戏|游戏ID必须为整型'],
  407. ['type', 'require|integer', '请选择类型|类型必须为整数'],
  408. ['url', 'url|max:160', '跳转地址格式不正确|跳转地址不能超过250个字符'],
  409. ]);
  410. if (true !== $result) {
  411. $this->error($result);
  412. }
  413. elseif($gameaidModel->where(['gameid'=>$data['gameid'],'id'=>['<>',$id]])->find())
  414. {
  415. $this->error('该游戏已经存在不能重复');
  416. }
  417. $gameaidModel->where(['id'=>$id])->update($data);
  418. $this->success('编辑成功', 'gameAidList');
  419. }
  420. $gameList = model('Common/Game')->getAllByCondition('id,name',[],'','self');
  421. $this->assign('game_list', $gameList);
  422. $this->assign('info', $info);
  423. return $this->fetch('gameaid_edit');
  424. }
  425. /**
  426. * 光环助手游戏删除
  427. */
  428. public function gameAidDel($id)
  429. {
  430. if(empty($id)){
  431. $this->error('ID不能为空');
  432. }
  433. $gameaidModel = Db::name('cy_gameaid');
  434. $sdkGameListModel = new SdkGameList;
  435. $subChannel = new SubChannel;
  436. $gameaidInfo = $gameaidModel->where(['id'=>$id])->find();
  437. if(!$gameaidInfo){
  438. $this->error('光环游戏助手记录不存在');
  439. }
  440. //分包记录
  441. $sdkGameList = $sdkGameListModel->field('gameid,filename,id')->where(['gameid'=>$gameaidInfo['gameid'],'package_type'=>1])->select();
  442. //删除光环记录
  443. $gameaidModel->delete(['id'=>$id]);
  444. if(!empty($sdkGameList)){
  445. foreach($sdkGameList as $value){
  446. //删除包体文件
  447. $subChannel->removePackageFile($gameaidInfo['gameid'], $value['filename']);
  448. //删除分包记录
  449. $sdkGameListModel->where(['id'=>$value['id'],'gameid'=>$gameaidInfo['gameid']])->delete();
  450. }
  451. }
  452. $this->success('删除成功', 'gameAidList');
  453. }
  454. /**
  455. * 开服开测订阅管理
  456. */
  457. public function subscribeList()
  458. {
  459. $where = [];
  460. $start_time = input('request.start_time');
  461. //游戏名称
  462. if (input('request.username')) {
  463. $where['sub.username'] = input('request.username');
  464. }
  465. //游戏名称
  466. if (input('request.gameid')) {
  467. $where['ser.gameid'] = input('request.gameid');
  468. }
  469. //通知类型
  470. if (input('request.type')) {
  471. $where['sub.type'] = input('request.type');
  472. }
  473. //发送状态
  474. if (input('request.is_send')!='') {
  475. $where['sub.is_send'] = input('request.is_send');
  476. }
  477. //短信状态
  478. if (input('request.is_del')!='') {
  479. $where['sub.is_del'] = input('request.is_del');
  480. }
  481. //开始时间和结束时间不为空时
  482. if ($start_time != '' && input('request.end_time') != '') {
  483. $where['sub.create_time'] = [
  484. ['>=', strtotime($start_time)],
  485. ['<=', strtotime(input('request.end_time').' 23:59:59')],
  486. ];
  487. } //开始时间不为空时
  488. elseif ($start_time!= '') {
  489. $where['sub.create_time'] = ['>=', strtotime($start_time)];
  490. } //结束时间不为空时
  491. elseif (input('request.end_time') != '') {
  492. $where['sub.create_time'] = ['<=', strtotime(input('request.end_time').' 23:59:59')];
  493. }
  494. // $where['sub.is_del'] = 0;
  495. //查询参数
  496. $param = input('get.');
  497. $list = Db::table('cy_subscribelog sub,cy_serverinfo ser,cy_game g')
  498. ->field('g.name,sub.id,sub.userid,sub.username,sub.mobile,sub.type,sub.is_del,sub.is_send,sub.send_time,sub.create_time,ser.sername,ser.sertime,ser.serstatus,ser.gameid')
  499. ->where('sub.related_id=ser.id and ser.gameid=g.id')->where($where)
  500. ->order('sub.create_time desc')
  501. ->paginate(10, false, array('query' => $param));
  502. $tmpGameList = model('Common/Game')->getAllByCondition('id,name');
  503. $gameList = array();
  504. foreach ($tmpGameList as $game) {
  505. $gameList[ $game['id']] = $game;
  506. }
  507. $this->assign('list', $list);
  508. $this->assign('page', $list->render());
  509. $this->assign('game_list', $gameList);
  510. return $this->fetch('subscribe_list');
  511. }
  512. /**
  513. * 开服开测订阅管理--查看玩家账号
  514. */
  515. public function showSubscribeName()
  516. {
  517. $id = input('id');
  518. $gameid = input('gameid');
  519. if(empty($id)){
  520. $this->error('ID不能为空');
  521. }
  522. $username= Db::table('cy_subscribelog')->where(['id'=>$id])->value('username');
  523. if(!empty($username)){
  524. $game_name = model('Common/Game')->where(['id'=>$gameid])->value('name');
  525. $this->insertLog($this->current_node,'查看账号:'.$username.',关联游戏:'.$game_name,141);
  526. $this->result($username,1);
  527. }
  528. else{
  529. $this->error('订阅信息不存在');
  530. }
  531. }
  532. /**
  533. * 开服开测订阅管理--查看玩家手机号
  534. */
  535. public function showSubscribeMobile()
  536. {
  537. $id = input('id');
  538. $gameid = input('gameid');
  539. if(empty($id)){
  540. $this->error('ID不能为空');
  541. }
  542. $username= Db::table('cy_subscribelog')->where(['id'=>$id])->value('mobile');
  543. if(!empty($username)){
  544. $game_name = model('Common/Game')->where(['id'=>$gameid])->value('name');
  545. $this->insertLog($this->current_node,'查看手机号:'.$username.',关联游戏:'.$game_name,142);
  546. $this->result($username,1);
  547. }
  548. else{
  549. $this->error('订阅信息不存在');
  550. }
  551. }
  552. }