- 只有存在相应的API才注册purchase partner

This commit is contained in:
gazebo
2019-04-24 07:19:44 +08:00
parent 6d787cd1a1
commit b1fcb3c4ae
10 changed files with 90 additions and 55 deletions

View File

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

View File

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