!!!门店相关的API全部添加vendorOrgCode依赖
This commit is contained in:
@@ -620,7 +620,7 @@ func (c *PurchaseHandler) ListOrders(ctx *jxcontext.Context, parentTask tasksch.
|
||||
toDate := fromDate.Add(24*time.Hour - 1)
|
||||
var vendorStoreIDs []string
|
||||
if vendorStoreID == "" {
|
||||
vendorStoreIDs, err = c.GetAllStoresVendorID(ctx)
|
||||
vendorStoreIDs, err = c.GetAllStoresVendorID(ctx, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ const (
|
||||
|
||||
type tEbaiStoreInfo struct {
|
||||
model.Store
|
||||
VendorOrgCode string `orm:"size(32)" json:"vendorOrgCode"` // 同一平台下不同的商户代码,如果只有一个,可以为空
|
||||
VendorStoreID string `orm:"column(vendor_store_id)"`
|
||||
RealLastOperator string
|
||||
EbaiStoreStatus int
|
||||
@@ -79,7 +80,7 @@ func getCoordintate(data interface{}) float64 {
|
||||
return utils.MustInterface2Float64(data)
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorStoreID string) (*dao.StoreDetail, error) {
|
||||
func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendorStoreID string) (*dao.StoreDetail, error) {
|
||||
baiduShopID := utils.Str2Int64WithDefault(vendorStoreID, 0)
|
||||
if baiduShopID == 0 {
|
||||
return nil, fmt.Errorf("饿百门店ID:%s非法,应该是一个整数", vendorStoreID)
|
||||
@@ -150,7 +151,9 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
|
||||
var stores []*tEbaiStoreInfo
|
||||
sql := `
|
||||
SELECT t1.*, t2.status ebai_store_status, t2.vendor_store_id,
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.status ebai_store_status, t2.vendor_store_id, t2.vendor_org_code,
|
||||
IF(t1.updated_at > t2.updated_at, t1.last_operator, t2.last_operator) real_last_operator, t2.sync_status
|
||||
FROM store t1
|
||||
JOIN store_map t2 ON t1.id = t2.store_id AND t2.vendor_id = ? AND (t2.deleted_at = ?)
|
||||
@@ -165,7 +168,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
if store.SyncStatus&model.SyncFlagDeletedMask == 0 {
|
||||
shopID = store.ID
|
||||
}
|
||||
store2, err2 := p.ReadStore(jxcontext.AdminCtx, store.VendorStoreID)
|
||||
store2, err2 := p.ReadStore(jxcontext.AdminCtx, store.VendorOrgCode, store.VendorStoreID)
|
||||
// globals.SugarLogger.Debugf("ebai UpdateStore2 store2:%s, err2:%v", utils.Format4Output(store2, true), err2)
|
||||
if err = err2; err == nil {
|
||||
if store2.ID == store.ID {
|
||||
@@ -174,7 +177,7 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
|
||||
}
|
||||
if err == nil {
|
||||
if shopID > 0 {
|
||||
err = p.UpdateStoreCustomID(jxcontext.AdminCtx, store.VendorStoreID, int64(shopID))
|
||||
err = p.UpdateStoreCustomID(jxcontext.AdminCtx, "", store.VendorStoreID, int64(shopID))
|
||||
} else if shopID == 0 {
|
||||
// todo remove out shop id
|
||||
}
|
||||
@@ -410,7 +413,7 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
|
||||
return params
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string) (storeStatus int, err error) {
|
||||
func (p *PurchaseHandler) GetStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string) (storeStatus int, err error) {
|
||||
ebaiStatus, err := api.EbaiAPI.ShopBusStatusGet("", utils.Str2Int64(vendorStoreID), ebaiapi.PlatformFlagElm)
|
||||
if err == nil {
|
||||
storeStatus = EbaiBusStatus2JxStatus(ebaiStatus)
|
||||
@@ -425,7 +428,7 @@ func (c *PurchaseHandler) onShopMsgPush(msg *ebaiapi.CallbackMsg) (response *eba
|
||||
storeStatus := model.StoreStatusOpened
|
||||
switch utils.Interface2String(msg.Body["msg_type"]) {
|
||||
case "online", "offline":
|
||||
storeStatus, err = c.GetStoreStatus(jxcontext.AdminCtx, storeID, vendorStoreID)
|
||||
storeStatus, err = c.GetStoreStatus(jxcontext.AdminCtx, "", storeID, vendorStoreID)
|
||||
case "shop_open", "shop_pause", "shop_close":
|
||||
if int(utils.ForceInterface2Int64(msg.Body["business_ele"])) == 1 {
|
||||
storeStatus = model.StoreStatusOpened
|
||||
@@ -447,12 +450,12 @@ func (c *PurchaseHandler) GetShopHealthInfo(vendorShopID string) (shopHealthInfo
|
||||
return shopHealthInfo, err
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, storeID int, vendorStoreID string, isSetEnable bool) (err error) {
|
||||
func (p *PurchaseHandler) EnableAutoAcceptOrder(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, isSetEnable bool) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, storeID int, vendorStoreID string, status int) (err error) {
|
||||
store, err := c.ReadStore(ctx, vendorStoreID)
|
||||
func (c *PurchaseHandler) UpdateStoreStatus(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, status int) (err error) {
|
||||
store, err := c.ReadStore(ctx, vendorOrgCode, vendorStoreID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -478,7 +481,7 @@ func (c *PurchaseHandler) updateStoreStatus(userName string, storeID int, vendor
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
||||
func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, vendorOrgCode string, storeID int, vendorStoreID string, opTimeList []int16) (err error) {
|
||||
params := map[string]interface{}{
|
||||
ebaiapi.KeyBaiduShopID: vendorStoreID,
|
||||
}
|
||||
@@ -489,7 +492,7 @@ func (c *PurchaseHandler) UpdateStoreOpTime(ctx *jxcontext.Context, storeID int,
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorStoreIDs []string, err error) {
|
||||
func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context, vendorOrgCode string) (vendorStoreIDs []string, err error) {
|
||||
shopList, err := api.EbaiAPI.ShopList(ebaiapi.SysStatusAll)
|
||||
if err == nil && len(shopList) > 0 {
|
||||
vendorStoreIDs = make([]string, len(shopList))
|
||||
@@ -500,7 +503,7 @@ func (c *PurchaseHandler) GetAllStoresVendorID(ctx *jxcontext.Context) (vendorSt
|
||||
return vendorStoreIDs, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorStoreID string, storeID int64) (err error) {
|
||||
func (c *PurchaseHandler) UpdateStoreCustomID(ctx *jxcontext.Context, vendorOrgCode string, vendorStoreID string, storeID int64) (err error) {
|
||||
if globals.EnableJdStoreWrite {
|
||||
err = api.EbaiAPI.ShopIDBatchUpdate([]string{vendorStoreID}, []string{utils.Int64ToStr(storeID)})
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestReadStore(t *testing.T) {
|
||||
result, err := CurPurchaseHandler.ReadStore(jxcontext.AdminCtx, testShopBaiduID)
|
||||
result, err := CurPurchaseHandler.ReadStore(jxcontext.AdminCtx, "", testShopBaiduID)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user