- 同步相关操作添加excludeSkuIDs参数
This commit is contained in:
@@ -362,7 +362,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 []int, skuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func (v *VendorSync) SyncStoresSkus2(ctx *jxcontext.Context, db *dao.DaoDB, vendorIDs []int, storeIDs, excludeSkuIDs []int, skuIDs []int, setSyncStatus int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
globals.SugarLogger.Debug("SyncStoresSkus2")
|
||||
isManageIt := isAsync || len(storeIDs) != 1 || len(skuIDs) == 0 || len(skuIDs) > 8
|
||||
task, hint, err := v.LoopStoresMap2(ctx, db, fmt.Sprintf("同步门店商品信息:%v", storeIDs), isAsync, isManageIt, vendorIDs, storeIDs,
|
||||
@@ -380,7 +380,7 @@ 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 _, err = v.proxySyncStoreSku(ctx, task, storeMap, nil, skuIDs, false, isContinueWhenError); err != nil {
|
||||
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
|
||||
@@ -413,7 +413,7 @@ func (v *VendorSync) SyncStoresSkus(ctx *jxcontext.Context, db *dao.DaoDB, vendo
|
||||
if isForce {
|
||||
setSyncStatus = model.SyncFlagStoreSkuModifiedMask
|
||||
}
|
||||
return v.SyncStoresSkus2(ctx, db, vendorIDs, storeIDs, skuIDs, setSyncStatus, isAsync, isContinueWhenError)
|
||||
return v.SyncStoresSkus2(ctx, db, vendorIDs, storeIDs, skuIDs, nil, setSyncStatus, isAsync, isContinueWhenError)
|
||||
}
|
||||
|
||||
// func isUseOldSyncLogic(storeMap *model.StoreMap) bool {
|
||||
@@ -428,11 +428,11 @@ func (v *VendorSync) proxySyncStoreCategory(ctx *jxcontext.Context, parentTask t
|
||||
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 []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
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, 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) {
|
||||
|
||||
@@ -112,7 +112,7 @@ func SyncStorCategories(ctx *jxcontext.Context, parentTask tasksch.ITask, vendor
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func SyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, nameIDs, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func SyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID, storeID int, vendorStoreID string, nameIDs, skuIDs, excludeSkuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
singleStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
if singleStoreHandler != nil {
|
||||
if err = CreateStoreCategoryByStoreSku(ctx, vendorID, storeID, vendorStoreID, nameIDs, skuIDs); err != nil {
|
||||
@@ -127,7 +127,7 @@ func SyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendorID,
|
||||
_, err = SyncStorCategories(ctx, task, vendorID, storeID, vendorStoreID, nameIDs, skuIDs, false, isContinueWhenError)
|
||||
}
|
||||
case 1:
|
||||
err = syncStoreSkuNew(ctx, task, false, vendorID, storeID, nameIDs, skuIDs, isContinueWhenError)
|
||||
err = syncStoreSkuNew(ctx, task, false, vendorID, storeID, nameIDs, skuIDs, excludeSkuIDs, isContinueWhenError)
|
||||
}
|
||||
return result, err
|
||||
}, 2)
|
||||
@@ -154,9 +154,9 @@ func FullSyncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, vendo
|
||||
}
|
||||
case 1:
|
||||
if singleStoreHandler != nil {
|
||||
_, err = SyncStoreSkuNew(ctx, task, vendorID, storeID, vendorStoreID, nil, nil, false, isContinueWhenError)
|
||||
_, err = SyncStoreSkuNew(ctx, task, vendorID, storeID, vendorStoreID, nil, nil, nil, false, isContinueWhenError)
|
||||
} else {
|
||||
err = syncStoreSkuNew(ctx, task, true, vendorID, storeID, nil, nil, isContinueWhenError)
|
||||
err = syncStoreSkuNew(ctx, task, true, vendorID, storeID, nil, nil, nil, isContinueWhenError)
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
@@ -252,7 +252,7 @@ func updateStoreSku(db *dao.DaoDB, vendorID int, storeSkuList []*dao.StoreSkuSyn
|
||||
return num, err
|
||||
}
|
||||
|
||||
func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bool, vendorID, storeID int, nameIDs, skuIDs []int, isContinueWhenError bool) (err error) {
|
||||
func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bool, vendorID, storeID int, nameIDs, skuIDs, excludeSkuIDs []int, isContinueWhenError bool) (err error) {
|
||||
db := dao.GetDB()
|
||||
storeDetail, err := dao.GetStoreDetail(db, storeID, vendorID)
|
||||
if err != nil {
|
||||
@@ -269,6 +269,16 @@ func syncStoreSkuNew(ctx *jxcontext.Context, parentTask tasksch.ITask, isFull bo
|
||||
if err != nil || len(skus) == 0 {
|
||||
return err
|
||||
}
|
||||
if len(excludeSkuIDs) > 0 {
|
||||
excludeSkuMap := jxutils.IntList2Map(excludeSkuIDs)
|
||||
var skus2 []*dao.StoreSkuSyncInfo
|
||||
for _, v := range skus {
|
||||
if excludeSkuMap[v.SkuID] == 0 {
|
||||
skus2 = append(skus2, v)
|
||||
}
|
||||
}
|
||||
skus = skus2
|
||||
}
|
||||
formalizeStoreSkuList(skus)
|
||||
|
||||
singleStoreHandler, _ := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||
|
||||
@@ -115,7 +115,7 @@ func doDailyWork() {
|
||||
// cms.CurVendorSync.FullSyncStoresSkus(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD}, nil, true, true)
|
||||
|
||||
SaveImportantTaskID(TaskNameSyncStoreSku, SpecialTaskID)
|
||||
taskID, _ := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD, model.VendorIDEBAI, model.VendorIDMTWM}, nil, nil, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true)
|
||||
taskID, _ := cms.CurVendorSync.SyncStoresSkus2(jxcontext.AdminCtx, dao.GetDB(), []int{model.VendorIDJD, model.VendorIDEBAI, model.VendorIDMTWM}, nil, nil, []int{27379, 30768}, model.SyncFlagSaleMask|model.SyncFlagPriceMask, true, true)
|
||||
SaveImportantTaskID(TaskNameSyncStoreSku, taskID)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user