From 6e84869b9a4d52e732c586a58b29106187070060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 27 Jul 2020 09:04:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=BA=93=E5=AD=98=E5=86=8D?= =?UTF-8?q?=E6=AC=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/cms/sync.go | 72 ++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/business/jxstore/cms/sync.go b/business/jxstore/cms/sync.go index 0e8afaca8..19dd6dfd9 100644 --- a/business/jxstore/cms/sync.go +++ b/business/jxstore/cms/sync.go @@ -1116,45 +1116,45 @@ func (v *VendorSync) SyncJdsStoresSkus(ctx *jxcontext.Context, storeIDs []int, i } func syncJdsStoreStock(ctx *jxcontext.Context, db *dao.DaoDB, parentTask tasksch.ITask, storeSkus []*model.StoreSkuBind, storeMap *model.StoreMap, isAsync, isContinueWhenError bool) (err error) { - for _, storeSku := range storeSkus { - stock := 0 - storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID}) - if storeSku.JdsID != 0 { - if len(storeSku2) > 0 { - if storeSku2[0].Status == model.StoreSkuBindStatusNormal { - stock = 9999 - } - if storeMap.VendorStoreID != "" { - err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, stock, utils.Str2Int(storeMap.VendorStoreID)) - } - } else { - err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID)) - } - } - } - // task := tasksch.NewParallelTask("syncJdsStoreStock", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetParallelCount(1).SetBatchSize(20), ctx, - // func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { - // storeSku := batchItemList[0].(*model.StoreSkuBind) - // stock := 0 - // storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID}) - // if storeSku.JdsID != 0 { - // if len(storeSku2) > 0 { - // if storeSku2[0].Status == model.StoreSkuBindStatusNormal { - // stock = 9999 - // } - // if storeMap.VendorStoreID != "" { - // err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, stock, utils.Str2Int(storeMap.VendorStoreID)) - // } - // } else { - // err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID)) + // for _, storeSku := range storeSkus { + // stock := 0 + // storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID}) + // if storeSku.JdsID != 0 { + // if len(storeSku2) > 0 { + // if storeSku2[0].Status == model.StoreSkuBindStatusNormal && storeSku.Status == model.StoreSkuBindStatusNormal { + // stock = 9999 // } + // if storeMap.VendorStoreID != "" { + // err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, stock, utils.Str2Int(storeMap.VendorStoreID)) + // } + // } else { + // err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID)) // } - // return retVal, err - // }, storeSkus) - // tasksch.HandleTask(task, parentTask, true).Run() - // if !isAsync { - // _, err = task.GetResult(0) + // } // } + task := tasksch.NewParallelTask("syncJdsStoreStock", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError).SetParallelCount(1), ctx, + func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { + storeSku := batchItemList[0].(*model.StoreSkuBind) + stock := 0 + storeSku2, _ := dao.GetStoresSkusInfo(db, []int{storeMap.StoreID}, []int{storeSku.SkuID}) + if storeSku.JdsID != 0 { + if len(storeSku2) > 0 { + if storeSku2[0].Status == model.StoreSkuBindStatusNormal && storeSku.Status == model.StoreSkuBindStatusNormal { + stock = 9999 + } + if storeMap.VendorStoreID != "" { + err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, stock, utils.Str2Int(storeMap.VendorStoreID)) + } + } else { + err = api.JdShopAPI.UpdateSkuSiteStock(storeSku.JdsID, 0, utils.Str2Int(storeMap.VendorStoreID)) + } + } + return retVal, err + }, storeSkus) + tasksch.HandleTask(task, parentTask, true).Run() + if !isAsync { + _, err = task.GetResult(0) + } return err }