- 优化京东门店商品信息同步逻辑,少量数据同步时,拆开,以避免由于单个SKU全体失败的情况

This commit is contained in:
gazebo
2019-06-13 11:02:04 +08:00
parent 694ea08540
commit f9373f3bda

View File

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