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

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

View File

@@ -30,6 +30,7 @@ const (
WaybillStatusCanceled = "100" // 配送单已取消
)
// APP方URL 推送用户或客服取消订单(必接)
const (
CancelReasonAcceptTimeout = 1001 // 系统取消,超时未确认
CancelReasonPayTimeout = 1002 // 系统取消在线支付订单15分钟未支付
@@ -43,6 +44,18 @@ const (
CancelReasonOther = 1301 // 其他原因
)
const (
ResTypePending = 0 // 未处理
ResTypeMerchantRefused = 1 // 商家驳回退款请求
ResTypeMerchantAgreed = 2 // 商家同意退款
ResTypeCSRefused = 3 // 客服驳回退款请求
ResTypeCSAgreed = 4 // 客服帮商家同意退款
ResTypeTimeoutAutoAgreed = 5 // 超过3小时自动同意
ResTypeAutoAgreed = 6 // 系统自动确认
ResTypeUserCancelApply = 7 // 用户取消退款申请
ResTypeUserCancelComplain = 8 // 用户取消退款申诉
)
const (
NotifyTypeApply = "apply" // 发起全款退款
NotifyTypePartyApply = "part" // 发起部分退款
@@ -70,12 +83,12 @@ type RefundSku struct {
type RefundSkuDetail struct {
AppFoodCode string `json:"app_food_code"`
BoxNum float32 `json:"box_num"`
BoxPrice float32 `json:"box_price"`
BoxPrice float64 `json:"box_price"`
Count int `json:"count"`
FoodName string `json:"food_name"`
FoodPrice float32 `json:"food_price"`
OriginFoodPrice float32 `json:"origin_food_price"`
RefundPrice float32 `json:"refund_price"`
FoodPrice float64 `json:"food_price"`
OriginFoodPrice float64 `json:"origin_food_price"`
RefundPrice float64 `json:"refund_price"`
SkuID string `json:"sku_id"`
Spec string `json:"spec"`
}