From f9373f3bda557f322d8f0502d1ca6ee69f170a57 Mon Sep 17 00:00:00 2001 From: gazebo Date: Thu, 13 Jun 2019 11:02:04 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=E4=BA=AC=E4=B8=9C?= =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=95=86=E5=93=81=E4=BF=A1=E6=81=AF=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E5=B0=91=E9=87=8F=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=90=8C=E6=AD=A5=E6=97=B6=EF=BC=8C=E6=8B=86=E5=BC=80?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E9=81=BF=E5=85=8D=E7=94=B1=E4=BA=8E=E5=8D=95?= =?UTF-8?q?=E4=B8=AASKU=E5=85=A8=E4=BD=93=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/jd/store_sku.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/business/partner/purchase/jd/store_sku.go b/business/partner/purchase/jd/store_sku.go index 352864e40..10a6e9e4b 100644 --- a/business/partner/purchase/jd/store_sku.go +++ b/business/partner/purchase/jd/store_sku.go @@ -32,7 +32,16 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks if err != nil { return "", err } - task := tasksch.NewParallelTask("syncStoreSkus京东", tasksch.NewParallelConfig().SetBatchSize(jdapi.MaxStoreSkuBatchSize).SetIsContinueWhenError(isContinueWhenError), ctx, + batchSize := jdapi.MaxStoreSkuBatchSize + storeSkusLen := len(storeSkus) + if storeSkusLen < jdapi.MaxStoreSkuBatchSize*2 { + batchSize = (storeSkusLen + 2) / 3 + } else if storeSkusLen < jdapi.MaxStoreSkuBatchSize { + batchSize = (storeSkusLen + 1) / 2 + } else if storeSkusLen < jdapi.MaxStoreSkuBatchSize/2 { + batchSize = 1 + } + task := tasksch.NewParallelTask("syncStoreSkus京东", tasksch.NewParallelConfig().SetBatchSize(batchSize).SetIsContinueWhenError(isContinueWhenError), ctx, func(t *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { var skuPriceInfoList []*jdapi.SkuPriceInfo var skuVendibilityList []*jdapi.StockVendibility