f
This commit is contained in:
@@ -51,22 +51,18 @@ func ProcessYYSYBE08Request(ctx context.Context, params []byte, deps *processors
|
|||||||
return json.Marshal(errorResponse)
|
return json.Marshal(errorResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析数脉响应数据 - 先解析外层结构
|
// 解析数脉 /v4/id_card/check 的 data 内容(CallAPIForm 返回的即 data 对象)
|
||||||
var shumaiResp struct {
|
// 数卖响应: result 0-一致 1-不一致 2-无记录(预留); desc 如 "一致"/"不一致"
|
||||||
Code int `json:"code"`
|
var shumaiData struct {
|
||||||
Msg string `json:"msg"`
|
|
||||||
Message string `json:"message"`
|
|
||||||
Data struct {
|
|
||||||
Result int `json:"result"`
|
Result int `json:"result"`
|
||||||
OrderNo string `json:"order_no"`
|
OrderNo string `json:"order_no"`
|
||||||
Desc string `json:"desc"`
|
Desc string `json:"desc"`
|
||||||
Sex string `json:"sex"`
|
Sex string `json:"sex"`
|
||||||
Birthday string `json:"birthday"`
|
Birthday string `json:"birthday"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
} `json:"data"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal(respBytes, &shumaiResp); err != nil {
|
if err := json.Unmarshal(respBytes, &shumaiData); err != nil {
|
||||||
// 解析失败,返回系统错误 - 转换为目标格式
|
// 解析失败,返回系统错误 - 转换为目标格式
|
||||||
errorResponse := map[string]interface{}{
|
errorResponse := map[string]interface{}{
|
||||||
"ctidRequest": map[string]interface{}{
|
"ctidRequest": map[string]interface{}{
|
||||||
@@ -82,22 +78,32 @@ func ProcessYYSYBE08Request(ctx context.Context, params []byte, deps *processors
|
|||||||
return json.Marshal(errorResponse)
|
return json.Marshal(errorResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据 verifyResult (desc) 设置 resultCode 和 verifyResult
|
// 按数卖 result 验证结果处理: 0-一致 1-不一致 2-无记录(预留)
|
||||||
// 0XXX: 一致, 5XXX: 不一致
|
// resultCode: 0XXX=一致, 5XXX=不一致/无记录
|
||||||
resultCode := "5XXX" // 默认为不一致
|
var resultCode, verifyResult, resultMsg string
|
||||||
verifyResult := "不一致" // 默认为不一致
|
switch shumaiData.Result {
|
||||||
if shumaiResp.Data.Desc == "一致" {
|
case 0: // 一致(收费)
|
||||||
resultCode = "0XXX"
|
resultCode = "0XXX"
|
||||||
verifyResult = "一致"
|
verifyResult = "一致"
|
||||||
}
|
resultMsg = shumaiData.Desc
|
||||||
|
|
||||||
resultMsg := shumaiResp.Msg
|
|
||||||
if resultMsg == "" {
|
|
||||||
resultMsg = shumaiResp.Message
|
|
||||||
}
|
|
||||||
if resultMsg == "" {
|
if resultMsg == "" {
|
||||||
resultMsg = "成功"
|
resultMsg = "成功"
|
||||||
}
|
}
|
||||||
|
case 1: // 不一致(收费)
|
||||||
|
resultCode = "5XXX"
|
||||||
|
verifyResult = "不一致"
|
||||||
|
resultMsg = shumaiData.Desc
|
||||||
|
if resultMsg == "" {
|
||||||
|
resultMsg = "不一致"
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
resultCode = "5XXX"
|
||||||
|
verifyResult = "不一致"
|
||||||
|
resultMsg = shumaiData.Desc
|
||||||
|
if resultMsg == "" {
|
||||||
|
resultMsg = "不一致"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 构建目标格式的响应
|
// 构建目标格式的响应
|
||||||
response := map[string]interface{}{
|
response := map[string]interface{}{
|
||||||
|
|||||||
Reference in New Issue
Block a user