- 只有存在相应的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,22 +8,24 @@ import (
) )
func OnCallbackMsg(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse) { func OnCallbackMsg(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse) {
if orderID := GetOrderIDFromMsg(msg); orderID != "" { if CurPurchaseHandler != nil {
jxutils.CallMsgHandler(func() { if orderID := GetOrderIDFromMsg(msg); orderID != "" {
switch msg.Cmd { jxutils.CallMsgHandler(func() {
case ebaiapi.CmdOrderCreate, ebaiapi.CmdOrderStatus, ebaiapi.CmdOrderUserCancel, ebaiapi.CmdOrderPartRefund: switch msg.Cmd {
response = CurPurchaseHandler.onOrderMsg(msg) case ebaiapi.CmdOrderCreate, ebaiapi.CmdOrderStatus, ebaiapi.CmdOrderUserCancel, ebaiapi.CmdOrderPartRefund:
case ebaiapi.CmdOrderDeliveryStatus: response = CurPurchaseHandler.onOrderMsg(msg)
response = CurPurchaseHandler.onWaybillMsg(msg) case ebaiapi.CmdOrderDeliveryStatus:
} response = CurPurchaseHandler.onWaybillMsg(msg)
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDEBAI)) }
} }, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDEBAI))
if msg.Cmd == ebaiapi.CmdOrderPartRefund || msg.Cmd == ebaiapi.CmdOrderUserCancel || msg.Cmd == ebaiapi.CmdOrderDeliveryStatus { }
utils.CallFuncAsync(func() { if msg.Cmd == ebaiapi.CmdOrderPartRefund || msg.Cmd == ebaiapi.CmdOrderUserCancel || msg.Cmd == ebaiapi.CmdOrderDeliveryStatus {
OnFinancialMsg(msg) utils.CallFuncAsync(func() {
}) OnFinancialMsg(msg)
} else if msg.Cmd == ebaiapi.CmdShopMsgPush { })
response = CurPurchaseHandler.onShopMsgPush(msg) } else if msg.Cmd == ebaiapi.CmdShopMsgPush {
response = CurPurchaseHandler.onShopMsgPush(msg)
}
} }
return response return response
} }

View File

@@ -19,8 +19,10 @@ type PurchaseHandler struct {
} }
func init() { func init() {
CurPurchaseHandler = new(PurchaseHandler) if api.EbaiAPI != nil {
partner.RegisterPurchasePlatform(CurPurchaseHandler) CurPurchaseHandler = new(PurchaseHandler)
partner.RegisterPurchasePlatform(CurPurchaseHandler)
}
} }
func EbaiBusStatus2JxStatus(ebaiStatus int) int { func EbaiBusStatus2JxStatus(ebaiStatus int) int {

View File

@@ -9,6 +9,7 @@ import (
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext" "git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals/api"
) )
var ( var (
@@ -20,8 +21,10 @@ type PurchaseHandler struct {
} }
func init() { func init() {
curPurchaseHandler = new(PurchaseHandler) if api.ElmAPI != nil {
partner.RegisterPurchasePlatform(curPurchaseHandler) curPurchaseHandler = new(PurchaseHandler)
partner.RegisterPurchasePlatform(curPurchaseHandler)
}
} }
func (c *PurchaseHandler) GetVendorID() int { func (c *PurchaseHandler) GetVendorID() int {
@@ -29,7 +32,10 @@ func (c *PurchaseHandler) GetVendorID() int {
} }
func OnCallbackMsg(msg *elmapi.CallbackMsg) (retVal *elmapi.CallbackResponse) { 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) { func (c *PurchaseHandler) OnCallbackMsg(msg *elmapi.CallbackMsg) (retVal *elmapi.CallbackResponse) {

View File

@@ -8,26 +8,35 @@ import (
) )
func OnOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) { func OnOrderMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
if retVal = curPurchaseHandler.OnOrderMsg(msg); retVal == nil { if curPurchaseHandler != nil {
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "") if retVal = curPurchaseHandler.OnOrderMsg(msg); retVal == nil {
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
}
} }
return retVal return retVal
} }
func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackResponse) { func OnWaybillMsg(msg *jdapi.CallbackDeliveryStatusMsg) (retVal *jdapi.CallbackResponse) {
if retVal = curPurchaseHandler.OnWaybillMsg(msg); retVal == nil { if curPurchaseHandler != nil {
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "") if retVal = curPurchaseHandler.OnWaybillMsg(msg); retVal == nil {
retVal = jdapi.Err2CallbackResponse(errors.New("Internal Error"), "")
}
} }
return retVal return retVal
} }
func OnStoreMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) { 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) { func OnAfterSaleMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
utils.CallFuncAsync(func() { if curPurchaseHandler != nil {
OnFinancialMsg(msg) utils.CallFuncAsync(func() {
}) OnFinancialMsg(msg)
})
}
return retVal 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/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model" "git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner" "git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/globals/api"
) )
var ( var (
@@ -16,8 +17,10 @@ type PurchaseHandler struct {
} }
func init() { func init() {
curPurchaseHandler = new(PurchaseHandler) if api.JdAPI != nil {
partner.RegisterPurchasePlatform(curPurchaseHandler) curPurchaseHandler = new(PurchaseHandler)
partner.RegisterPurchasePlatform(curPurchaseHandler)
}
} }
func (c *PurchaseHandler) GetVendorID() int { func (c *PurchaseHandler) GetVendorID() int {

View File

@@ -8,22 +8,24 @@ import (
) )
func OnOrderCallbackMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) { func OnOrderCallbackMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) {
if orderID := GetOrderIDFromMsg(msg); orderID != "" { if curPurchaseHandler != nil {
jxutils.CallMsgHandler(func() { if orderID := GetOrderIDFromMsg(msg); orderID != "" {
switch msg.Cmd { jxutils.CallMsgHandler(func() {
case mtwmapi.MsgTypeWaybillStatus: switch msg.Cmd {
response = curPurchaseHandler.onWaybillMsg(msg) case mtwmapi.MsgTypeWaybillStatus:
default: response = curPurchaseHandler.onWaybillMsg(msg)
response = curPurchaseHandler.onOrderMsg(msg) default:
} response = curPurchaseHandler.onOrderMsg(msg)
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDMTWM)) }
} }, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDMTWM))
if msg.Cmd == mtwmapi.MsgTypeOrderRefund || msg.Cmd == mtwmapi.MsgTypeOrderPartialRefund { }
utils.CallFuncAsync(func() { if msg.Cmd == mtwmapi.MsgTypeOrderRefund || msg.Cmd == mtwmapi.MsgTypeOrderPartialRefund {
OnFinancialMsg(msg) utils.CallFuncAsync(func() {
}) OnFinancialMsg(msg)
} else if msg.Cmd == mtwmapi.MsgTypeStoreStatusChanged { })
response = curPurchaseHandler.onStoreStatusChanged(msg) } else if msg.Cmd == mtwmapi.MsgTypeStoreStatusChanged {
response = curPurchaseHandler.onStoreStatusChanged(msg)
}
} }
return response return response
} }

View File

@@ -22,8 +22,10 @@ type PurchaseHandler struct {
} }
func init() { func init() {
curPurchaseHandler = new(PurchaseHandler) if api.MtwmAPI != nil {
partner.RegisterPurchasePlatform(curPurchaseHandler) curPurchaseHandler = new(PurchaseHandler)
partner.RegisterPurchasePlatform(curPurchaseHandler)
}
} }
func (c *PurchaseHandler) GetVendorID() int { func (c *PurchaseHandler) GetVendorID() int {

View File

@@ -8,9 +8,11 @@ import (
) )
func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) { func OnCallbackMsg(msg *weimobapi.CallbackMsg) (response *weimobapi.CallbackResponse) {
orderID := utils.Int64ToStr(msg.OrderNo) if curPurchaseHandler != nil {
jxutils.CallMsgHandler(func() { orderID := utils.Int64ToStr(msg.OrderNo)
response = curPurchaseHandler.onOrderMsg(msg) jxutils.CallMsgHandler(func() {
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDWSC)) response = curPurchaseHandler.onOrderMsg(msg)
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDWSC))
}
return response return response
} }

View File

@@ -24,8 +24,10 @@ type PurchaseHandler struct {
} }
func init() { func init() {
curPurchaseHandler = new(PurchaseHandler) if api.WeimobAPI != nil {
partner.RegisterPurchasePlatform(curPurchaseHandler) curPurchaseHandler = new(PurchaseHandler)
partner.RegisterPurchasePlatform(curPurchaseHandler)
}
} }
func (c *PurchaseHandler) GetVendorID() int { func (c *PurchaseHandler) GetVendorID() int {

View File

@@ -105,6 +105,8 @@ weixinToken = "17_roSCZgkCxhRnyFVtei0KdfHwdGP8PmLzJFhCieka4_X4_d-lgfaTxF6oIS6FE5
dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true" dbConnectStr = "root:WebServer@1@tcp(127.0.0.1:3306)/jxd_dev_0?charset=utf8mb4&loc=Local&parseTime=true"
[prod] [prod]
EnableDocs = false
jdToken = "ccb10daf-e6f5-4a58-ada5-b97f9073a137" jdToken = "ccb10daf-e6f5-4a58-ada5-b97f9073a137"
jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d" jdAppKey = "1dba76d40cac446ca500c0391a0b6c9d"
jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4" jdSecret = "a88d031a1e7b462cb1579f12e97fe7f4"
@@ -143,6 +145,9 @@ dingdingSecret = "LWrZAFeqUfuVv7n_tc8vPpCAx6PT4CwManx2XCVhJOqGsx2L5XCDuX1sAN_Jtv
dingdingCallbackURL = "http://callback.jxc4.com/dingding/msg" dingdingCallbackURL = "http://callback.jxc4.com/dingding/msg"
[jxgy] [jxgy]
httpport = 8088
EnableDocs = false
dbConnectStr = "root:WebServer@1@tcp(db1.int.jxc4.com:3306)/jxgy?charset=utf8mb4&loc=Local&parseTime=true" dbConnectStr = "root:WebServer@1@tcp(db1.int.jxc4.com:3306)/jxgy?charset=utf8mb4&loc=Local&parseTime=true"
jdToken = "b9f98667-9856-45e9-a31c-9a8862b1bfde" jdToken = "b9f98667-9856-45e9-a31c-9a8862b1bfde"