GameHelpLogic.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * GameHelpLogic.php UTF-8
  4. * WWW
  5. *
  6. * @date : 2018/7/12 18:00
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace huo\logic\game;
  13. use huo\logic\qq\QqConfLogic;
  14. use huo\model\common\CommonModel;
  15. use huo\model\game\GameHelpModel;
  16. use huolib\constant\CommonConst;
  17. class GameHelpLogic extends CommonModel {
  18. /**
  19. * @param array $param
  20. *
  21. * @return array
  22. */
  23. protected function getWhere($param = []) {
  24. $_map = [];
  25. if (!empty($param['start_time']) && !empty($param['end_time'])) {
  26. $_map['create_time']
  27. = [
  28. 'between',
  29. [
  30. strtotime($param['start_time']),
  31. CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])
  32. ]
  33. ];
  34. } elseif (!empty($param['start_time'])) {
  35. $_map['create_time'] = ['egt', strtotime($param['start_time'])];
  36. } elseif (!empty($param['end_time'])) {
  37. $_map['create_time'] = ['elt', CommonConst::CONST_DAY_SECONDS + strtotime($param['end_time'])];
  38. }
  39. if (!empty($param['game_id'])) {
  40. $_map['app_id'] = $param['game_id'];
  41. }
  42. if (!empty($param['app_id'])) {
  43. $_map['app_id'] = $param['app_id'];
  44. }
  45. return $_map;
  46. }
  47. public function getField() {
  48. return [
  49. 'app_id' => 'app_id',
  50. 'qq_ids' => 'qq_ids',
  51. 'wx' => 'wx',
  52. 'tel' => 'tel',
  53. 'service_time' => 'service_time',
  54. 'weibo' => 'weibo',
  55. 'officesite' => 'officesite',
  56. 'update_time' => 'update_time',
  57. 'create_time' => 'create_time',
  58. ];
  59. }
  60. /**
  61. * 后台获取列表
  62. *
  63. * @param array $where
  64. * @param string $page
  65. * @param string $order
  66. *
  67. * @return array
  68. * @throws \think\db\exception\DataNotFoundException
  69. * @throws \think\db\exception\ModelNotFoundException
  70. * @throws \think\exception\DbException
  71. */
  72. public function getAdminList($where = [], $page = '1,10', $order = '+app_id') {
  73. $_map = $this->getWhere($where);
  74. $_model = new GameHelpModel();
  75. $_rdata = ['count' => 0, 'list' => []];
  76. $_count = $_model->where($_map)->count('app_id');
  77. if (empty($_count)) {
  78. return $_rdata;
  79. }
  80. $_field = $this->getField();
  81. $_order = $this->orderFilter($order);
  82. $_gdata = $_model->with('game')
  83. ->field($_field)
  84. ->where($_map)
  85. ->order($_order)
  86. ->page($page)
  87. ->select();
  88. if (is_object($_gdata)) {
  89. $_gdata = $_gdata->toArray();
  90. }
  91. if (empty($_gdata)) {
  92. return $_rdata;
  93. }
  94. $_list = [];
  95. foreach ($_gdata as $_k => $_v) {
  96. $_data = [];
  97. foreach ($_field as $_fk => $_fv) {
  98. $_data[$_fv] = $_v[$_fk];
  99. }
  100. if (!empty($_v['qq_ids'])) {
  101. list($_data['qq'], $_data['qqgroup']) = (new QqConfLogic())->getQqs($_v['qq_ids']);
  102. }
  103. if (!empty($_v['game'])) {
  104. $_data['game_name'] = isset($_v['game']['game_name']) ? $_v['game']['game_name'] : '';
  105. } else {
  106. $_data['game_name'] = '';
  107. }
  108. $_list[] = $_data;
  109. }
  110. $_rdata = ['count' => $_count, 'list' => $_list];
  111. return $_rdata;
  112. }
  113. }