feat(user): 新增三要素
This commit is contained in:
parent
6f77085c72
commit
f13dcda370
@ -74,18 +74,29 @@ func (l *BackgroundCheckLogic) BackgroundCheck(req *types.QueryReq) (resp *types
|
||||
}
|
||||
|
||||
// 3、二要素三要素核验
|
||||
twoVerification := service.TwoFactorVerificationRequest{
|
||||
//twoVerification := service.TwoFactorVerificationRequest{
|
||||
// Name: data.Name,
|
||||
// IDCard: data.IDCard,
|
||||
//}
|
||||
//verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
//if err != nil {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "人事背调, 二要素验证失败: %+v", err)
|
||||
//}
|
||||
//if !verification.Passed {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "人事背调, 二要素验证不通过: %+v", err)
|
||||
//}
|
||||
// 3、二要素三要素核验
|
||||
threeVerification := service.ThreeFactorVerificationRequest{
|
||||
Name: data.Name,
|
||||
IDCard: data.IDCard,
|
||||
}
|
||||
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "人事背调, 二要素验证失败: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "人事背调, 三要素验证失败: %+v", err)
|
||||
}
|
||||
if !verification.Passed {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "人事背调, 二要素验证不通过: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "人事背调, 三要素验证不通过: %+v", err)
|
||||
}
|
||||
|
||||
// 缓存
|
||||
queryCache := types.QueryCache{
|
||||
Name: data.Name,
|
||||
|
@ -74,16 +74,28 @@ func (l *CompanyInfoLogic) CompanyInfo(req *types.QueryReq) (resp *types.QueryRe
|
||||
}
|
||||
|
||||
// 3、二要素三要素核验
|
||||
twoVerification := service.TwoFactorVerificationRequest{
|
||||
//twoVerification := service.TwoFactorVerificationRequest{
|
||||
// Name: data.Name,
|
||||
// IDCard: data.IDCard,
|
||||
//}
|
||||
//verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
//if err != nil {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "企业报告, 二要素验证失败: %+v", err)
|
||||
//}
|
||||
//if !verification.Passed {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "企业报告, 二要素验证不通过: %+v", err)
|
||||
//}
|
||||
// 3、二要素三要素核验
|
||||
threeVerification := service.ThreeFactorVerificationRequest{
|
||||
Name: data.Name,
|
||||
IDCard: data.IDCard,
|
||||
}
|
||||
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "企业报告, 二要素验证失败: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "企业报告, 三要素验证失败: %+v", err)
|
||||
}
|
||||
if !verification.Passed {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "企业报告, 二要素验证不通过: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "企业报告, 三要素验证不通过: %+v", err)
|
||||
}
|
||||
// 缓存
|
||||
queryCache := types.QueryCache{
|
||||
|
@ -74,17 +74,30 @@ func (l *HomeServiceLogic) HomeService(req *types.QueryReq) (resp *types.QueryRe
|
||||
}
|
||||
|
||||
// 3、二要素三要素核验
|
||||
twoVerification := service.TwoFactorVerificationRequest{
|
||||
//twoVerification := service.TwoFactorVerificationRequest{
|
||||
// Name: data.Name,
|
||||
// IDCard: data.IDCard,
|
||||
//}
|
||||
//verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
//if err != nil {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "家政服务, 二要素验证失败: %+v", err)
|
||||
//}
|
||||
//if !verification.Passed {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "家政服务, 二要素验证不通过: %+v", err)
|
||||
//}
|
||||
// 3、二要素三要素核验
|
||||
threeVerification := service.ThreeFactorVerificationRequest{
|
||||
Name: data.Name,
|
||||
IDCard: data.IDCard,
|
||||
}
|
||||
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "家政服务, 二要素验证失败: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "家政服务, 三要素验证失败: %+v", err)
|
||||
}
|
||||
if !verification.Passed {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "家政服务, 二要素验证不通过: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "家政服务, 三要素验证不通过: %+v", err)
|
||||
}
|
||||
|
||||
// 缓存
|
||||
queryCache := types.QueryCache{
|
||||
Name: data.Name,
|
||||
|
@ -73,19 +73,30 @@ func (l *MarriageLogic) Marriage(req *types.QueryReq) (resp *types.QueryResp, er
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("验证码不正确"), "婚恋评估, 验证码不正确: %s", data.Mobile)
|
||||
}
|
||||
|
||||
//// 3、二要素三要素核验
|
||||
//twoVerification := service.TwoFactorVerificationRequest{
|
||||
// Name: data.Name,
|
||||
// IDCard: data.IDCard,
|
||||
//}
|
||||
//verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
//if err != nil {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "婚恋评估, 二要素验证失败: %+v", err)
|
||||
//}
|
||||
//if !verification.Passed {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "婚恋评估, 二要素验证不通过: %+v", err)
|
||||
//}
|
||||
// 3、二要素三要素核验
|
||||
twoVerification := service.TwoFactorVerificationRequest{
|
||||
threeVerification := service.ThreeFactorVerificationRequest{
|
||||
Name: data.Name,
|
||||
IDCard: data.IDCard,
|
||||
}
|
||||
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "婚恋评估, 二要素验证失败: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "婚恋评估, 三要素验证失败: %+v", err)
|
||||
}
|
||||
if !verification.Passed {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "婚恋评估, 二要素验证不通过: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "婚恋评估, 三要素验证不通过: %+v", err)
|
||||
}
|
||||
|
||||
// 缓存
|
||||
queryCache := types.QueryCache{
|
||||
Name: data.Name,
|
||||
|
@ -74,16 +74,28 @@ func (l *PreLoanBackgroundCheckLogic) PreLoanBackgroundCheck(req *types.QueryReq
|
||||
}
|
||||
|
||||
// 3、二要素三要素核验
|
||||
twoVerification := service.TwoFactorVerificationRequest{
|
||||
//twoVerification := service.TwoFactorVerificationRequest{
|
||||
// Name: data.Name,
|
||||
// IDCard: data.IDCard,
|
||||
//}
|
||||
//verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
//if err != nil {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "贷前背调, 二要素验证失败: %+v", err)
|
||||
//}
|
||||
//if !verification.Passed {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "贷前背调, 二要素验证不通过: %+v", err)
|
||||
//}
|
||||
// 3、二要素三要素核验
|
||||
threeVerification := service.ThreeFactorVerificationRequest{
|
||||
Name: data.Name,
|
||||
IDCard: data.IDCard,
|
||||
}
|
||||
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "贷前背调, 二要素验证失败: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "贷前背调, 三要素验证失败: %+v", err)
|
||||
}
|
||||
if !verification.Passed {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "贷前背调, 二要素验证不通过: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "贷前背调, 三要素验证不通过: %+v", err)
|
||||
}
|
||||
// 缓存
|
||||
queryCache := types.QueryCache{
|
||||
|
@ -74,16 +74,28 @@ func (l *RentalInfoLogic) RentalInfo(req *types.QueryReq) (resp *types.QueryResp
|
||||
}
|
||||
|
||||
// 3、二要素三要素核验
|
||||
twoVerification := service.TwoFactorVerificationRequest{
|
||||
//twoVerification := service.TwoFactorVerificationRequest{
|
||||
// Name: data.Name,
|
||||
// IDCard: data.IDCard,
|
||||
//}
|
||||
//verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
//if err != nil {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "租赁服务, 二要素验证失败: %+v", err)
|
||||
//}
|
||||
//if !verification.Passed {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "租赁服务, 二要素验证不通过: %+v", err)
|
||||
//}
|
||||
// 3、二要素三要素核验
|
||||
threeVerification := service.ThreeFactorVerificationRequest{
|
||||
Name: data.Name,
|
||||
IDCard: data.IDCard,
|
||||
}
|
||||
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "租赁服务, 二要素验证失败: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "租赁服务, 三要素验证失败: %+v", err)
|
||||
}
|
||||
if !verification.Passed {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "租赁服务, 二要素验证不通过: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "租赁服务, 三要素验证不通过: %+v", err)
|
||||
}
|
||||
// 缓存
|
||||
queryCache := types.QueryCache{
|
||||
|
@ -74,16 +74,28 @@ func (l *RiskAssessmentLogic) RiskAssessment(req *types.QueryReq) (resp *types.Q
|
||||
}
|
||||
|
||||
// 3、二要素三要素核验
|
||||
twoVerification := service.TwoFactorVerificationRequest{
|
||||
//twoVerification := service.TwoFactorVerificationRequest{
|
||||
// Name: data.Name,
|
||||
// IDCard: data.IDCard,
|
||||
//}
|
||||
//verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
//if err != nil {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "个人风险, 二要素验证失败: %+v", err)
|
||||
//}
|
||||
//if !verification.Passed {
|
||||
// return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "个人风险, 二要素验证不通过: %+v", err)
|
||||
//}
|
||||
// 3、二要素三要素核验
|
||||
threeVerification := service.ThreeFactorVerificationRequest{
|
||||
Name: data.Name,
|
||||
IDCard: data.IDCard,
|
||||
}
|
||||
verification, err := l.svcCtx.VerificationService.TwoFactorVerification(twoVerification)
|
||||
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(threeVerification)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "个人风险, 二要素验证失败: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "个人风险, 三要素验证失败: %+v", err)
|
||||
}
|
||||
if !verification.Passed {
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "个人风险, 二要素验证不通过: %+v", err)
|
||||
return nil, errors.Wrapf(xerr.NewErrCodeMsg(xerr.SERVER_COMMON_ERROR, verification.Err.Error()), "个人风险, 三要素验证不通过: %+v", err)
|
||||
}
|
||||
// 缓存
|
||||
queryCache := types.QueryCache{
|
||||
|
@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/tidwall/gjson"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@ -11,15 +12,18 @@ import (
|
||||
)
|
||||
|
||||
type VerificationService struct {
|
||||
c config.Config
|
||||
c config.Config
|
||||
westDexService *WestDexService
|
||||
}
|
||||
|
||||
func NewVerificationService(c config.Config) *VerificationService {
|
||||
func NewVerificationService(c config.Config, westDexService *WestDexService) *VerificationService {
|
||||
return &VerificationService{
|
||||
c: c,
|
||||
c: c,
|
||||
westDexService: westDexService,
|
||||
}
|
||||
}
|
||||
|
||||
// 二要素
|
||||
type TwoFactorVerificationRequest struct {
|
||||
Name string
|
||||
IDCard string
|
||||
@ -39,6 +43,13 @@ type TwoFactorVerificationData struct {
|
||||
Desc string `json:"desc"`
|
||||
}
|
||||
|
||||
// 三要素
|
||||
type ThreeFactorVerificationRequest struct {
|
||||
Name string
|
||||
IDCard string
|
||||
Mobile string
|
||||
}
|
||||
|
||||
// VerificationResult 定义校验结果结构体
|
||||
type VerificationResult struct {
|
||||
Passed bool
|
||||
@ -114,3 +125,51 @@ func (r *VerificationService) TwoFactorVerification(request TwoFactorVerificatio
|
||||
|
||||
return &VerificationResult{Passed: true, Err: nil}, nil
|
||||
}
|
||||
func (r *VerificationService) ThreeFactorVerification(request ThreeFactorVerificationRequest) (*VerificationResult, error) {
|
||||
threeElementsReq := map[string]interface{}{
|
||||
"name": request.Name,
|
||||
"idNo": request.IDCard,
|
||||
"phone": request.Mobile,
|
||||
}
|
||||
|
||||
resp, err := r.westDexService.CallAPI("G15BJ02", threeElementsReq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dataResult := gjson.GetBytes(resp, "data.code")
|
||||
if !dataResult.Exists() {
|
||||
return nil, fmt.Errorf("code 字段不存在")
|
||||
}
|
||||
code := dataResult.Int()
|
||||
switch code {
|
||||
case 1000:
|
||||
case 1002:
|
||||
return &VerificationResult{
|
||||
Passed: false,
|
||||
Err: &ValidationError{Message: "姓名、证件号、手机号信息不一致"},
|
||||
}, nil
|
||||
case 1003:
|
||||
return &VerificationResult{
|
||||
Passed: false,
|
||||
Err: &ValidationError{Message: "姓名、证件号、手机号信息不一致"},
|
||||
}, nil
|
||||
case 1004:
|
||||
return &VerificationResult{
|
||||
Passed: false,
|
||||
Err: &ValidationError{Message: "姓名不正确"},
|
||||
}, nil
|
||||
case 1005:
|
||||
return &VerificationResult{
|
||||
Passed: false,
|
||||
Err: &ValidationError{Message: "证件号码不正确"},
|
||||
}, nil
|
||||
default:
|
||||
dataResultMsg := gjson.GetBytes(resp, "data.msg")
|
||||
if !dataResultMsg.Exists() {
|
||||
return nil, fmt.Errorf("msg字段不存在")
|
||||
}
|
||||
return nil, fmt.Errorf("三要素核验错误状态响应: %s", dataResultMsg.String())
|
||||
}
|
||||
|
||||
return &VerificationResult{Passed: true, Err: nil}, nil
|
||||
}
|
||||
|
@ -45,13 +45,14 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
||||
Concurrency: 10,
|
||||
},
|
||||
)
|
||||
westDexService := service.NewWestDexService(c)
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
Redis: redis.MustNewRedis(redisConf),
|
||||
AlipayService: service.NewAliPayService(c),
|
||||
WechatPayService: service.NewWechatPayService(c),
|
||||
WestDexService: service.NewWestDexService(c),
|
||||
VerificationService: service.NewVerificationService(c),
|
||||
WestDexService: westDexService,
|
||||
VerificationService: service.NewVerificationService(c, westDexService),
|
||||
AsynqServer: asynqServer,
|
||||
AsynqService: service.NewAsynqService(c),
|
||||
UserModel: model.NewUserModel(db, c.CacheRedis),
|
||||
|
Loading…
Reference in New Issue
Block a user