- 接收门店状态消息,本地同步状态,京东暂时无效
This commit is contained in:
@@ -8,10 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func OnCallbackMsg(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse) {
|
||||
if msg.Cmd == ebaiapi.CmdOrderCreate ||
|
||||
msg.Cmd == ebaiapi.CmdOrderStatus ||
|
||||
msg.Cmd == ebaiapi.CmdOrderUserCancel {
|
||||
orderID := GetOrderIDFromMsg(msg)
|
||||
if orderID := GetOrderIDFromMsg(msg); orderID != "" {
|
||||
jxutils.CallMsgHandler(func() {
|
||||
switch msg.Cmd {
|
||||
case ebaiapi.CmdOrderCreate, ebaiapi.CmdOrderStatus, ebaiapi.CmdOrderUserCancel:
|
||||
@@ -25,13 +22,18 @@ func OnCallbackMsg(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse
|
||||
utils.CallFuncAsync(func() {
|
||||
OnFinancialMsg(msg)
|
||||
})
|
||||
} else if msg.Cmd == ebaiapi.CmdShopMsgPush {
|
||||
response = CurPurchaseHandler.onShopMsgPush(msg)
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
func GetOrderIDFromMsg(msg *ebaiapi.CallbackMsg) string {
|
||||
if tryOrderID, ok := msg.Body["order_id"].(string); ok {
|
||||
return tryOrderID
|
||||
if orderID := msg.Body["order_id"]; orderID != nil {
|
||||
if tryOrderID, ok := orderID.(string); ok {
|
||||
return tryOrderID
|
||||
}
|
||||
return utils.Int64ToStr(utils.MustInterface2Int64(orderID))
|
||||
}
|
||||
return utils.Int64ToStr(utils.MustInterface2Int64(msg.Body["order_id"]))
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error)
|
||||
}
|
||||
}
|
||||
|
||||
if ebaiStatus, err2 := api.EbaiAPI.ShopBusStatusGet("", baiduShopID, ebaiapi.PlatformFlagBaidu); err2 == nil {
|
||||
if ebaiStatus, err2 := api.EbaiAPI.ShopBusStatusGet("", baiduShopID, ebaiapi.PlatformFlagElm); err2 == nil {
|
||||
retVal.Status = EbaiBusStatus2JxStatus(ebaiStatus)
|
||||
}
|
||||
|
||||
@@ -394,3 +394,31 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorStoreID string) (storeStatus int, err error) {
|
||||
ebaiStatus, err := api.EbaiAPI.ShopBusStatusGet("", utils.Str2Int64(vendorStoreID), ebaiapi.PlatformFlagElm)
|
||||
if err == nil {
|
||||
storeStatus = EbaiBusStatus2JxStatus(ebaiStatus)
|
||||
}
|
||||
return storeStatus, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) onShopMsgPush(msg *ebaiapi.CallbackMsg) (response *ebaiapi.CallbackResponse) {
|
||||
var err error
|
||||
vendorStoreID := utils.Interface2String(msg.Body["baidu_shop_id"])
|
||||
storeStatus := model.StoreStatusOpened
|
||||
switch utils.Interface2String(msg.Body["msg_type"]) {
|
||||
case "online", "offline":
|
||||
storeStatus, err = c.GetStoreStatus(jxcontext.AdminCtx, vendorStoreID)
|
||||
case "shop_open":
|
||||
if utils.Interface2String(msg.Body["business_ele"]) == "1" {
|
||||
storeStatus = model.StoreStatusOpened
|
||||
} else {
|
||||
storeStatus = model.StoreStatusClosed
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
err = partner.CurStoreManager.OnStoreStatusChanged(vendorStoreID, model.VendorIDEBAI, storeStatus)
|
||||
}
|
||||
return api.EbaiAPI.Err2CallbackResponse(msg.Cmd, err, nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user