- 接收门店状态消息,本地同步状态,京东暂时无效

This commit is contained in:
gazebo
2019-04-12 16:22:22 +08:00
parent ca8d0b362b
commit 77c5a16c08
14 changed files with 233 additions and 53 deletions

View File

@@ -8,10 +8,7 @@ import (
)
func OnOrderCallbackMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) {
if msg.Cmd == mtwmapi.MsgTypePrivateNumberDowngrade {
response = mtwmapi.SuccessResponse
} else {
orderID := GetOrderIDFromMsg(msg)
if orderID := GetOrderIDFromMsg(msg); orderID != "" {
jxutils.CallMsgHandler(func() {
switch msg.Cmd {
case mtwmapi.MsgTypeWaybillStatus:
@@ -20,11 +17,13 @@ func OnOrderCallbackMsg(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackRes
response = curPurchaseHandler.onOrderMsg(msg)
}
}, jxutils.ComposeUniversalOrderID(orderID, model.VendorIDMTWM))
if msg.Cmd == mtwmapi.MsgTypeOrderRefund || msg.Cmd == mtwmapi.MsgTypeOrderPartialRefund {
utils.CallFuncAsync(func() {
OnFinancialMsg(msg)
})
}
}
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
}

View File

@@ -161,3 +161,32 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
func (p *PurchaseHandler) RefreshAllStoresID(ctx *jxcontext.Context, parentTask tasksch.ITask, isAsync bool) (hint string, err error) {
return "", errors.New("美团外卖不支持此操作")
}
func (p *PurchaseHandler) onStoreStatusChanged(msg *mtwmapi.CallbackMsg) (response *mtwmapi.CallbackResponse) {
var err error
poiStatus := int(utils.Str2Int64(msg.Data.Get("poi_status")))
vendorStoreID := msg.Data.Get("app_poi_code")
storeStatus := 0
if poiStatus == mtwmapi.MsgPoiStatusOpened {
storeStatus = model.StoreStatusOpened
} else if poiStatus == mtwmapi.MsgPoiStatusClosed {
storeStatus = model.StoreStatusClosed
} else if poiStatus == mtwmapi.MsgPoiStatusOffline {
storeStatus = model.StoreStatusDisabled
} else {
storeStatus, err = p.GetStoreStatus(jxcontext.AdminCtx, vendorStoreID)
}
if err == nil {
err = partner.CurStoreManager.OnStoreStatusChanged(vendorStoreID, model.VendorIDMTWM, storeStatus)
}
response = mtwmapi.Err2CallbackResponse(err, "")
return response
}
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorStoreID string) (storeStatus int, err error) {
result, err := api.MtwmAPI.PoiGet(vendorStoreID)
if err == nil {
return bizStatusMtwm2JX(int(utils.MustInterface2Int64(result["open_level"])), int(utils.MustInterface2Int64(result["is_online"]))), nil
}
return 0, err
}

View File

@@ -16,7 +16,7 @@ func TestSyncStoreCategory(t *testing.T) {
}
func TestSyncLocalStoreCategory(t *testing.T) {
hint, err := new(PurchaseHandler).SyncLocalStoreCategory(jxcontext.AdminCtx, nil, 100077, true)
hint, err := new(PurchaseHandler).SyncLocalStoreCategory(jxcontext.AdminCtx, nil, 100077, true, nil)
if err != nil {
t.Fatal(err)
}