From e48efb45666cbb7938f3180f7a63509606a2b6df Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Fri, 23 Jan 2026 18:37:22 +0800 Subject: [PATCH] f --- .../processors/yysy/yysybe08_processor.go | 59 ++++++++++++++----- 1 file changed, 45 insertions(+), 14 deletions(-) diff --git a/internal/domains/api/services/processors/yysy/yysybe08_processor.go b/internal/domains/api/services/processors/yysy/yysybe08_processor.go index 3211342..3836d07 100644 --- a/internal/domains/api/services/processors/yysy/yysybe08_processor.go +++ b/internal/domains/api/services/processors/yysy/yysybe08_processor.go @@ -81,26 +81,57 @@ func ProcessYYSYBE08Request(ctx context.Context, params []byte, deps *processors shumaiResponse.Success = true } - // 构建返回结果 + // 检查响应状态码 + if shumaiResponse.Code != 200 { + // code != 200 表示请求失败,返回错误 + msg := shumaiResponse.Msg + if msg == "" { + msg = "数据源异常" + } + return nil, fmt.Errorf("%s: %s", processors.ErrDatasource, msg) + } + + // code == 200 时,根据 data.result 判断验证结果 + // result: 0 一致(收费),1 不一致(收费),2 无记录(预留) resultCode := "0XXX" // 默认成功 resultMsg := "验证通过" verifyResult := "一致" - if shumaiResponse.Code == 400 { + switch shumaiResponse.Data.Result { + case 0: + // 一致(验证通过) + resultCode = "0XXX" + resultMsg = "验证通过" + verifyResult = "一致" + // 如果desc字段有值,使用desc作为resultMsg + if shumaiResponse.Data.Desc != "" { + resultMsg = shumaiResponse.Data.Desc + } + case 1: + // 不一致(验证失败) resultCode = "5XXX" - resultMsg = "请输入有效的身份证号码" + resultMsg = "身份证号不匹配" verifyResult = "不一致" - } else { - // result: 0表示一致,非0表示不一致 - if shumaiResponse.Data.Result != 0 { - // 验证失败 - resultCode = "5XXX" - resultMsg = "身份证号不匹配" - verifyResult = "不一致" - // 如果desc字段有值,使用desc作为resultMsg - if shumaiResponse.Data.Desc != "" { - resultMsg = shumaiResponse.Data.Desc - } + // 如果desc字段有值,使用desc作为resultMsg + if shumaiResponse.Data.Desc != "" { + resultMsg = shumaiResponse.Data.Desc + } + case 2: + // 无记录 + resultCode = "5XXX" + resultMsg = "无记录" + verifyResult = "不一致" + // 如果desc字段有值,使用desc作为resultMsg + if shumaiResponse.Data.Desc != "" { + resultMsg = shumaiResponse.Data.Desc + } + default: + // 其他未知状态,按不一致处理 + resultCode = "5XXX" + resultMsg = "验证失败" + verifyResult = "不一致" + if shumaiResponse.Data.Desc != "" { + resultMsg = shumaiResponse.Data.Desc } } // 构建最终响应结构