From bd0694ca32baaa270328ed3d015b32981e0b261a Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 31 Oct 2019 09:30:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=99=9A=E8=87=AA=E5=8A=A8=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=97=B6=EF=BC=8C=E6=8E=92=E9=99=A4=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E9=97=A8=E5=BA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync.go | 50 ++++++++++------------------------- business/jxstore/misc/misc.go | 6 ++--- controllers/cms_sync.go | 2 +- 3 files changed, 18 insertions(+), 40 deletions(-) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index d7d03b007..750931e3e 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -358,7 +358,7 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v } // -func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) { +func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled bool, skuIDs, excludeSkuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) { globals.SugarLogger.Debug("SyncStoresSkus2") isManageIt := len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8 task, hint, err := v.LoopStoresMap2(ctx, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs, @@ -373,11 +373,13 @@ func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vend tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetIsContinueWhenError(isContinueWhenError), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { storeMap := batchItemList[0].(*model.StoreMap) - if setSyncStatus != 0 { - dao.SetStoreSkuSyncStatus(db, storeMap.VendorID, []int{storeMap.StoreID}, skuIDs, setSyncStatus) - } - if _, err = v.proxySyncStoreSku(ctx, task, storeMap, nil, skuIDs, excludeSkuIDs, false, isContinueWhenError); err != nil { - globals.SugarLogger.Debugf("SyncStoresSkus2 failed2 store:%d failed with error:%v", storeMap.StoreID, err) + if syncDisabled || storeMap.Status > model.StoreStatusDisabled { + if setSyncStatus != 0 { + dao.SetStoreSkuSyncStatus(db, storeMap.VendorID, []int{storeMap.StoreID}, skuIDs, setSyncStatus) + } + if _, err = v.proxySyncStoreSku(ctx, task, storeMap, nil, skuIDs, excludeSkuIDs, false, isContinueWhenError); err != nil { + globals.SugarLogger.Debugf("SyncStoresSkus2 failed2 store:%d failed with error:%v", storeMap.StoreID, err) + } } return nil, err }, loopMapInfo.StoreMapList) @@ -387,18 +389,6 @@ func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vend return nil, partner.AddVendorInfo2Err(err, loopMapInfo.VendorID) }, isContinueWhenError) if task != nil { - // if vendorErr := partner.IsErrChangePriceFailed(task.GetOriginalErr()); vendorErr != nil { - // platformList := make([]string, len(task.GetDetailErrList())) - // for k, v := range task.GetDetailErrList() { - // if vendorErr := partner.IsErrVendorError(v); vendorErr != nil { - // platformList[k] = model.VendorChineseNames[vendorErr.VendorID()] - // } else { - // platformList[k] = "未知" - // } - // } - // err = fmt.Errorf("同步价格失败\n失败平台:%s", strings.Join(platformList, ",")) - // } else { - // } err = makeSyncError(err) } return hint, err @@ -409,36 +399,22 @@ func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendo if isForce { setSyncStatus = model.SyncFlagStoreSkuModifiedMask } - return v.SyncStoresSkus2(ctx, db, vendorIDs, storeIDs, skuIDs, nil, setSyncStatus, isAsync, isContinueWhenError) + return v.SyncStoresSkus2(ctx, db, vendorIDs, storeIDs, true, skuIDs, nil, setSyncStatus, isAsync, isContinueWhenError) } -// func isUseOldSyncLogic(storeMap *model.StoreMap) bool { -// return false -// return globals.IsProductEnv() && storeMap.StoreID != 102652 // 绿城四季鲜店 -// } - func (v *VendorSync) proxySyncStoreCategory(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, nameIDs, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { - // if isUseOldSyncLogic(storeMap) { - // return v.GetStoreHandler(storeMap.VendorID).(partner.ISingleStoreHandler).SyncStoreCategory(ctx, parentTask, storeMap.StoreID, isAsync) - // } return SyncStorCategories(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, skuIDs, isAsync, isContinueWhenError) } func (v *VendorSync) proxySyncStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, nameIDs, skuIDs, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { - // if isUseOldSyncLogic(storeMap) { - // return v.GetStoreHandler(storeMap.VendorID).SyncStoreSkus(ctx, parentTask, storeMap.StoreID, skuIDs, isAsync, isContinueWhenError) - // } return SyncStoreSkuNew(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, nil, skuIDs, excludeSkuIDs, isAsync, isContinueWhenError) } func (v *VendorSync) proxyFullSyncStoreSku(ctx *jxcontext.Context, parentTask tasksch.ITask, storeMap *model.StoreMap, isAsync, isContinueWhenError bool) (hint string, err error) { - // if isUseOldSyncLogic(storeMap) { - // return v.GetStoreHandler(storeMap.VendorID).FullSyncStoreSkus(ctx, parentTask, storeMap.StoreID, isAsync, isContinueWhenError) - // } return FullSyncStoreSkuNew(ctx, parentTask, storeMap.VendorID, storeMap.StoreID, storeMap.VendorStoreID, isAsync, isContinueWhenError) } -func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { +func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs []int, syncDisabled, isAsync, isContinueWhenError bool) (hint string, err error) { globals.SugarLogger.Debug("FullSyncStoresSkus") hint, err = v.LoopStoresMap(ctx, db, fmt.Sprintf("初始化门店商品信息:%v", storeIDs), isAsync, true, vendorIDs, storeIDs, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (interface{}, error) { @@ -452,8 +428,10 @@ func (v *VendorSync) FullSyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, v tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetIsContinueWhenError(isContinueWhenError), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { storeMap := batchItemList[0].(*model.StoreMap) - if _, err = v.proxyFullSyncStoreSku(ctx, task, storeMap, false, isContinueWhenError); err != nil { - globals.SugarLogger.Debugf("FullSyncStoresSkus failed2 store:%d failed with error:%v", storeMap.StoreID, err) + if syncDisabled || storeMap.Status > model.StoreStatusDisabled { + if _, err = v.proxyFullSyncStoreSku(ctx, task, storeMap, false, isContinueWhenError); err != nil { + globals.SugarLogger.Debugf("FullSyncStoresSkus failed2 store:%d failed with error:%v", storeMap.StoreID, err) + } } return nil, err }, loopMapInfo.StoreMapList) diff --git a/business/jxstore/misc/misc.go b/business/jxstore/misc/misc.go index 8f62f7f92..807ba34a5 100644 --- a/business/jxstore/misc/misc.go +++ b/business/jxstore/misc/misc.go @@ -124,12 +124,12 @@ func doDailyWork() { globals.SugarLogger.Debug("doDailyWork") cms.SyncStoresCourierInfo(jxcontext.AdminCtx, nil, false, true) netprinter.RebindAllPrinters(jxcontext.AdminCtx, false, true) - // cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, true, true) + // cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, false, true, true) - cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, nil, []int{27379}, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true) + cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, false, nil, []int{27379}, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true) SaveImportantTaskID(TaskNameSyncStoreSku, SpecialTaskID) - taskID, _ := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDEBAI, model.VendorIDMTWM}, nil, nil, nil, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true) + taskID, _ := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDEBAI, model.VendorIDMTWM}, nil, false, nil, nil, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true) SaveImportantTaskID(TaskNameSyncStoreSku, taskID) InitEx() diff --git a/controllers/cms_sync.go b/controllers/cms_sync.go index 079ae7e04..687264cb2 100644 --- a/controllers/cms_sync.go +++ b/controllers/cms_sync.go @@ -115,7 +115,7 @@ func (c *SyncController) FullSyncStoresSkus() { if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs, params.VendorIDs, &vendorIDs); err != nil { return retVal, "", err } - retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, params.IsAsync, params.IsContinueWhenError) + retVal, err = cms.CurVendorSync.FullSyncStoresSkus(params.Ctx, db, vendorIDs, storeIDs, true, params.IsAsync, params.IsContinueWhenError) return retVal, "", err }) }