This commit is contained in:
2026-07-06 12:38:41 +08:00
parent e8664ca2d7
commit ce9496ce8b

View File

@@ -10,8 +10,8 @@ import (
"tyapi-server/internal/infrastructure/external/shumai" "tyapi-server/internal/infrastructure/external/shumai"
) )
// 数脉 H5 活体结果查询中,以下 msg 表示检测不通过但属于正常业务响应,返回 result=1 并扣费。 // 数脉 H5 活体结果查询中,以下 msg 属于正常业务响应,返回 result=2 且不扣费。
var ivyzX5Q2BillableFailMsgs = map[string]struct{}{ var ivyzX5Q2NoBillFailMsgs = map[string]struct{}{
"动作中检测不到人脸": {}, "动作中检测不到人脸": {},
"用户拒绝打开摄像头": {}, "用户拒绝打开摄像头": {},
"未检测到人脸": {}, "未检测到人脸": {},
@@ -44,12 +44,12 @@ func ProcessIVYZX5Q2Request(ctx context.Context, params []byte, deps *processors
respBytes, err := deps.ShumaiService.CallAPIForm(ctx, apiPath, reqFormData) respBytes, err := deps.ShumaiService.CallAPIForm(ctx, apiPath, reqFormData)
if err != nil { if err != nil {
if shumaiErr := shumai.GetShumaiError(err); shumaiErr != nil && shumaiErr.IsParamError() { if shumaiErr := shumai.GetShumaiError(err); shumaiErr != nil && shumaiErr.IsParamError() {
if _, ok := ivyzX5Q2BillableFailMsgs[shumaiErr.Message]; ok { if _, ok := ivyzX5Q2NoBillFailMsgs[shumaiErr.Message]; ok {
resp, marshalErr := buildIVYZX5Q2FailResponse(ctx, shumaiErr.Message) resp, marshalErr := buildIVYZX5Q2FailResponse(ctx, shumaiErr.Message)
if marshalErr != nil { if marshalErr != nil {
return nil, errors.Join(processors.ErrSystem, marshalErr) return nil, errors.Join(processors.ErrSystem, marshalErr)
} }
return resp, nil return nil, &processors.SuccessNoBillError{Response: resp}
} }
} }
if errors.Is(err, shumai.ErrNotFound) { if errors.Is(err, shumai.ErrNotFound) {
@@ -81,7 +81,7 @@ func ProcessIVYZX5Q2Request(ctx context.Context, params []byte, deps *processors
func buildIVYZX5Q2FailResponse(ctx context.Context, codeDesc string) ([]byte, error) { func buildIVYZX5Q2FailResponse(ctx context.Context, codeDesc string) ([]byte, error) {
resp := ivyzX5Q2Resp{ resp := ivyzX5Q2Resp{
Result: 1, Result: 2,
CodeDesc: codeDesc, CodeDesc: codeDesc,
} }
if orderNo, ok := ctx.Value("transaction_id").(string); ok && orderNo != "" { if orderNo, ok := ctx.Value("transaction_id").(string); ok && orderNo != "" {