- 美团外卖退款与部分退款消息解析为具体参数
This commit is contained in:
@@ -38,10 +38,31 @@ type CallbackResponse struct {
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// !!!特别注意,Data中的数据
|
||||
type CallbackSysInfo struct {
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
AppID string `json:"app_id"`
|
||||
Sig string `json:"sig"`
|
||||
}
|
||||
|
||||
// 全额退款没有Food, FoodList, Money项
|
||||
type CallbackRefundInfo struct {
|
||||
CallbackSysInfo
|
||||
OrderID int64 `json:"order_id"`
|
||||
NotifyType string `json:"notify_type"`
|
||||
Reason string `json:"reason"`
|
||||
ResType int `json:"res_type"`
|
||||
IsAppeal int `json:"is_appeal"`
|
||||
Pictures string `json:"pictures"`
|
||||
|
||||
Food string `json:"food"`
|
||||
FoodList []*RefundSkuDetail `json:"foodList"`
|
||||
Money float32 `json:"money"`
|
||||
}
|
||||
|
||||
type CallbackMsg struct {
|
||||
FormData url.Values
|
||||
Cmd string
|
||||
FormData url.Values
|
||||
Data interface{}
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -89,6 +110,15 @@ func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackR
|
||||
}
|
||||
msg.FormData.Set(k, v.(string))
|
||||
}
|
||||
if msg.Cmd == MsgTypeOrderRefund || msg.Cmd == MsgTypeOrderPartialRefund {
|
||||
var refundData *CallbackRefundInfo
|
||||
if err = utils.Map2StructByJson(data, &refundData, true); err == nil {
|
||||
if refundData.Food != "" {
|
||||
utils.UnmarshalUseNumber([]byte(refundData.Food), &refundData.FoodList)
|
||||
}
|
||||
msg.Data = refundData
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
callbackResponse = SuccessResponse // 美团外卖PING消息没有sign
|
||||
|
||||
Reference in New Issue
Block a user