每晚自动同步时,排除禁用门店

This commit is contained in:
gazebo
2019-10-31 09:30:37 +08:00
parent 48d6d5487b
commit bd0694ca32
3 changed files with 18 additions and 40 deletions

View File

@@ -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)

View File

@@ -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()

View File

@@ -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
})
}