- 只有存在相应的API才注册purchase partner
This commit is contained in:
@@ -8,22 +8,24 @@ import (
|
||||
)
|
||||
|
||||
func OnCallbackMsg(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse) {
|
||||
if orderID := GetOrderIDFromMsg(msg); orderID != "" {
|
||||
jxutils.CallMsgHandler(func() {
|
||||
switch msg.Cmd {
|
||||
case ebaiapi.CmdOrderCreate, ebaiapi.CmdOrderStatus, ebaiapi.CmdOrderUserCancel, ebaiapi.CmdOrderPartRefund:
|
||||
response = CurPurchaseHandler.onOrderMsg(msg)
|
||||
case ebaiapi.CmdOrderDeliveryStatus:
|
||||
response = CurPurchaseHandler.onWaybillMsg(msg)
|
||||
}
|
||||
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDEBAI))
|
||||
}
|
||||
if msg.Cmd == ebaiapi.CmdOrderPartRefund || msg.Cmd == ebaiapi.CmdOrderUserCancel || msg.Cmd == ebaiapi.CmdOrderDeliveryStatus {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnFinancialMsg(msg)
|
||||
})
|
||||
} else if msg.Cmd == ebaiapi.CmdShopMsgPush {
|
||||
response = CurPurchaseHandler.onShopMsgPush(msg)
|
||||
if CurPurchaseHandler != nil {
|
||||
if orderID := GetOrderIDFromMsg(msg); orderID != "" {
|
||||
jxutils.CallMsgHandler(func() {
|
||||
switch msg.Cmd {
|
||||
case ebaiapi.CmdOrderCreate, ebaiapi.CmdOrderStatus, ebaiapi.CmdOrderUserCancel, ebaiapi.CmdOrderPartRefund:
|
||||
response = CurPurchaseHandler.onOrderMsg(msg)
|
||||
case ebaiapi.CmdOrderDeliveryStatus:
|
||||
response = CurPurchaseHandler.onWaybillMsg(msg)
|
||||
}
|
||||
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDEBAI))
|
||||
}
|
||||
if msg.Cmd == ebaiapi.CmdOrderPartRefund || msg.Cmd == ebaiapi.CmdOrderUserCancel || msg.Cmd == ebaiapi.CmdOrderDeliveryStatus {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnFinancialMsg(msg)
|
||||
})
|
||||
} else if msg.Cmd == ebaiapi.CmdShopMsgPush {
|
||||
response = CurPurchaseHandler.onShopMsgPush(msg)
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
@@ -19,8 +19,10 @@ type PurchaseHandler struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
CurPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(CurPurchaseHandler)
|
||||
if api.EbaiAPI != nil {
|
||||
CurPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(CurPurchaseHandler)
|
||||
}
|
||||
}
|
||||
|
||||
func EbaiBusStatus2JxStatus(ebaiStatus int) int {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -20,8 +21,10 @@ type PurchaseHandler struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
if api.ElmAPI != nil {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetVendorID() int {
|
||||
@@ -29,7 +32,10 @@ func (c *PurchaseHandler) GetVendorID() int {
|
||||
}
|
||||
|
||||
func OnCallbackMsg(msg *elmapi.CallbackMsg) (retVal *elmapi.CallbackResponse) {
|
||||
return curPurchaseHandler.OnCallbackMsg(msg)
|
||||
if curPurchaseHandler != nil {
|
||||
retVal = curPurchaseHandler.OnCallbackMsg(msg)
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) OnCallbackMsg(msg *elmapi.CallbackMsg) (retVal *elmapi.CallbackResponse) {
|
||||
|
||||
@@ -8,26 +8,35 @@ import (
|
||||
)
|
||||
|
||||
func OnOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if retVal = curPurchaseHandler.OnOrderMsg(msg); retVal == nil {
|
||||
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
|
||||
if curPurchaseHandler != nil {
|
||||
if retVal = curPurchaseHandler.OnOrderMsg(msg); retVal == nil {
|
||||
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
|
||||
}
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if retVal = curPurchaseHandler.OnWaybillMsg(msg); retVal == nil {
|
||||
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
|
||||
if curPurchaseHandler != nil {
|
||||
if retVal = curPurchaseHandler.OnWaybillMsg(msg); retVal == nil {
|
||||
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
|
||||
}
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
return curPurchaseHandler.onStoreMsg(msg)
|
||||
if curPurchaseHandler != nil {
|
||||
retVal = curPurchaseHandler.onStoreMsg(msg)
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func OnAfterSaleMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnFinancialMsg(msg)
|
||||
})
|
||||
if curPurchaseHandler != nil {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnFinancialMsg(msg)
|
||||
})
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -16,8 +17,10 @@ type PurchaseHandler struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
if api.JdAPI != nil {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetVendorID() int {
|
||||
|
||||
@@ -8,22 +8,24 @@ import (
|
||||
)
|
||||
|
||||
func OnOrderCallbackMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) {
|
||||
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)
|
||||
})
|
||||
} else if msg.Cmd == mtwmapi.MsgTypeStoreStatusChanged {
|
||||
response = curPurchaseHandler.onStoreStatusChanged(msg)
|
||||
if curPurchaseHandler != nil {
|
||||
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)
|
||||
})
|
||||
} else if msg.Cmd == mtwmapi.MsgTypeStoreStatusChanged {
|
||||
response = curPurchaseHandler.onStoreStatusChanged(msg)
|
||||
}
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ type PurchaseHandler struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
if api.MtwmAPI != nil {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetVendorID() int {
|
||||
|
||||
@@ -8,9 +8,11 @@ import (
|
||||
)
|
||||
|
||||
func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) {
|
||||
orderID := utils.Int64ToStr(msg.OrderNo)
|
||||
jxutils.CallMsgHandler(func() {
|
||||
response = curPurchaseHandler.onOrderMsg(msg)
|
||||
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDWSC))
|
||||
if curPurchaseHandler != nil {
|
||||
orderID := utils.Int64ToStr(msg.OrderNo)
|
||||
jxutils.CallMsgHandler(func() {
|
||||
response = curPurchaseHandler.onOrderMsg(msg)
|
||||
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDWSC))
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
@@ -24,8 +24,10 @@ type PurchaseHandler struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
if api.WeimobAPI != nil {
|
||||
curPurchaseHandler = new(PurchaseHandler)
|
||||
partner.RegisterPurchasePlatform(curPurchaseHandler)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetVendorID() int {
|
||||
|
||||
Reference in New Issue
Block a user