IdentifyGameLogic.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. /**
  3. * IdentifyGameLogic.php UTF-8
  4. *
  5. *
  6. * @date : 2021-03-11 15:36
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : luowei <lw@huosdk.com>
  10. * @version : HUOSDK 9.0
  11. */
  12. namespace huoIdentify\logic;
  13. use huo\model\common\CommonModel;
  14. use huoIdentify\model\GameModel;
  15. use huoIdentify\model\IdentifyGameModel;
  16. use huolib\constant\IdentifyConst;
  17. class IdentifyGameLogic extends CommonModel {
  18. protected $base_field = [];
  19. /**
  20. * 转换查询条件
  21. *
  22. * @param array $param
  23. *
  24. * @return array
  25. */
  26. public function getWhere($param = []) {
  27. $_map = [];
  28. /* app_id搜索 */
  29. if (!empty($param['app_id'])) {
  30. $_map['id'] = $param['app_id'];
  31. }
  32. $_ig_map = [];
  33. if (!empty($param['app_key'])) {
  34. $_ig_map['app_key'] = $param['app_key'];
  35. }
  36. if (!empty($param['biz_id'])) {
  37. $_ig_map['biz_id'] = $param['biz_id'];
  38. }
  39. if (!empty($param['driver_key'])) {
  40. $_ig_map['driver_key'] = $param['driver_key'];
  41. }
  42. if (empty($_map['id']) && !empty($_ig_map)) {
  43. $_app_ids = (new IdentifyGameModel())->getIdsByWhere($_ig_map);
  44. $_map['id'] = ['in', $_app_ids];
  45. }
  46. if (empty($_map['id'])) {
  47. $_map['id'] = ['not in', [100, 101]];
  48. }
  49. return $_map;
  50. }
  51. /**
  52. * 获取列表底层函数
  53. *
  54. * @param array $where 搜索条件
  55. * @param string $page 列表个数
  56. * @param string $order 排序
  57. * @param array $field 附加字段
  58. * @param string $group 归类
  59. *
  60. * @return array ['count'=>0,'list'=>[]]
  61. */
  62. public function getList($where = [], $page = '1,10', $order = '-id', $field = [], $group = '') {
  63. $_map = $where;
  64. $_field = $field;
  65. $_model = new GameModel();
  66. $_count = $_model->where($_map)->count();
  67. if (empty($_count)) {
  68. return [
  69. 'count' => 0,
  70. 'list' => []
  71. ];
  72. }
  73. $_order = $this->orderFilter($order);
  74. $_datas = $_model->with('identify')->field($_field)->where($_map)->order($_order)->page($page)->select();
  75. if (is_object($_datas)) {
  76. $_datas = $_datas->toArray();
  77. }
  78. if (empty($_datas)) {
  79. return [
  80. 'count' => 0,
  81. 'list' => []
  82. ];
  83. }
  84. return [
  85. 'count' => $_count,
  86. 'list' => $_datas
  87. ];
  88. }
  89. /**
  90. * 获取后台列表
  91. *
  92. * @param array $where 搜索条件
  93. * @param string $page 列表个数
  94. * @param string $order 排序
  95. * @param array $field 附加字段
  96. *
  97. * @return array ['count'=>0,'list'=>[]]
  98. */
  99. public function getAdminList($where = [], $page = '1,10', $order = '-id', $field = []) {
  100. $_map = $this->getWhere($where);
  101. $_field = $this->base_field;
  102. if (!empty($field)) {
  103. $_field = array_merge($_field, $field);/* 获取后台字段 */
  104. }
  105. $_rdata = $this->getList($_map, $page, $order, $_field);
  106. if (empty($_rdata['list'])) {
  107. return $_rdata;
  108. }
  109. foreach ($_rdata['list'] as $_k => $_v) {
  110. $_ig_data = get_val($_v, 'identify', []);
  111. $_ext_info = get_val($_ig_data, 'ext_info', []);
  112. $_rdata['list'][$_k]['ig_id'] = get_val($_ig_data, 'id', 0);
  113. $_rdata['list'][$_k]['driver_key'] = get_val($_ig_data, 'driver_key', '');
  114. $_rdata['list'][$_k]['create_time'] = get_val($_ig_data, 'create_time', 0);
  115. $_rdata['list'][$_k]['update_time'] = get_val($_ig_data, 'update_time', 0);
  116. switch ($_rdata['list'][$_k]['driver_key']) {
  117. case 'fcmgame':
  118. $_app_key = get_val($_ig_data, 'app_key', '');
  119. $_app_secret = get_val($_ig_data, 'app_secret', '');
  120. $_biz_id = get_val($_ig_data, 'biz_id', '');
  121. $_str = '应用标识:'.$_app_key.'<br/>用户密钥:'.$_app_secret.'<br/>游戏备案识别码:'
  122. .$_biz_id;
  123. break;
  124. case 'guopan':
  125. $_url = get_val($_ext_info, 'require_url', '');
  126. $_channel_code = get_val($_ext_info, 'channel_code', '');
  127. $_server_key = get_val($_ext_info, 'server_key', '');
  128. $_str = '请求URL:'.$_url.'<br/> 渠道CODE:'.$_channel_code.'<br/> 加密KEY:'.$_server_key;
  129. break;
  130. case 'liebao':
  131. $_url = get_val($_ext_info, 'require_url', '');
  132. $_channel_code = get_val($_ext_info, 'channel_code', '');
  133. $_game_id = get_val($_ext_info, 'game_id', '');
  134. $_str = '请求URL:'.$_url.'<br/> 加密密钥:'.$_channel_code.'<br/> CP游戏ID:'.$_game_id;
  135. break;
  136. case 'moxing':
  137. $_url = get_val($_ext_info, 'require_url', '');
  138. $_app_key = get_val($_ext_info, 'app_key', '');
  139. $_secret_key = get_val($_ext_info, 'secret_key', '');
  140. $_channel_id = get_val($_ext_info, 'channel_id', '');
  141. $_str = '请求URL:'.$_url.'<br/> appKey:'.$_app_key.'<br/> secretKey:'.$_secret_key
  142. .'<br/> channelId:'.$_channel_id;
  143. break;
  144. default:
  145. $_str = '';
  146. $_url = get_val($_ext_info, 'require_url', '');
  147. $_channel_code = get_val($_ext_info, 'channel_code', '');
  148. if (!empty($_channel_code)) {
  149. $_str = '请求URL:'.$_url.'<br/> 渠道CODE:'.$_channel_code;
  150. }
  151. }
  152. $_rdata['list'][$_k]['param'] = $_str;
  153. $_url = url('setPreCheck', ['app_id' => $_v['id']]);
  154. $_lang_key = IdentifyConst::getIdentityPreCheckType(get_val($_ig_data, 'pre_check', 1));
  155. $_rdata['list'][$_k]['pre_check_button'] = action_dialog($_url, $_lang_key, 'btn', 'success');
  156. }
  157. return $_rdata;
  158. }
  159. }