- 美团外卖退款与部分退款消息解析为具体参数

This commit is contained in:
gazebo
2019-05-12 17:13:51 +08:00
parent 0e68c408b9
commit 9620931eec
2 changed files with 49 additions and 6 deletions

View File

@@ -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