new product

This commit is contained in:
liangzai 2025-04-24 17:15:48 +08:00
parent e7c2de0d55
commit b70b7abcda
2 changed files with 131 additions and 24 deletions

View File

@ -76,30 +76,42 @@ func (l *QueryServiceLogic) VerifyCode(mobile string, code string) error {
func (l *QueryServiceLogic) Verify(Name string, IDCard string, Mobile string) error {
if l.svcCtx.Config.SystemConfig.ThreeVerify {
// 三要素验证
threeVerification := service.ThreeFactorVerificationRequest{
Name: Name,
IDCard: IDCard,
Mobile: Mobile,
}
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
if err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "三要素验证失败: %+v", err)
}
if !verification.Passed {
return errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "三要素验证不通过: %+v", err)
}
return l.VerifyThreeFactors(Name, IDCard, Mobile)
} else {
twoVerification := service.TwoFactorVerificationRequest{
Name: Name,
IDCard: IDCard,
}
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
if err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "二要素验证失败: %+v", err)
}
if !verification.Passed {
return errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "二要素验证不通过: %+v", err)
}
// 二要素验证
return l.VerifyTwoFactors(Name, IDCard)
}
}
// VerifyTwoFactors 二要素验证
func (l *QueryServiceLogic) VerifyTwoFactors(Name string, IDCard string) error {
twoVerification := service.TwoFactorVerificationRequest{
Name: Name,
IDCard: IDCard,
}
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
if err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "二要素验证失败: %+v", err)
}
if !verification.Passed {
return errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "二要素验证不通过: %+v", err)
}
return nil
}
// VerifyThreeFactors 三要素验证
func (l *QueryServiceLogic) VerifyThreeFactors(Name string, IDCard string, Mobile string) error {
threeVerification := service.ThreeFactorVerificationRequest{
Name: Name,
IDCard: IDCard,
Mobile: Mobile,
}
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
if err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "三要素验证失败: %+v", err)
}
if !verification.Passed {
return errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "三要素验证不通过: %+v", err)
}
return nil
}
@ -185,7 +197,8 @@ var productProcessors = map[string]func(*QueryServiceLogic, *types.QueryServiceR
"toc_MobileDrugFraudRiskCheck": (*QueryServiceLogic).ProcessTocMobileDrugFraudRiskCheckLogic, // 手机号反赌反诈
"toc_MobileLocation": (*QueryServiceLogic).ProcessTocMobileLocationLogic, // 手机归属地
"toc_IDCardLocation": (*QueryServiceLogic).ProcessTocIDCardLocationLogic, // 身份证归属地
"toc_DebtRepayStress": (*QueryServiceLogic).ProcessTocDebtRepayStressLogic, // 偿贷压力
"toc_EducationInfo": (*QueryServiceLogic).ProcessTocEducationInfoLogic, // 学历信息查询
}
func (l *QueryServiceLogic) PreprocessLogic(req *types.QueryServiceReq, product string) (*types.QueryServiceResp, error) {
@ -1920,3 +1933,84 @@ func (l *QueryServiceLogic) ProcessTocIDCardLocationLogic(req *types.QueryServic
return &types.QueryServiceResp{Id: cacheNo}, nil
}
// ProcessTocDebtRepayStressLogic 偿贷压力
func (l *QueryServiceLogic) ProcessTocDebtRepayStressLogic(req *types.QueryServiceReq) (*types.QueryServiceResp, error) {
userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
if getUidErr != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 获取用户信息失败, %+v", getUidErr)
}
// AES解密
decryptData, DecryptDataErr := l.DecryptData(req.Data)
if DecryptDataErr != nil {
return nil, DecryptDataErr
}
// 校验参数
var data types.TocDebtRepayStress
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
}
if validatorErr := validator.Validate(data); validatorErr != nil {
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
}
// 验证三要素
if verifyErr := l.VerifyThreeFactors(data.Name, data.IDCard, data.Mobile); verifyErr != nil {
return nil, verifyErr
}
params := map[string]interface{}{
"mobile": data.Mobile,
"name": data.Name,
"id_card": data.IDCard,
}
cacheNo, cacheDataErr := l.CacheData(params, "toc_DebtRepayStress", userID)
if cacheDataErr != nil {
return nil, cacheDataErr
}
return &types.QueryServiceResp{Id: cacheNo}, nil
}
// ProcessTocEducationInfoLogic 学历信息查询
func (l *QueryServiceLogic) ProcessTocEducationInfoLogic(req *types.QueryServiceReq) (*types.QueryServiceResp, error) {
userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
if getUidErr != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 获取用户信息失败, %+v", getUidErr)
}
// AES解密
decryptData, DecryptDataErr := l.DecryptData(req.Data)
if DecryptDataErr != nil {
return nil, DecryptDataErr
}
// 校验参数
var data types.TocEducationInfo
if unmarshalErr := json.Unmarshal(decryptData, &data); unmarshalErr != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "查询服务, 解密后的数据格式不正确: %+v", unmarshalErr)
}
if validatorErr := validator.Validate(data); validatorErr != nil {
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.PARAM_VERIFICATION_ERROR, validatorErr.Error()), "查询服务, 参数不正确: %+v", validatorErr)
}
// 验证二要素
if verifyErr := l.VerifyTwoFactors(data.Name, data.IDCard); verifyErr != nil {
return nil, verifyErr
}
params := map[string]interface{}{
"name": data.Name,
"id_card": data.IDCard,
}
cacheNo, cacheDataErr := l.CacheData(params, "toc_EducationInfo", userID)
if cacheDataErr != nil {
return nil, cacheDataErr
}
return &types.QueryServiceResp{Id: cacheNo}, nil
}

View File

@ -187,3 +187,16 @@ type TocMobileLocation struct {
type TocIDCardLocation struct {
IDCard string `json:"id_card" validate:"required,idCard"`
}
// 偿贷压力
type TocDebtRepayStress struct {
Name string `json:"name" validate:"required,name"`
IDCard string `json:"id_card" validate:"required,idCard"`
Mobile string `json:"mobile" validate:"required,mobile"`
}
// 学历信息查询
type TocEducationInfo struct {
Name string `json:"name" validate:"required,name"`
IDCard string `json:"id_card" validate:"required,idCard"`
}