| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 | <?php/** * IdentifyDriverConf.php UTF-8 * * * @date    : 2021-03-11 15:04 * * @license 这不是一个自由软件,未经授权不许任何使用和传播。 * @author  : luowei <lw@huosdk.com> * @version : HUOSDK 9.0 */namespace huoIdentify\controller;use huoIdentify\model\GameModel;use huoIdentify\model\IdentifyGameModel;use huolib\constant\IdentifyConst;use think\Config;class IdentifyDriverConf {    /**     * @param $identify_from     * @param $app_id     *     * @return array     */    public static function getConfig($identify_from, $app_id) {        if ($identify_from == IdentifyConst::DRIVER_KEY_WXPAY || $identify_from == IdentifyConst::DRIVER_KEY_ALIPAY) {            return (array)Config::get('identify_conf.'.$identify_from);        }        $_identify_game_model = new IdentifyGameModel();        $_identify_game_info = (array)$_identify_game_model->getInfoByAppId($app_id);        if (empty($_identify_game_info)) {            throw new \think\Exception('游戏暂未配置实名参数');        }        $_driver_key = get_val($_identify_game_info, 'driver_key', '');        switch ($_driver_key) {            case IdentifyConst::DRIVER_KEY_FCMGAME:                return [                    'driver_key' => $_driver_key,                    'appId'      => get_val($_identify_game_info, 'app_key', ''),                    'bizId'      => get_val($_identify_game_info, 'biz_id', ''),                    'key'        => get_val($_identify_game_info, 'app_secret', ''),                ];            case IdentifyConst::DRIVER_KEY_YIWAN:            case IdentifyConst::DRIVER_KEY_HUOUNION:            case IdentifyConst::DRIVER_KEY_YIXIN:            case IdentifyConst::DRIVER_KEY_JUEFENG:            case IdentifyConst::DRIVER_KEY_KUCHANG:                $_ext_info = get_val($_identify_game_info, 'ext_info', '');                $_channel_code = get_val($_ext_info, 'channel_code', '');                $_require_url = get_val($_ext_info, 'require_url', '');                if (empty($_channel_code) || empty($_require_url)) {                    throw new \think\Exception('游戏暂未配置实名参数');                }                return [                    'driver_key'   => $_driver_key,                    'channel_code' => $_channel_code,                    'require_url'  => $_require_url,                    'app_id'       => $app_id                ];            case IdentifyConst::DRIVER_KEY_GUOPAN:                $_ext_info = get_val($_identify_game_info, 'ext_info', '');                $_server_key = get_val($_ext_info, 'server_key', '');                $_channel_code = get_val($_ext_info, 'channel_code', '');                $_require_url = get_val($_ext_info, 'require_url', '');                if (empty($_channel_code) || empty($_require_url)) {                    throw new \think\Exception('游戏暂未配置实名参数');                }                return [                    'driver_key'   => $_driver_key,                    'channel_code' => $_channel_code,                    'server_key'   => $_server_key,                    'require_url'  => $_require_url,                    'app_id'       => $app_id                ];            case IdentifyConst::DRIVER_KEY_LIEBAO:                $_ext_info = get_val($_identify_game_info, 'ext_info', '');                $_game_id = get_val($_ext_info, 'game_id', '');                $_channel_code = get_val($_ext_info, 'channel_code', '');                $_require_url = get_val($_ext_info, 'require_url', '');                if (empty($_channel_code) || empty($_require_url)) {                    throw new \think\Exception('游戏暂未配置实名参数');                }                return [                    'driver_key'   => $_driver_key,                    'channel_code' => $_channel_code,                    'game_id'      => $_game_id,                    'require_url'  => $_require_url,                    'app_id'       => $app_id                ];            case IdentifyConst::DRIVER_KEY_QIANXI:            case IdentifyConst::DRIVER_KEY_TIANYU:                $_ext_info = get_val($_identify_game_info, 'ext_info', '');                $_channel_code = get_val($_ext_info, 'channel_code', '');                $_require_url = get_val($_ext_info, 'require_url', '');                $_app_key = (new GameModel())->getAppKey($app_id);                if (empty($_channel_code) || empty($_require_url) || empty($_app_key)) {                    throw new \think\Exception('游戏暂未配置实名参数');                }                return [                    'driver_key'   => $_driver_key,                    'channel_code' => $_channel_code,                    'app_key'      => $_app_key,                    'require_url'  => $_require_url,                    'app_id'       => $app_id                ];            case IdentifyConst::DRIVER_KEY_MOXING:                $_ext_info = get_val($_identify_game_info, 'ext_info', '');                $_app_key = get_val($_ext_info, 'app_key', '');                $_secret_key = get_val($_ext_info, 'secret_key', '');                $_require_url = get_val($_ext_info, 'require_url', '');                $_channel_id = get_val($_ext_info, 'channel_id', '');                if (empty($_app_key) || empty($_require_url) || empty($_secret_key) || empty($_channel_id)) {                    throw new \think\Exception('游戏暂未配置实名参数');                }                return [                    'driver_key'  => $_driver_key,                    'app_key'     => $_app_key,                    'secret_key'  => $_secret_key,                    'require_url' => $_require_url,                    'channel_id'  => $_channel_id,                    'app_id'      => $app_id                ];            default:                throw new \think\Exception('游戏暂未配置实名参数');        }    }    /**     * 获取阿里云或腾讯云实名配置信息     */    public function getATCloudConf() {        $_wx_conf = (array)Config::get('identify_conf.weixin');        if (!empty($_wx_conf['SECRET_ID']) && !empty($_wx_conf['SECRET_KEY'])) {            return ['weixin', $_wx_conf];        }        $_ali_conf = (array)Config::get('identify_conf.alipay');        if (!empty($_ali_conf['APP_KEY']) && !empty($_ali_conf['APP_SECRET']) && !empty($_ali_conf['APP_CODE'])) {            return ['alipay', $_ali_conf];        }        return ['', []];    }    /**     * 获取前置校验类型     *     * @param $app_id     *     * @return array     */    public function getIdentityCheckType($app_id) {        $_identify_game_model = new IdentifyGameModel();        $_identify_game_info = (array)$_identify_game_model->getInfoByAppId($app_id);        return $_identify_game_info;    }}
 |