From 4664c06c03c3969daf356b646141155221b0417c Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Sat, 24 Jan 2026 11:02:05 +0800 Subject: [PATCH] f --- .../processors/yysy/yysybe08_processor.go | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/internal/domains/api/services/processors/yysy/yysybe08_processor.go b/internal/domains/api/services/processors/yysy/yysybe08_processor.go index b551d2c..890acfb 100644 --- a/internal/domains/api/services/processors/yysy/yysybe08_processor.go +++ b/internal/domains/api/services/processors/yysy/yysybe08_processor.go @@ -51,22 +51,18 @@ func ProcessYYSYBE08Request(ctx context.Context, params []byte, deps *processors return json.Marshal(errorResponse) } - // 解析数脉响应数据 - 先解析外层结构 - var shumaiResp struct { - Code int `json:"code"` - Msg string `json:"msg"` - Message string `json:"message"` - Data struct { - Result int `json:"result"` - OrderNo string `json:"order_no"` - Desc string `json:"desc"` - Sex string `json:"sex"` - Birthday string `json:"birthday"` - Address string `json:"address"` - } `json:"data"` + // 解析数脉 /v4/id_card/check 的 data 内容(CallAPIForm 返回的即 data 对象) + // 数卖响应: result 0-一致 1-不一致 2-无记录(预留); desc 如 "一致"/"不一致" + var shumaiData struct { + Result int `json:"result"` + OrderNo string `json:"order_no"` + Desc string `json:"desc"` + Sex string `json:"sex"` + Birthday string `json:"birthday"` + Address string `json:"address"` } - if err := json.Unmarshal(respBytes, &shumaiResp); err != nil { + if err := json.Unmarshal(respBytes, &shumaiData); err != nil { // 解析失败,返回系统错误 - 转换为目标格式 errorResponse := map[string]interface{}{ "ctidRequest": map[string]interface{}{ @@ -82,21 +78,31 @@ func ProcessYYSYBE08Request(ctx context.Context, params []byte, deps *processors return json.Marshal(errorResponse) } - // 根据 verifyResult (desc) 设置 resultCode 和 verifyResult - // 0XXX: 一致, 5XXX: 不一致 - resultCode := "5XXX" // 默认为不一致 - verifyResult := "不一致" // 默认为不一致 - if shumaiResp.Data.Desc == "一致" { + // 按数卖 result 验证结果处理: 0-一致 1-不一致 2-无记录(预留) + // resultCode: 0XXX=一致, 5XXX=不一致/无记录 + var resultCode, verifyResult, resultMsg string + switch shumaiData.Result { + case 0: // 一致(收费) resultCode = "0XXX" verifyResult = "一致" - } - - resultMsg := shumaiResp.Msg - if resultMsg == "" { - resultMsg = shumaiResp.Message - } - if resultMsg == "" { - resultMsg = "成功" + resultMsg = shumaiData.Desc + if resultMsg == "" { + resultMsg = "成功" + } + case 1: // 不一致(收费) + resultCode = "5XXX" + verifyResult = "不一致" + resultMsg = shumaiData.Desc + if resultMsg == "" { + resultMsg = "不一致" + } + default: + resultCode = "5XXX" + verifyResult = "不一致" + resultMsg = shumaiData.Desc + if resultMsg == "" { + resultMsg = "不一致" + } } // 构建目标格式的响应