This commit is contained in:
2026-06-29 11:25:32 +08:00
parent 2eec7e5bbe
commit 40b50a5a5c
4 changed files with 42 additions and 19 deletions

View File

@@ -4,9 +4,18 @@ import "errors"
// 处理器相关错误类型
var (
ErrDatasource = errors.New("数据源异常")
ErrSystem = errors.New("系统异常")
ErrInvalidParam = errors.New("参数校验不正确")
ErrNotFound = errors.New("查询为空")
ErrContactBusiness = errors.New("请联系商务咨询")
ErrDatasource = errors.New("数据源异常")
ErrSystem = errors.New("系统异常")
ErrInvalidParam = errors.New("参数校验不正确")
ErrNotFound = errors.New("查询为空")
ErrContactBusiness = errors.New("请联系商务咨询")
)
// SuccessNoBillError 携带成功响应但不扣费(如活体检测 result=2
type SuccessNoBillError struct {
Response []byte
}
func (e *SuccessNoBillError) Error() string {
return "成功不扣费"
}

View File

@@ -8,9 +8,6 @@ import (
"tyapi-server/internal/domains/api/dto"
"tyapi-server/internal/domains/api/services/processors"
"tyapi-server/internal/infrastructure/external/shumai"
"tyapi-server/internal/shared/logger"
"go.uber.org/zap"
)
// ProcessIVYZX5Q2Request IVYZX5Q2 活体识别步骤二API处理方法
@@ -47,16 +44,13 @@ func ProcessIVYZX5Q2Request(ctx context.Context, params []byte, deps *processors
}
}
// result==2 时手动抛出错误(不通过/无记录,不返回正常响应
// result: 0-通过 1-不通过0/1 正常返回并扣费2-未找到结果(返回 codeDesc不扣费
var body struct {
Result int `json:"result"`
Result int `json:"result"`
CodeDesc string `json:"codeDesc"`
}
if err := json.Unmarshal(respBytes, &body); err == nil && body.Result == 2 {
log := logger.GetGlobalLogger()
log.Warn("IVYZX5Q2 活体检测 result=2 无记录或不通过,返回错误",
zap.Int("result", body.Result),
zap.ByteString("response", respBytes))
return nil, errors.Join(processors.ErrNotFound, errors.New("活体检测 result=2 无记录或不通过"))
return nil, &processors.SuccessNoBillError{Response: respBytes}
}
return respBytes, nil