* @version : HUOSDK 9.0 */ namespace huoIdentify\logic; use huo\model\common\CommonModel; use huoIdentify\model\GameModel; use huoIdentify\model\IdentifyGameModel; use huolib\constant\IdentifyConst; class IdentifyGameLogic extends CommonModel { protected $base_field = []; /** * 转换查询条件 * * @param array $param * * @return array */ public function getWhere($param = []) { $_map = []; /* app_id搜索 */ if (!empty($param['app_id'])) { $_map['id'] = $param['app_id']; } $_ig_map = []; if (!empty($param['app_key'])) { $_ig_map['app_key'] = $param['app_key']; } if (!empty($param['biz_id'])) { $_ig_map['biz_id'] = $param['biz_id']; } if (!empty($param['driver_key'])) { $_ig_map['driver_key'] = $param['driver_key']; } if (empty($_map['id']) && !empty($_ig_map)) { $_app_ids = (new IdentifyGameModel())->getIdsByWhere($_ig_map); $_map['id'] = ['in', $_app_ids]; } if (empty($_map['id'])) { $_map['id'] = ['not in', [100, 101]]; } return $_map; } /** * 获取列表底层函数 * * @param array $where 搜索条件 * @param string $page 列表个数 * @param string $order 排序 * @param array $field 附加字段 * @param string $group 归类 * * @return array ['count'=>0,'list'=>[]] */ public function getList($where = [], $page = '1,10', $order = '-id', $field = [], $group = '') { $_map = $where; $_field = $field; $_model = new GameModel(); $_count = $_model->where($_map)->count(); if (empty($_count)) { return [ 'count' => 0, 'list' => [] ]; } $_order = $this->orderFilter($order); $_datas = $_model->with('identify')->field($_field)->where($_map)->order($_order)->page($page)->select(); if (is_object($_datas)) { $_datas = $_datas->toArray(); } if (empty($_datas)) { return [ 'count' => 0, 'list' => [] ]; } return [ 'count' => $_count, 'list' => $_datas ]; } /** * 获取后台列表 * * @param array $where 搜索条件 * @param string $page 列表个数 * @param string $order 排序 * @param array $field 附加字段 * * @return array ['count'=>0,'list'=>[]] */ public function getAdminList($where = [], $page = '1,10', $order = '-id', $field = []) { $_map = $this->getWhere($where); $_field = $this->base_field; if (!empty($field)) { $_field = array_merge($_field, $field);/* 获取后台字段 */ } $_rdata = $this->getList($_map, $page, $order, $_field); if (empty($_rdata['list'])) { return $_rdata; } foreach ($_rdata['list'] as $_k => $_v) { $_ig_data = get_val($_v, 'identify', []); $_ext_info = get_val($_ig_data, 'ext_info', []); $_rdata['list'][$_k]['ig_id'] = get_val($_ig_data, 'id', 0); $_rdata['list'][$_k]['driver_key'] = get_val($_ig_data, 'driver_key', ''); $_rdata['list'][$_k]['create_time'] = get_val($_ig_data, 'create_time', 0); $_rdata['list'][$_k]['update_time'] = get_val($_ig_data, 'update_time', 0); switch ($_rdata['list'][$_k]['driver_key']) { case 'fcmgame': $_app_key = get_val($_ig_data, 'app_key', ''); $_app_secret = get_val($_ig_data, 'app_secret', ''); $_biz_id = get_val($_ig_data, 'biz_id', ''); $_str = '应用标识:'.$_app_key.'
用户密钥:'.$_app_secret.'
游戏备案识别码:' .$_biz_id; break; case 'guopan': $_url = get_val($_ext_info, 'require_url', ''); $_channel_code = get_val($_ext_info, 'channel_code', ''); $_server_key = get_val($_ext_info, 'server_key', ''); $_str = '请求URL:'.$_url.'
渠道CODE:'.$_channel_code.'
加密KEY:'.$_server_key; break; case 'liebao': $_url = get_val($_ext_info, 'require_url', ''); $_channel_code = get_val($_ext_info, 'channel_code', ''); $_game_id = get_val($_ext_info, 'game_id', ''); $_str = '请求URL:'.$_url.'
加密密钥:'.$_channel_code.'
CP游戏ID:'.$_game_id; break; case 'moxing': $_url = get_val($_ext_info, 'require_url', ''); $_app_key = get_val($_ext_info, 'app_key', ''); $_secret_key = get_val($_ext_info, 'secret_key', ''); $_channel_id = get_val($_ext_info, 'channel_id', ''); $_str = '请求URL:'.$_url.'
appKey:'.$_app_key.'
secretKey:'.$_secret_key .'
channelId:'.$_channel_id; break; default: $_str = ''; $_url = get_val($_ext_info, 'require_url', ''); $_channel_code = get_val($_ext_info, 'channel_code', ''); if (!empty($_channel_code)) { $_str = '请求URL:'.$_url.'
渠道CODE:'.$_channel_code; } } $_rdata['list'][$_k]['param'] = $_str; $_url = url('setPreCheck', ['app_id' => $_v['id']]); $_lang_key = IdentifyConst::getIdentityPreCheckType(get_val($_ig_data, 'pre_check', 1)); $_rdata['list'][$_k]['pre_check_button'] = action_dialog($_url, $_lang_key, 'btn', 'success'); } return $_rdata; } }