* @version : HUOUNION 8.5 */ namespace huoIdentify\controller; use huo\controller\common\Base; use huo\controller\common\CommonFunc; use huo\controller\integral\MemIa; use huo\model\game\GameModel; use huo\model\member\MemberModel; use huo\model\member\MemGameModel; use huoIdentify\lib\queue\controller\IdentifyQueue; use huoIdentify\lib\queue\controller\ReportQueue; use huoIdentify\model\IdentifyGameModel; use huoIdentify\model\IdentifyMemModel; use huoIdentify\model\IdentifyOrderModel; use huoIdentify\model\IdentifyPiModel; use huoIdentify\model\IdentifyPlatformLogModel; use huolib\constant\CommonConst; use huolib\constant\DeviceTypeConst; use huolib\constant\GameConst; use huolib\constant\IaConst; use huolib\constant\IdentifyConst; use huolib\constant\MemConst; use huolib\status\CommonStatus; use huolib\status\IdentifyStatus; use huolib\status\MemberStatus; use huolib\tool\RateLimit; use huolib\tool\StrUtils; use huolib\utils\IdentifyUtils; use think\Config; use think\Exception; class Identify extends Base { protected $app_id = 0; public function __construct($app_id = 0) { $this->__initConfig($app_id); } private function __initConfig($app_id) { $_app_id = $app_id; if (empty($_app_id)) { $_app_id = (int)request()->param('game_id/d', 0); if (empty($_app_id)) { $_app_id = (int)request()->param('app_id/d', 0); } } $this->app_id = $_app_id; if (!empty($_app_id)) { $_identify_game_model = new IdentifyGameModel(); $_identify_game_info = (array)$_identify_game_model->getInfoByAppId($_app_id); if (!empty($_identify_game_info['driver_key'])) { Config::set('identify_conf.default', $_identify_game_info['driver_key']); } } } /** * 获取会员认证信息 * * @param int $mem_id 玩家id * @param bool $encrypt 是否加密 * @param int $app_id 当前游戏id * * @return mixed : array */ public function getIdentifyByMemId($mem_id, $encrypt = false, $app_id = 0) { $_mem_data = (new IdentifyMemModel())->getInfoByMemId($mem_id); if (empty($_mem_data) && !empty($app_id)) { /* 未获取到实名信息,则查看是否有认证中的数据 */ $this->checkMemIdentify($mem_id, $app_id); $_mem_data = (new IdentifyMemModel())->getInfoByMemId($mem_id); } $_data['id_card'] = get_val($_mem_data, 'id_card'); $_data['real_name'] = get_val($_mem_data, 'real_name'); $_data['pi'] = get_val($_mem_data, 'identify_pi'); $_data['birthday'] = IdentifyUtils::getBirthday($_data['id_card']); $_data['age'] = IdentifyUtils::getAge($_data['birthday']); $_data['is_auth'] = IdentifyConst::IS_AUTH_NO; if (!empty($_data['id_card'])) { $_data['is_auth'] = IdentifyConst::IS_AUTH_YES; } if (true == $encrypt) { if (!empty($_data['real_name'])) { $_data['real_name'] = StrUtils::encryptName($_data['real_name']); } if (!empty($_data['id_card'])) { $_data['id_card'] = StrUtils::encryptName($_data['id_card']); } } return $_data; } /** * 根据app_id获取游戏实名认证状态 * * @param int $app_id * * @return:int */ public function getGameAuthByAppId($app_id) { $_is_auth = (new GameModel())->getIsAuthById($app_id); return $_is_auth; } /** * 获取用户实名信息状况 * * @param int $app_id 游戏id * @param int $mem_id 会员id * @param string $device_id 设备号 用于未实名玩家时长统计 * * @return array */ public function getMemIdentifyInfo($app_id, $mem_id, $device_id = '', $token = '') { /*定义返回数组*/ $_rdata = [ 'auth_info' => [ 'id_card' => '', 'real_name' => '', 'birthday' => '', 'age' => '', 'is_auth' => IdentifyConst::IS_AUTH_NO ], 'url' => '', ]; $_app_ids = CommonFunc::getAppAppId(); $_game_auth = $this->getGameAuthByAppId($app_id); if (!in_array($app_id, $_app_ids)) { /* 不需要实名不做任何处理 */ if (GameConst::GAME_IDENTIFY_IS_NO == $_game_auth) { return $_rdata; } } $_token = session_id(); if (!empty($token)) { $_token = $token; } $_param = [ 'app_id' => $app_id, 'device_id' => $device_id, 'token' => $_token ]; $_identify_url = IdentifyConst::getIdentifyUrl($_param); $_mem_auth_info = $this->getIdentifyByMemId($mem_id, false, $app_id); $_mem_auth_info['is_auth'] = $_game_auth; $_rdata['auth_info'] = $_mem_auth_info; /* 获取玩家是否已绑定手机 */ $_mem_model = new MemberModel(); $_mobile = $_mem_model->getMobileById($mem_id); $_status = $_mem_model->getStatus($mem_id); if (empty($_mobile) && MemConst::STATUS_TRY == $_status) { $_rdata['url'] = IdentifyConst::getBindMobileUrl($_param); return $_rdata; } $_rdata['url'] = $_identify_url; /* 玩家未实名返回实名认证地址 */ if (empty($_mem_auth_info['id_card'])) { return $_rdata; } /* 玩家已实名校验未成年限制 */ $_rdata['url'] = (new Online($app_id, $mem_id, $device_id))->checkLimit(); return $_rdata; } /** * 更新实名认证信息 * * @param $mem_id * @param int $type * @param $real_name * @param $id_card * @param int $app_id * * @return mixed */ public function updateIdentify($mem_id, $type = 1, $real_name, $id_card, $app_id = 0) { $_id_card = strtoupper($id_card); /* 防止输入小写字符 x*/ $_real_name = $real_name; $_mem_model = new MemberModel(); $_mem_data = $_mem_model->getInfoById($mem_id); if (empty($_mem_data)) { $_code = MemberStatus::LOGIN_IS_OUT; return $this->huoError($_code, MemberStatus::getMsg($_code)); } $_app_id = $app_id; if (empty($_app_id)) { $_app_id = request()->param('app_id/d', 0); } if (empty($_app_id)) { $_app_id = $_mem_data['app_id']; } \think\Log::error('↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓'); \think\Log::error('================= 实名认证开始 ====================='); \think\Log::error([$mem_id, $type, $real_name, $id_card, $_app_id]); /* 1、本地正则校验 */ $_chk_rs = IdentifyUtils::checkIdentify($type, $_real_name, $_id_card); if (IdentifyStatus::NO_ERROR != $_chk_rs) { \think\Log::error('================= 正则校验失败 ====================='); return $this->huoError($_chk_rs, IdentifyStatus::getMsg($_chk_rs)); } \think\Log::error('================= 正则校验通过 ====================='); /* 2、获取游戏配置 */ $_identify_conf = (new \huoIdentify\controller\IdentifyDriverConf())->getIdentityCheckType($_app_id); $_driver_key = get_val($_identify_conf, 'driver_key', Config::get('identify_conf.default')); $_rs_data = []; if (empty($_identify_conf['pre_check']) || IdentifyConst::IDENTITY_PRE_CHECK_AT_CLOUD == $_identify_conf['pre_check'] || in_array($_driver_key, [IdentifyConst::DRIVER_KEY_ALIPAY, IdentifyConst::DRIVER_KEY_WXPAY])) { \think\Log::error('================= 前置阿里/腾讯云校验 ====================='); /* 未配置实名参数,或前置校验需要使用阿里腾讯云 */ $_rs_data = $this->identifyByThirdParty($mem_id, $type, $_real_name, $_id_card, $_app_id); if (CommonStatus::NO_ERROR != $_rs_data['code']) { \think\Log::error('================= 前置阿里/腾讯云返回结果 ====================='); \think\Log::error($_rs_data); return $this->huoReturn($_rs_data); } $_id_card = strtoupper(get_val($_rs_data['data'], 'id_card', '')); $_real_name = get_val($_rs_data['data'], 'real_name', ''); } switch ($_driver_key) { case IdentifyConst::DRIVER_KEY_ALIPAY: case IdentifyConst::DRIVER_KEY_WXPAY: \think\Log::error('================= 阿里/腾讯云实名直接返回认证成功,允许进入游戏 ====================='); /* 阿里/腾讯云实名直接返回认证成功,允许进入游戏 */ $_code = IdentifyStatus::NO_ERROR; return $this->huoSuccess($_code, IdentifyStatus::getMsg($_code), $_rs_data); default: return $this->getReportIdentity($mem_id, $type, $_real_name, $_id_card, $_app_id); } } /** * 上报实名信息 * * @param $mem_id * @param int $type * @param $real_name * @param $id_card * @param int $app_id * @param bool $from_queue 是否来自队列 * * @return mixed */ public function getReportIdentity($mem_id, $type = 1, $real_name, $id_card, $app_id = 0, $from_queue = false) { $_im_model = new IdentifyMemModel(); $_app_id = $app_id; $_identify_from = Config::get('identify_conf.default'); //实名认证api $_pi_info = $this->getPiInfoByIdCard($id_card); $_identify_pi = get_val($_pi_info, 'identify_pi', ''); $_pi_real_name = get_val($_pi_info, 'real_name', ''); if (!empty($_identify_pi) && $_pi_real_name == $real_name) { /* 产品经理和技术负责人明确:库中实名信息与输入信息一致才不需重新上报 */ \think\Log::error('================= PI值存在无需上报 ====================='); $_identify_from = get_val($_pi_info, 'identify_from', ''); $id_card = get_val($_pi_info, 'id_card', $id_card); $real_name = get_val($_pi_info, 'real_name', $real_name); return $this->afterIdentify($mem_id, $id_card, $real_name, $type, $_identify_from, $_identify_pi, $_app_id); } try { /* Modified by chenbingling BEGIN 2021/5/6 ISSUES:#-1 不是队列来的入队列处理 */ if (false === $from_queue) { /* 判断当前信息认证状态 */ $_report_status = $_im_model->getReportStatusByMemIdIdCard($mem_id, $id_card); if (IdentifyConst::IDENTITY_STATUS_NO == $_report_status) { $_code = IdentifyStatus::IDENTITY_FAIL; return $this->huoError($_code, IdentifyStatus::getMsg($_code)); } $_rs = (new IdentifyQueue())->addInQueueData($mem_id, $id_card, $real_name, $_app_id, $_identify_pi); if (true === $_rs) { \think\Log::error('================= 数据入队列 ====================='); if (IdentifyConst::DRIVER_KEY_FCMGAME == $_identify_from) { \think\Log::error('================= 国家防沉迷上报结果等待 ====================='); $_code = IdentifyStatus::IDENTITY_WAIT; } else { \think\Log::error('================= CP上报后允许进入游戏 ====================='); $_code = IdentifyStatus::IDENTITY_IN_PROGRESS; } return $this->huoSuccess($_code, IdentifyStatus::getMsg($_code)); } } /* END 2021/5/6 ISSUES:#-1 */ $_identify_conf = \huoIdentify\controller\IdentifyDriverConf::getConfig($_identify_from, $_app_id); $_identify_class = \huoIdentify\identifyDriver\Identify::ins()->get($_identify_from, $_identify_conf); $_identify_class->setRealName($real_name); $_identify_class->setIdCard($id_card); $_identify_class->setMemId($mem_id); $_identify_class->setIdentifyFrom($_identify_from); $_mg_mem_id = (new MemGameModel())->getDefaultMgIdByMemAppId($mem_id, $_app_id); $_identify_class->setMgMemId($_mg_mem_id); $_classify = (new \huoIdentify\model\GameModel())->getClassifyById($_app_id); $_pf = GameConst::GAME_IOS == $_classify ? 2 : 1; /* 1 安卓 2 ios*/ $_identify_class->setPf($_pf); $_identify_rs = $_identify_class->identify(); /* 玩家实名认证中可放行 */ if (CommonStatus::MEM_IDENTIFY_IN_PROGRESS == $_identify_rs['code']) { if (true === $from_queue) { /* 来源队列的原样返回 */ return $this->huoReturn($_identify_rs); } if (IdentifyConst::DRIVER_KEY_FCMGAME == $_identify_from) { $_code = IdentifyStatus::IDENTITY_WAIT; } else { $_code = IdentifyStatus::IDENTITY_IN_PROGRESS; } return $this->huoSuccess($_code, $_identify_rs['msg']); } /* 认证失败的清理实名信息 */ if (IdentifyStatus::IDENTITY_FAIL == $_identify_rs['code']) { $_im_model = new IdentifyMemModel(); \think\Log::error('================= 认证失败实名信息清理 ====================='); \think\Log::error([$mem_id, $type, $real_name, $id_card, $app_id]); $_id = $_im_model->getIdByMemId($mem_id); if (!empty($_id)) { $_im_model->deleteData($_id); } } if (CommonStatus::NO_ERROR != $_identify_rs['code']) { /* 设置认证失败 */ $_im_model->setReportFailByMemIdIdCard($mem_id, $id_card); $_identify_rs['msg'] = lang('IDENTITY_FAIL_CONFIRM_INFO'); return $this->huoReturn($_identify_rs); } $_identify_pi = isset($_identify_rs['data']['pi']) ? $_identify_rs['data']['pi'] : ''; } catch (Exception $e) { /* 设置认证失败 */ $_im_model->setReportFailByMemIdIdCard($mem_id, $id_card); return $this->huoError($e->getCode(), $e->getMessage()); } \think\Log::error('================= 认证成功结束 ====================='); \think\Log::error([$mem_id, $type, $real_name, $id_card, $app_id]); return $this->afterIdentify($mem_id, $id_card, $real_name, $type, $_identify_from, $_identify_pi, $_app_id); } /** * 直接使用腾讯或阿里云实名认证 * * @param $mem_id * @param $type * @param $real_name * @param $id_card * @param $app_id * * @return array */ public function identifyByThirdParty($mem_id, $type, $real_name, $id_card, $app_id) { $_im_model = new IdentifyMemModel(); $_cnt = $_im_model->getCntByIdCard($id_card); $_id_bind_limit = (new IdentifyConf())->getIdCardBindCnt(); $_im_info = $_im_model->getInfoByIdCard($id_card); $_im_real_name = get_val($_im_info, 'real_name', ''); if ($_cnt >= $_id_bind_limit) { $_code = IdentifyStatus::IDCARD_BIND_LIMIT; return $this->huoError($_code, IdentifyStatus::getMsg($_code)); } elseif (empty($_cnt) || $_im_real_name != $real_name) { /*产品经理和技术负责人明确:库中已有信息,但是真实姓名不一致则需要重新实名 */ try { list($_identify_from, $_identify_conf) = (new \huoIdentify\controller\IdentifyDriverConf( ))->getATCloudConf(); $_identify_class = \huoIdentify\identifyDriver\Identify::ins()->get($_identify_from, $_identify_conf); $_identify_class->setRealName($real_name); $_identify_class->setIdCard($id_card); $_identify_class->setMemId($mem_id); $_identify_class->setIdentifyFrom($_identify_from); $_identify_rs = $_identify_class->identify(); if (CommonStatus::NO_ERROR != $_identify_rs['code']) { $_identify_rs['msg'] = '认证失败,请确认身份信息是否正确'; return $this->huoReturn($_identify_rs); } $_identify_pi = isset($_identify_rs['data']['pi']) ? $_identify_rs['data']['pi'] : ''; } catch (Exception $e) { return $this->huoError($e->getCode(), $e->getMessage()); } } else { $_identify_from = get_val($_im_info, 'identify_from', ''); $_identify_pi = get_val($_im_info, 'identify_pi', ''); } return $this->afterIdentify($mem_id, $id_card, $real_name, $type, $_identify_from, $_identify_pi, $app_id); } /** * 实名后操作 * * @param $mem_id * @param $id_card * @param $real_name * @param $type * @param $identify_from * @param $identify_pi * @param $app_id * * @return array */ public function afterIdentify($mem_id, $id_card, $real_name, $type, $identify_from, $identify_pi, $app_id) { $_im_model = new IdentifyMemModel(); $_old_id_data = $_im_model->getInfoByMemId($mem_id); $_old_id_card = get_val($_old_id_data, 'id_card', ''); $_old_real_name = get_val($_old_id_data, 'real_name', ''); $_old_identify_pi = get_val($_old_id_data, 'identify_pi', ''); if ($_old_id_card != $id_card || $_old_real_name != $real_name || $_old_identify_pi != $identify_pi) { /* 有变化 */ $_data = [ 'identify_from' => $identify_from, 'mem_id' => $mem_id, 'real_name' => $real_name, 'id_card' => $id_card, 'identify_type' => $type, ]; if (!empty($identify_pi)) { $_data['identify_pi'] = $identify_pi; } if (empty($_old_id_data)) { $_rs = $_im_model->addData($_data); } else { $_rs = $_im_model->updateData($_data, $_old_id_data['id']); } if (false === $_rs) { return $this->huoSuccess(MemberStatus::INNER_ERROR, MemberStatus::getMsg(MemberStatus::INNER_ERROR)); } if (!empty($identify_pi)) { $this->updatePiInfo($id_card, $real_name, $identify_pi, $identify_from); } $_mem_data = [ 'status' => MemConst::STATUS_NORMAL ]; $_mem_data['real_name'] = $real_name; $_mem_data['id_card'] = $id_card; $_mem_data['identify_type'] = $type; (new MemberModel())->updateData($_mem_data, $mem_id); /* 实名认证成功获取积分 */ if (empty($_old_id_card)) { (new MemIa($mem_id))->doItgAct(IaConst::IA_IDENTIFY); } } $_data = $this->getIdentifyByMemId($mem_id); $_age = IdentifyUtils::getAgeById($id_card); if ($_age < 18) { /* 小于18岁校验是否可以玩游戏 */ $_url = (new Online($app_id, $mem_id, ''))->checkUnderageLimitOnTheHour(); if (!empty($_url)) { $_code = IdentifyStatus::IDENTITY_NOT_ALLOW_LOGIN; $_data['url'] = $_url; return $this->huoSuccess($_code, IdentifyStatus::getMsg($_code), $_data); } } return $this->retSucMsg(IdentifyStatus::NO_ERROR, $_data); } /** * 获取游戏实名认证信息 * * @param int $app_id 游戏id * @param int $mem_id 会员id * @param string $device_type 设备类型 * * @return array */ public function getAuthInfo($app_id, $mem_id, $device_type = DeviceTypeConst::DEVICE_TYPE_MP) { /*定义返回数组*/ $_data = []; $_is_auth = $this->getGameAuthByAppId($app_id); if (GameConst::GAME_IDENTIFY_IS_NO == $_is_auth) { return $_data; } $_data['auth_info'] = $this->getIdentifyByMemId($mem_id); $_data['url'] = ''; if (IdentifyConst::IS_AUTH_NO == $_data['auth_info']['is_auth']) { $_param = [ 'token' => session_id(), 'app_id' => $app_id, 'device_type' => $device_type, ]; $_data['url'] = MemConst::getIdentifyUrl($_param); } return $_data; } /** * 上报登录行为 * * @param $app_id * @param $mem_id * * @return array|bool */ public function reportLoginBehavior($app_id, $mem_id) { return $this->reportCommon($app_id, $mem_id, CommonConst::STATUS_YES); } /** * 上报退出登录行为 * * @param $app_id * @param $mem_id * * @return array|bool */ public function reportLogoutBehavior($app_id, $mem_id) { return $this->reportCommon($app_id, $mem_id, CommonConst::STATUS_NO); } public function reportCommon($app_id, $mem_id, $is_login = CommonConst::STATUS_YES, $from_queue = false) { if (false === $from_queue) { $_rs = (new ReportQueue())->push($app_id, $mem_id, $is_login); if (true === $_rs) { $_code = IdentifyStatus::NO_ERROR; return $this->huoSuccess($_code, CommonStatus::getMsg($_code)); } } $_identify_mem_info = (new IdentifyMemModel())->getInfoByMemId($mem_id); if (!empty($_identify_mem_info['id_card'])) { $_identify_from = Config::get('identify_conf.default'); if (!empty($app_id)) { $_identify_game_model = new IdentifyGameModel(); $_identify_game_info = (array)$_identify_game_model->getInfoByAppId($app_id); if (!empty($_identify_game_info['driver_key'])) { $_identify_from = $_identify_game_info['driver_key']; Config::set('identify_conf.default', $_identify_game_info['driver_key']); } } /* 需要pi的类型 */ $_need_pi_type = IdentifyConst::getNeedPiTypes(); try { $_identify_conf = \huoIdentify\controller\IdentifyDriverConf::getConfig($_identify_from, $app_id); $_id_card = isset($_identify_mem_info['id_card']) ? $_identify_mem_info['id_card'] : ''; $_real_name = isset($_identify_mem_info['real_name']) ? $_identify_mem_info['real_name'] : ''; $_identify_pi = isset($_identify_mem_info['identify_pi']) ? $_identify_mem_info['identify_pi'] : ''; if (empty($_identify_pi) && !empty($_id_card) && !empty($_real_name) && in_array($_identify_from, $_need_pi_type) ) { /* 游戏开启国家防沉迷认证但是玩家没有在国家防沉迷系统认证的需要前往认证 */ $_rs = $this->updateIdentify($mem_id, 1, $_real_name, $_id_card, $app_id); if (IdentifyStatus::NO_ERROR == $_rs['code']) { $_identify_pi = get_val($_rs['data'], 'identify_pi', ''); } } $_identify_class = \huoIdentify\identifyDriver\Identify::ins()->get($_identify_from, $_identify_conf); $_identify_class->setRealName($_real_name); $_identify_class->setIdCard($_id_card); $_identify_class->setMemId($mem_id); $_identify_class->setIdentifyFrom($_identify_from); $_mg_mem_id = (new MemGameModel())->getDefaultMgIdByMemAppId($mem_id, $app_id); $_identify_class->setMgMemId($_mg_mem_id); $_classify = (new \huoIdentify\model\GameModel())->getClassifyById($app_id); $_pf = GameConst::GAME_IOS == $_classify ? 2 : 1; /* 1 安卓 2 ios*/ $_identify_class->setPf($_pf); $_identify_class->setPi($_identify_pi); if ($is_login == CommonConst::STATUS_YES) { $_identify_rs = $_identify_class->loginBehavior($_identify_pi); } else { $_identify_rs = $_identify_class->logoutBehavior($_identify_pi); } if (CommonStatus::NO_ERROR != $_identify_rs['code']) { $_identify_rs['msg'] = '上报失败'; return $this->huoReturn($_identify_rs); } } catch (exception $e) { return $this->huoError($e->getCode(), $e->getMessage()); } } $_code = IdentifyStatus::NO_ERROR; return $this->huoSuccess($_code, CommonStatus::getMsg($_code)); } /** * 查询是否有认证中数据 * * @param $mem_id * @param $app_id */ protected function checkMemIdentify($mem_id, $app_id) { /* 限制速率 */ $_rs = (new RateLimit())->rateLimit($mem_id, true, true, 1, 3); if (false == $_rs) { return false; } $_identify_from = Config::get('identify_conf.default'); switch ($_identify_from) { case IdentifyConst::DRIVER_KEY_ALIPAY: case IdentifyConst::DRIVER_KEY_WXPAY: return false; case IdentifyConst::DRIVER_KEY_FCMGAME: try { $_identify_conf = \huoIdentify\controller\IdentifyDriverConf::getConfig($_identify_from, $app_id); } catch (exception $e) { return false; } $_in_progress_data = $this->getFcmGameInProgressData($mem_id, $_identify_conf['bizId']); break; default: $_in_progress_data = []; $_class_name = '\\huoIdentify\\identifyDriver\\driver\\'.ucfirst(strtolower($_identify_from)); if (class_exists($_class_name)) { $_status_in_progress = $_class_name::STATUS_IN_PROGRESS; /* 获取各实名驱动类的认证中状态值 */ $_in_progress_data = $this->getInProgressDataByMemAppFrom( $mem_id, $app_id, $_identify_from, $_status_in_progress ); } } if (empty($_in_progress_data)) { return false; } $_real_name = get_val($_in_progress_data, 'real_name', ''); $_id_card = get_val($_in_progress_data, 'id_card', ''); $_rs = $this->updateIdentify($mem_id, 1, $_real_name, $_id_card, $app_id); if (IdentifyStatus::NO_ERROR == $_rs['code']) { return true; } return false; } /** * 获取国家防沉迷系统认证中数据 * * @param $mem_id * @param $biz_id * * @return array */ public function getFcmGameInProgressData($mem_id, $biz_id) { $_io_data = (new IdentifyOrderModel())->getLastInfoByBizIdMem($biz_id, $mem_id); if (empty($_io_data)) { return []; } $_status = get_val($_io_data, 'status', 2); if (\huoIdentify\identifyDriver\driver\Fcmgame::STATUS_IN_PROGRESS != $_status) { /* 非认证中不处理 */ return []; } return $_io_data; } /** * 根据玩家id和游戏id获取实名认证中数据 * * @param $mem_id * @param $app_id * * @return array|bool */ public function getInProgressDataByMemApp($mem_id, $app_id) { $_identify_from = Config::get('identify_conf.default'); switch ($_identify_from) { case IdentifyConst::DRIVER_KEY_ALIPAY: case IdentifyConst::DRIVER_KEY_WXPAY: return false; case IdentifyConst::DRIVER_KEY_FCMGAME: try { $_identify_conf = \huoIdentify\controller\IdentifyDriverConf::getConfig($_identify_from, $app_id); } catch (exception $e) { return false; } $_in_progress_data = $this->getFcmGameInProgressData($mem_id, $_identify_conf['bizId']); break; default: $_in_progress_data = []; $_class_name = '\\huoIdentify\\identifyDriver\\driver\\'.ucfirst(strtolower($_identify_from)); if (class_exists($_class_name)) { $_status_in_progress = $_class_name::STATUS_IN_PROGRESS; /* 获取各实名驱动类的认证中状态值 */ $_in_progress_data = $this->getInProgressDataByMemAppFrom( $mem_id, $app_id, $_identify_from, $_status_in_progress ); } } return $_in_progress_data; } /** * 获取实名认证中的数据 * * @param int $mem_id 玩家id * @param int $app_id 游戏id * @param string $identify_from 认证平台 * @param int $status_in_progress 认证中状态 * * @return array */ private function getInProgressDataByMemAppFrom($mem_id, $app_id, $identify_from, $status_in_progress) { $_mg_mem_id = (new MemGameModel())->getDefaultMgIdByMemAppId($mem_id, $app_id); if (empty($_mg_mem_id)) { return []; } $_ipl_data = (new IdentifyPlatformLogModel())->getInfoByMgFrom($_mg_mem_id, $identify_from); if (empty($_ipl_data)) { return []; } $_status = get_val($_ipl_data, 'status', 0); if ($status_in_progress != $_status) { /* 非认证中不处理 */ return []; } return $_ipl_data; } /** * 根据身份证号获取pi信息 * * @param string $id_card 身份证号 * * @return array */ public function getPiInfoByIdCard($id_card) { $_pi_info = (new IdentifyPiModel())->getInfoByIdCard($id_card); // if (empty($_pi_info)) { // /* 此处兼容旧数据查找的一种方案可注释,也可将旧数据查找后写入信数据表中后注释 */ // $_pi_info = (new IdentifyMemModel())->getInfoByIdCard($id_card); // } return $_pi_info; } /** * 更新PI信息 * * @param string $id_card 身份证号 * @param string $real_name 真实姓名 * @param string $identify_pi 中宣部PI * @param string $identify_from 认证来源 * * @return bool|false|int */ public function updatePiInfo($id_card, $real_name, $identify_pi, $identify_from) { if (empty($id_card) || empty($real_name) || empty($identify_pi)) { return false; } $_ip_model = new IdentifyPiModel(); $_pi_info = $_ip_model->getInfoByIdCard($id_card); $_rs = true; if (empty($_pi_info)) { $_data = [ 'id_card' => $id_card, 'real_name' => $real_name, 'identify_pi' => $identify_pi, 'identify_from' => $identify_from, ]; $_rs = $_ip_model->addData($_data); } return $_rs; } }