* @version : Huomp 1.0 */ namespace huomp\controller\finance; use huo\controller\common\Base; use huo\controller\member\MemCache; use huo\controller\wap\Option; use huo\model\finance\SettleModel; use huo\model\member\MemberModel; use huolib\constant\CacheConst; use huolib\constant\CommonConst; use huolib\constant\OptionConst; use huolib\status\CommonStatus; use huolib\status\IdentifyStatus; use huolib\status\MemberStatus; use huolib\tool\StrUtils; use think\Cache; class SettleVerifiedOut extends Base { public function getVerifiedCfg() { /* 获取实名认证配置 */ $_settle_set = OptionConst::SETTING_SETTLE_VERIFIED; $_settle_set_item = (new Option())->getOptionData($_settle_set); $_verified = [ 'is_verified' => CommonConst::STATUS_NO, //是否需要实名 1 不需要 2需要 'first_verified' => CommonConst::STATUS_NO, //首单是否需要实名 1 不需要 2需要 'mobile_must' => CommonConst::STATUS_NO, //手机号是否必填 1 不需要 2需要 ]; if (!empty($_settle_set_item['option_value'])) { $_option_value = json_decode($_settle_set_item['option_value'], true); $_verified = array_merge($_verified, $_option_value); } return $_verified; } /** * 判断是否实名 * * @param $mem_id * @param $agent_id * @param $real_name * @param $mobile * * @return array */ public function isVerified($mem_id, $agent_id, $real_name, $mobile) { $_verified = $this->getVerifiedCfg(); /* 不需要实名直接返回 */ if (CommonConst::STATUS_NO == $_verified['is_verified']) { $_code = CommonStatus::NO_ERROR; return $this->huoError($_code, CommonStatus::getMsg($_code), []); } /* 首次不需要实名,判断是首次则直接返回 */ if (CommonConst::STATUS_NO == $_verified['first_verified']) { $_withdraw_cnt = (new SettleModel())->getCnt($agent_id); if (empty($_withdraw_cnt)) { $_code = CommonStatus::NO_ERROR; return $this->huoError($_code, CommonStatus::getMsg($_code), []); } } /* 实名是否手机号必填 */ if (CommonConst::STATUS_YES == $_verified['mobile_must']) { if (empty($mobile)) { $_code = MemberStatus::PHONE_EMPTY; return $this->huoError($_code, MemberStatus::getMsg($_code), []); } $_rs = StrUtils::checkPhone($mobile); if (false == $_rs) { $_code = MemberStatus::PHONE_ERROR; return $this->huoError($_code, MemberStatus::getMsg($_code), []); } $_mobile_mem_id = (new MemberModel())->where(['mobile' => $mobile])->value('id'); if (!empty($_mobile_mem_id) && $mem_id != $_mobile_mem_id) { $_code = MemberStatus::PHONE_IS_BIND; return $this->huoError($_code, MemberStatus::getMsg($_code), []); } } if (empty($real_name)) { $_code = IdentifyStatus::REALNAME_EMPTY; return $this->huoError($_code, IdentifyStatus::getMsg($_code), []); } //将实名信息更新到玩家数据 $_mem_cache = MemCache::ins(); $_mem_data = $_mem_cache->getInfoById($mem_id); if ($_mem_data['real_name'] != $real_name) { $this->setRealNameCnt($real_name); //不相同表示新的名字,相同表示已统计过 } $_mem_data['real_name'] = $real_name; $_mem_data['mobile'] = $mobile; $_rs = $_mem_cache->updateMem($mem_id, $_mem_data); if (false == $_rs) { $_code = CommonStatus::INNER_ERROR; return $this->huoError($_code, IdentifyStatus::getMsg($_code), []); } $_code = CommonStatus::NO_ERROR; return $this->huoSuccess($_code, IdentifyStatus::getMsg($_code), []); } /** * 获取某个名字的玩家数量 * * @param $real_name * * @return array|mixed */ public function getRealNameCnt($real_name) { if (empty($real_name)) { return 0; } $_cache_key = CacheConst::CACHE_REAL_NAME_PREFIX.md5($real_name); $_rdata = Cache::get($_cache_key); if (!empty($_rdata)) { return $_rdata; } $_cnt = (new MemberModel())->where(['real_name' => $real_name])->count(); if (empty($_cnt)) { return 0; } Cache::set($_cache_key, $_cnt, CommonConst::CONST_DAY_SECONDS); return $_cnt; } /** * 设置某个名字的玩家数量 * * @param $real_name */ public function setRealNameCnt($real_name) { $_cache_key = CacheConst::CACHE_REAL_NAME_PREFIX.md5($real_name); $_rdata = $this->getRealNameCnt($real_name); $_rdata += 1; Cache::set($_cache_key, $_rdata, CommonConst::CONST_DAY_SECONDS); } /** * 判断玩家重名数是否达到限制 * * @param $real_name * * @return bool true 表示达到限制 false 表示未达到限制 */ public function isLimit($real_name) { $_setting_name = OptionConst::SETTING_SAME_NAME_CNT; $_option_value = ['same_cnt' => 0]; $_m = new Option(); $_item = $_m->getOptionData($_setting_name, 1, true); if (!empty($_item['option_value'])) { $_item['option_value'] = json_decode($_item['option_value'], true); } $_option_value = array_merge($_option_value, $_item['option_value']); if (empty($_option_value['same_cnt'])) { return false; } $_cnt = $this->getRealNameCnt($real_name); if ($_cnt >= $_option_value['same_cnt']) { return true; } return false; } }