f
This commit is contained in:
@@ -72,6 +72,26 @@ func (l *VehicleCallbackLogic) Handle(r *http.Request) error {
|
|||||||
}
|
}
|
||||||
l.Infof("tianyuan vehicle callback body received, api_id=%s, order_no=%s, body_len=%d", apiID, orderNo, len(bodyBytes))
|
l.Infof("tianyuan vehicle callback body received, api_id=%s, order_no=%s, body_len=%d", apiID, orderNo, len(bodyBytes))
|
||||||
|
|
||||||
|
// 回调包裹格式通常为 { code:0, msg:\"成功\", order_id:\"...\", data:{...} },
|
||||||
|
// 这里只把 data 字段提取出来存到 QueryData 里,便于前端直接渲染。
|
||||||
|
type callbackWrapper struct {
|
||||||
|
Code json.RawMessage `json:"code"`
|
||||||
|
Msg json.RawMessage `json:"msg"`
|
||||||
|
OrderID json.RawMessage `json:"order_id"`
|
||||||
|
Data json.RawMessage `json:"data"`
|
||||||
|
Extra map[string]any `json:"-"` // 预留
|
||||||
|
}
|
||||||
|
var wrapper callbackWrapper
|
||||||
|
payload := bodyBytes
|
||||||
|
if len(bodyBytes) > 0 {
|
||||||
|
if err := json.Unmarshal(bodyBytes, &wrapper); err != nil {
|
||||||
|
l.Errorf("tianyuan vehicle callback unmarshal body failed, api_id=%s, order_no=%s, err=%v", apiID, orderNo, err)
|
||||||
|
} else if len(wrapper.Data) > 0 {
|
||||||
|
payload = wrapper.Data
|
||||||
|
l.Infof("tianyuan vehicle callback extracted data field, api_id=%s, order_no=%s, data_len=%d", apiID, orderNo, len(payload))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 1. 根据订单号找到订单
|
// 1. 根据订单号找到订单
|
||||||
order, err := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, orderNo)
|
order, err := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, orderNo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -115,7 +135,7 @@ func (l *VehicleCallbackLogic) Handle(r *http.Request) error {
|
|||||||
updated := false
|
updated := false
|
||||||
for i := range apiList {
|
for i := range apiList {
|
||||||
if apiList[i].ApiID == apiID {
|
if apiList[i].ApiID == apiID {
|
||||||
apiList[i].Data = json.RawMessage(bodyBytes)
|
apiList[i].Data = json.RawMessage(payload)
|
||||||
apiList[i].Success = true
|
apiList[i].Success = true
|
||||||
apiList[i].Timestamp = nowStr
|
apiList[i].Timestamp = nowStr
|
||||||
apiList[i].Error = ""
|
apiList[i].Error = ""
|
||||||
@@ -126,7 +146,7 @@ func (l *VehicleCallbackLogic) Handle(r *http.Request) error {
|
|||||||
if !updated {
|
if !updated {
|
||||||
apiList = append(apiList, service.APIResponseData{
|
apiList = append(apiList, service.APIResponseData{
|
||||||
ApiID: apiID,
|
ApiID: apiID,
|
||||||
Data: json.RawMessage(bodyBytes),
|
Data: json.RawMessage(payload),
|
||||||
Success: true,
|
Success: true,
|
||||||
Timestamp: nowStr,
|
Timestamp: nowStr,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user