- 美团外卖退款与部分退款消息解析为具体参数
This commit is contained in:
@@ -38,10 +38,31 @@ type CallbackResponse struct {
|
|||||||
Data string `json:"data"`
|
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 {
|
type CallbackMsg struct {
|
||||||
FormData url.Values
|
|
||||||
Cmd string
|
Cmd string
|
||||||
|
FormData url.Values
|
||||||
|
Data interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -89,6 +110,15 @@ func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackR
|
|||||||
}
|
}
|
||||||
msg.FormData.Set(k, v.(string))
|
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 {
|
} else {
|
||||||
callbackResponse = SuccessResponse // 美团外卖PING消息没有sign
|
callbackResponse = SuccessResponse // 美团外卖PING消息没有sign
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const (
|
|||||||
WaybillStatusCanceled = "100" // 配送单已取消
|
WaybillStatusCanceled = "100" // 配送单已取消
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// APP方URL 推送用户或客服取消订单(必接)
|
||||||
const (
|
const (
|
||||||
CancelReasonAcceptTimeout = 1001 // 系统取消,超时未确认
|
CancelReasonAcceptTimeout = 1001 // 系统取消,超时未确认
|
||||||
CancelReasonPayTimeout = 1002 // 系统取消,在线支付订单15分钟未支付
|
CancelReasonPayTimeout = 1002 // 系统取消,在线支付订单15分钟未支付
|
||||||
@@ -43,6 +44,18 @@ const (
|
|||||||
CancelReasonOther = 1301 // 其他原因
|
CancelReasonOther = 1301 // 其他原因
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ResTypePending = 0 // 未处理
|
||||||
|
ResTypeMerchantRefused = 1 // 商家驳回退款请求
|
||||||
|
ResTypeMerchantAgreed = 2 // 商家同意退款
|
||||||
|
ResTypeCSRefused = 3 // 客服驳回退款请求
|
||||||
|
ResTypeCSAgreed = 4 // 客服帮商家同意退款
|
||||||
|
ResTypeTimeoutAutoAgreed = 5 // 超过3小时自动同意
|
||||||
|
ResTypeAutoAgreed = 6 // 系统自动确认
|
||||||
|
ResTypeUserCancelApply = 7 // 用户取消退款申请
|
||||||
|
ResTypeUserCancelComplain = 8 // 用户取消退款申诉
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
NotifyTypeApply = "apply" // 发起全款退款
|
NotifyTypeApply = "apply" // 发起全款退款
|
||||||
NotifyTypePartyApply = "part" // 发起部分退款
|
NotifyTypePartyApply = "part" // 发起部分退款
|
||||||
@@ -70,12 +83,12 @@ type RefundSku struct {
|
|||||||
type RefundSkuDetail struct {
|
type RefundSkuDetail struct {
|
||||||
AppFoodCode string `json:"app_food_code"`
|
AppFoodCode string `json:"app_food_code"`
|
||||||
BoxNum float32 `json:"box_num"`
|
BoxNum float32 `json:"box_num"`
|
||||||
BoxPrice float32 `json:"box_price"`
|
BoxPrice float64 `json:"box_price"`
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
FoodName string `json:"food_name"`
|
FoodName string `json:"food_name"`
|
||||||
FoodPrice float32 `json:"food_price"`
|
FoodPrice float64 `json:"food_price"`
|
||||||
OriginFoodPrice float32 `json:"origin_food_price"`
|
OriginFoodPrice float64 `json:"origin_food_price"`
|
||||||
RefundPrice float32 `json:"refund_price"`
|
RefundPrice float64 `json:"refund_price"`
|
||||||
SkuID string `json:"sku_id"`
|
SkuID string `json:"sku_id"`
|
||||||
Spec string `json:"spec"`
|
Spec string `json:"spec"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user