This commit is contained in:
邹宗楠
2022-03-15 17:47:06 +08:00
parent 88783fa086
commit 7a7fe1b3da

View File

@@ -7,36 +7,35 @@ import (
)
func OnCallbackMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) {
if CurPurchaseHandler == nil {
return &mtwmapi.CallbackResponse{Data: "CurPurchaseHandler init fail"}
if CurPurchaseHandler != nil {
if msg.Cmd == mtwmapi.MsgTypeStoreStatusChanged || msg.Cmd == mtwmapi.MsgTypeStoreAuditStatusChanged {
response = CurPurchaseHandler.onStoreStatusChanged(msg)
} else if msg.Cmd == mtwmapi.MsgTypePrivateNumberDowngrade {
response = CurPurchaseHandler.onNumberDowngrade(msg)
} else if msg.Cmd == mtwmapi.MsgTypeStoreBind {
}
} else {
if orderID := GetOrderIDFromMsg(msg); orderID != "" {
jxutils.CallMsgHandler(func() {
switch msg.Cmd {
case mtwmapi.MsgTypeWaybillStatus:
response = CurPurchaseHandler.onWaybillMsg(msg)
default:
response = CurPurchaseHandler.onOrderMsg(msg)
}
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDMTWM))
}
/*if msg.Cmd == mtwmapi.MsgTypeOrderRefund || msg.Cmd == mtwmapi.MsgTypeOrderPartialRefund {
utils.CallFuncAsync(func() {
OnFinancialMsg(msg)
})
} */
}
// 获取orderId
orderID := GetOrderIDFromMsg(msg)
switch {
case msg.Cmd == mtwmapi.MsgTypeStoreStatusChanged || msg.Cmd == mtwmapi.MsgTypeStoreAuditStatusChanged:
response = CurPurchaseHandler.onStoreStatusChanged(msg)
case msg.Cmd == mtwmapi.MsgTypePrivateNumberDowngrade:
response = CurPurchaseHandler.onNumberDowngrade(msg)
case msg.Cmd == mtwmapi.MsgTypeStoreBind:
break
case orderID != "" && msg.Cmd == mtwmapi.MsgTypeWaybillStatus:
jxutils.CallMsgHandler(func() {
if msg.Cmd == mtwmapi.MsgTypeWaybillStatus {
response = CurPurchaseHandler.onWaybillMsg(msg)
} else {
response = CurPurchaseHandler.onOrderMsg(msg)
}
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDMTWM))
}
return response
}
func GetOrderIDFromMsg(msg *mtwmapi.CallbackMsg) string {
return msg.FormData.Get(mtwmapi.KeyOrderID)
}
func GetVendorStoreIDFromMsg(msg *mtwmapi.CallbackMsg) string {
return msg.FormData.Get(mtwmapi.KeyAppPoiCode)
}