GameQqLogic.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. /**
  3. * GamePlayLogic.php UTF-8
  4. * GameQqLogic
  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\model\common\CommonModel;
  14. use huo\model\game\GameQqModel;
  15. use huolib\constant\CommonConst;
  16. use huolib\constant\GameConst;
  17. class GameQqLogic 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. if (!empty($param['status'])) {
  46. $_map['status'] = $param['status'];
  47. }
  48. return $_map;
  49. }
  50. public function getField() {
  51. return [
  52. 'id' => 'id',
  53. 'app_id' => 'app_id',
  54. 'qq_id' => 'qq_id',
  55. 'status' => 'status',
  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 GameQqModel();
  75. $_rdata = ['count' => 0, 'list' => []];
  76. $_count = $_model->where($_map)->count('id');
  77. if (empty($_count)) {
  78. return $_rdata;
  79. }
  80. $_field = $this->getField();
  81. $_order = $this->orderFilter($order);
  82. $_gdata = $_model->with('game')
  83. ->with('qq')
  84. ->field($_field)
  85. ->where($_map)
  86. ->order($_order)
  87. ->page($page)
  88. ->select();
  89. if (is_object($_gdata)) {
  90. $_gdata = $_gdata->toArray();
  91. }
  92. if (empty($_gdata)) {
  93. return $_rdata;
  94. }
  95. $_list = [];
  96. foreach ($_gdata as $_k => $_v) {
  97. $_data = [];
  98. foreach ($_field as $_fk => $_fv) {
  99. $_data[$_fv] = $_v[$_fk];
  100. }
  101. $_data['status_text'] = GameConst::getQqStatusMsg($_v['status']);
  102. if (!empty($_v['game'])) {
  103. $_data['game_name'] = isset($_v['game']['game_name']) ? $_v['game']['game_name'] : '';
  104. }
  105. if (!empty($_v['qq'])) {
  106. $_data['qq'] = isset($_v['qq']['qq']) ? $_v['qq']['qq'] : '';
  107. $_data['idkey'] = isset($_v['qq']['idkey']) ? $_v['qq']['idkey'] : '';
  108. $_data['ios_key'] = isset($_v['qq']['ios_key']) ? $_v['qq']['ios_key'] : '';
  109. $_data['and_key'] = isset($_v['qq']['and_key']) ? $_v['qq']['and_key'] : '';
  110. }
  111. $_list[] = $_data;
  112. }
  113. $_rdata = ['count' => $_count, 'list' => $_list];
  114. return $_rdata;
  115. }
  116. /**
  117. * 获取游戏Qq配置信息
  118. *
  119. * @param $app_id
  120. *
  121. * @return array|false|\PDOStatement|string|\think\Collection
  122. * @throws \think\Exception
  123. * @throws \think\db\exception\DataNotFoundException
  124. * @throws \think\db\exception\ModelNotFoundException
  125. * @throws \think\exception\DbException
  126. */
  127. public function getGameQqInfo($app_id) {
  128. if (empty($app_id)) {
  129. return '';
  130. }
  131. $_map = [];
  132. $_map['app_id'] = $app_id;
  133. $_map['status'] = GameConst::QQ_STATUS_OPEN;
  134. $_rdata = (new GameQqModel())->where($_map)->find();
  135. if (is_object($_rdata)) {
  136. $_rdata = $_rdata->toArray();
  137. }
  138. return $_rdata;
  139. }
  140. /**
  141. * 获取游戏Qq配置信息
  142. *
  143. * @param $id
  144. *
  145. * @return array|false|\PDOStatement|string|\think\Collection
  146. * @throws \think\Exception
  147. * @throws \think\db\exception\DataNotFoundException
  148. * @throws \think\db\exception\ModelNotFoundException
  149. * @throws \think\exception\DbException
  150. */
  151. public function getGameQqInfoById($id) {
  152. if (empty($id)) {
  153. return '';
  154. }
  155. $_map = [];
  156. $_map['id'] = $id;
  157. $_rdata = (new GameQqModel())->where($_map)->find();
  158. if (is_object($_rdata)) {
  159. $_rdata = $_rdata->toArray();
  160. }
  161. return $_rdata;
  162. }
  163. /**
  164. * 获取游戏QQ配置
  165. *
  166. * @param $where
  167. *
  168. * @return array|bool|false|\PDOStatement|string|\think\Model
  169. * @throws \think\Exception
  170. * @throws \think\db\exception\DataNotFoundException
  171. * @throws \think\db\exception\ModelNotFoundException
  172. * @throws \think\exception\DbException
  173. */
  174. public function getGameQqDetail($where) {
  175. if (empty($where['app_id']) || empty($where['qq_id'])) {
  176. return false;
  177. }
  178. $_map = [];
  179. $_map['app_id'] = $where['app_id'];
  180. $_map['qq_id'] = $where['qq_id'];
  181. $_rdata = (new GameQqModel())->useGlobalScope(false)->where($_map)->find();
  182. if (is_object($_rdata)) {
  183. $_rdata = $_rdata->toArray();
  184. }
  185. return $_rdata;
  186. }
  187. }