f
This commit is contained in:
@@ -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 = "不一致"
|
||||
}
|
||||
}
|
||||
|
||||
// 构建目标格式的响应
|
||||
|
||||
Reference in New Issue
Block a user