From 040f6eef6522736e9e6512df56964753c93fcc44 Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Sat, 21 Mar 2026 18:51:51 +0800 Subject: [PATCH] f --- .../processors/yysy/yysybe08_processor.go | 57 ++++++++++++++++++- .../processors/yysy/yysybe08test_processor.go | 54 +----------------- 2 files changed, 58 insertions(+), 53 deletions(-) diff --git a/internal/domains/api/services/processors/yysy/yysybe08_processor.go b/internal/domains/api/services/processors/yysy/yysybe08_processor.go index 20d5298..5d82dc0 100644 --- a/internal/domains/api/services/processors/yysy/yysybe08_processor.go +++ b/internal/domains/api/services/processors/yysy/yysybe08_processor.go @@ -46,7 +46,62 @@ func ProcessYYSYBE08Request(ctx context.Context, params []byte, deps *processors } return nil, errors.Join(processors.ErrSystem, aerr) } - return dataBytes, nil + var aliyunData struct { + Result int `json:"result"` + Desc string `json:"desc"` + } + if err := json.Unmarshal(dataBytes, &aliyunData); err != nil { + errorResponse := map[string]interface{}{ + "ctidRequest": map[string]interface{}{ + "ctidAuth": map[string]interface{}{ + "idCard": paramsDto.IDCard, + "name": paramsDto.Name, + "resultCode": "500", + "resultMsg": "响应解析失败", + "verifyResult": "", + }, + }, + } + return json.Marshal(errorResponse) + } + + var resultCode, verifyResult, resultMsg string + switch aliyunData.Result { + case 0: + resultCode = "0XXX" + verifyResult = "一致" + resultMsg = aliyunData.Desc + if resultMsg == "" { + resultMsg = "成功" + } + case 1: + resultCode = "5XXX" + verifyResult = "不一致" + resultMsg = aliyunData.Desc + if resultMsg == "" { + resultMsg = "不一致" + } + default: + resultCode = "5XXX" + verifyResult = "不一致" + resultMsg = aliyunData.Desc + if resultMsg == "" { + resultMsg = "不一致" + } + } + + response := map[string]interface{}{ + "ctidRequest": map[string]interface{}{ + "ctidAuth": map[string]interface{}{ + "idCard": paramsDto.IDCard, + "name": paramsDto.Name, + "resultCode": resultCode, + "resultMsg": resultMsg, + "verifyResult": verifyResult, + }, + }, + } + return json.Marshal(response) } } diff --git a/internal/domains/api/services/processors/yysy/yysybe08test_processor.go b/internal/domains/api/services/processors/yysy/yysybe08test_processor.go index e54e680..3341f81 100644 --- a/internal/domains/api/services/processors/yysy/yysybe08test_processor.go +++ b/internal/domains/api/services/processors/yysy/yysybe08test_processor.go @@ -9,7 +9,7 @@ import ( "tyapi-server/internal/domains/api/services/processors" ) -// ProcessYYSYBE08testRequest 与 YYSYBE08 相同入参,底层使用阿里云市场身份证二要素校验;响应映射为 ctidRequest.ctidAuth 格式 +// ProcessYYSYBE08testRequest 与 YYSYBE08 相同入参,底层使用阿里云市场身份证二要素校验;响应为阿里云接口 data(不做字段映射) func ProcessYYSYBE08testRequest(ctx context.Context, params []byte, deps *processors.ProcessorDependencies) ([]byte, error) { var paramsDto dto.YYSYBE08Req if err := json.Unmarshal(params, ¶msDto); err != nil { @@ -20,57 +20,7 @@ func ProcessYYSYBE08testRequest(ctx context.Context, params []byte, deps *proces return nil, errors.Join(processors.ErrInvalidParam, err) } - respBytes, err := callAliyunIDCardCheckRaw(ctx, deps, paramsDto.Name, paramsDto.IDCard) - if err != nil { - return nil, err - } - - var aliyunData struct { - Result int `json:"result"` - Desc string `json:"desc"` - } - if err := json.Unmarshal(respBytes, &aliyunData); err != nil { - return nil, errors.Join(processors.ErrSystem, err) - } - - var resultCode, verifyResult, resultMsg string - switch aliyunData.Result { - case 0: - resultCode = "0XXX" - verifyResult = "一致" - resultMsg = aliyunData.Desc - if resultMsg == "" { - resultMsg = "成功" - } - case 1: - resultCode = "5XXX" - verifyResult = "不一致" - resultMsg = aliyunData.Desc - if resultMsg == "" { - resultMsg = "不一致" - } - default: - resultCode = "5XXX" - verifyResult = "不一致" - resultMsg = aliyunData.Desc - if resultMsg == "" { - resultMsg = "不一致" - } - } - - response := map[string]interface{}{ - "ctidRequest": map[string]interface{}{ - "ctidAuth": map[string]interface{}{ - "idCard": paramsDto.IDCard, - "name": paramsDto.Name, - "resultCode": resultCode, - "resultMsg": resultMsg, - "verifyResult": verifyResult, - }, - }, - } - - return json.Marshal(response) + return callAliyunIDCardCheckRaw(ctx, deps, paramsDto.Name, paramsDto.IDCard) } // callAliyunIDCardCheckRaw POST api-mall/api/id_card/check(form: name、idcard),返回响应 data,供 YYSYBE08TEST 与 YYSYBE08 数脉失败兜底共用