同步函数增加parentTask
This commit is contained in:
@@ -797,7 +797,7 @@ func UpdateStoresSkus(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*St
|
||||
isAsync = asyncStoreSkuOpFilter(ctx, isAsync)
|
||||
num = int64(len(skuIDs))
|
||||
if num > 0 {
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, nil, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
@@ -805,7 +805,7 @@ func UpdateStoresSkus(ctx *jxcontext.Context, storeIDs []int, skuBindInfos []*St
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func UpdateStoresSkusByBind(ctx *jxcontext.Context, skuBindInfos []*StoreSkuBindInfo, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
func UpdateStoresSkusByBind(ctx *jxcontext.Context, parentTask tasksch.ITask, skuBindInfos []*StoreSkuBindInfo, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
if len(skuBindInfos) > maxStoreNameBind {
|
||||
return "", fmt.Errorf("门店商品信息大于%d", maxStoreNameBind)
|
||||
}
|
||||
@@ -848,7 +848,7 @@ func UpdateStoresSkusByBind(ctx *jxcontext.Context, skuBindInfos []*StoreSkuBind
|
||||
isAsync = asyncStoreSkuOpFilter(ctx, isAsync)
|
||||
if num > 0 {
|
||||
skuIDs := jxutils.IntMap2List(skuIDMap)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, parentTask, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
@@ -1292,7 +1292,7 @@ func UpdateStoresSkusSale(ctx *jxcontext.Context, storeIDs []int, skuBindSkuInfo
|
||||
skuIDs = append(skuIDs, v.SkuID)
|
||||
}
|
||||
db := dao.GetDB()
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
hint, err = CurVendorSync.SyncStoresSkus(ctx, nil, db, nil, storeIDs, skuIDs, false, isAsync, isContinueWhenError)
|
||||
}
|
||||
if num == 0 || !isAsync || hint == "" {
|
||||
hint = utils.Int64ToStr(num)
|
||||
@@ -2165,7 +2165,7 @@ func AutoSaleStoreSku(ctx *jxcontext.Context, storeIDs []int, isNeedSync bool) (
|
||||
}
|
||||
}
|
||||
if isNeedSync && len(skuIDs) > 0 {
|
||||
if _, err = CurVendorSync.SyncStoresSkus(ctx, db, nil, []int{storeID}, skuIDs, false, true, true); err != nil {
|
||||
if _, err = CurVendorSync.SyncStoresSkus(ctx, nil, db, nil, []int{storeID}, skuIDs, false, true, true); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -2895,6 +2895,7 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync,
|
||||
}
|
||||
}
|
||||
}
|
||||
var storeSkuBindInfo []*StoreSkuBindInfo
|
||||
for k, v := range skuNameMap {
|
||||
skuBindInfo := &StoreSkuBindInfo{
|
||||
StoreID: store.ID,
|
||||
@@ -2904,8 +2905,9 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync,
|
||||
IsSale: 1,
|
||||
Skus: skuInfoMap[k],
|
||||
}
|
||||
retVal = []*StoreSkuBindInfo{skuBindInfo}
|
||||
storeSkuBindInfo = append(storeSkuBindInfo, skuBindInfo)
|
||||
}
|
||||
retVal = storeSkuBindInfo
|
||||
return retVal, err
|
||||
}
|
||||
taskParallel := tasksch.NewParallelTask("根据skuID关注商品", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx, taskFunc, storeList)
|
||||
@@ -2916,7 +2918,7 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync,
|
||||
for _, v := range result1 {
|
||||
skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo))
|
||||
}
|
||||
UpdateStoresSkusByBind(ctx, skuBindInfos, true, true)
|
||||
UpdateStoresSkusByBind(ctx, task, skuBindInfos, true, true)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
@@ -3011,7 +3013,7 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuBindInfos []*StoreSkuBindInf
|
||||
for _, v := range result1 {
|
||||
skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo))
|
||||
}
|
||||
hint, err = UpdateStoresSkusByBind(ctx, skuBindInfos, isAsync, isContinueWhenError)
|
||||
hint, err = UpdateStoresSkusByBind(ctx, task, skuBindInfos, isAsync, isContinueWhenError)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
@@ -3101,7 +3103,7 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context, isAsync, i
|
||||
for _, v := range result1 {
|
||||
skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo))
|
||||
}
|
||||
UpdateStoresSkusByBind(ctx, skuBindInfos, isAsync, isContinueWhenError)
|
||||
UpdateStoresSkusByBind(ctx, nil, skuBindInfos, isAsync, isContinueWhenError)
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user