fix
This commit is contained in:
@@ -122,31 +122,31 @@ func (r *VerificationService) ThreeFactorVerification(request ThreeFactorVerific
|
||||
return nil, fmt.Errorf("转换响应失败: %v", err)
|
||||
}
|
||||
|
||||
// 使用gjson获取resultCode
|
||||
resultCode := gjson.GetBytes(respBytes, "ctidRequest.ctidAuth.resultCode")
|
||||
if !resultCode.Exists() {
|
||||
// 解析data.code
|
||||
code := gjson.GetBytes(respBytes, "code")
|
||||
if !code.Exists() {
|
||||
return &VerificationResult{
|
||||
Passed: false,
|
||||
Err: &ValidationError{Message: "身份信息异常"},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 获取resultCode的第一个字符
|
||||
resultCodeStr := resultCode.String()
|
||||
if len(resultCodeStr) == 0 {
|
||||
return &VerificationResult{
|
||||
Passed: false,
|
||||
Err: &ValidationError{Message: "身份信息异常"},
|
||||
}, nil
|
||||
}
|
||||
|
||||
firstChar := string(resultCodeStr[0])
|
||||
if firstChar != "0" && firstChar != "5" {
|
||||
codeStr := code.String()
|
||||
switch codeStr {
|
||||
case "1000":
|
||||
// 一致
|
||||
return &VerificationResult{Passed: true, Err: nil}, nil
|
||||
case "1001":
|
||||
// 不一致
|
||||
return &VerificationResult{
|
||||
Passed: false,
|
||||
Err: &ValidationError{Message: "姓名、证件号、手机号信息不一致"},
|
||||
}, nil
|
||||
default:
|
||||
// 其他异常
|
||||
return &VerificationResult{
|
||||
Passed: false,
|
||||
Err: &ValidationError{Message: "身份信息异常"},
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &VerificationResult{Passed: true, Err: nil}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user