diff --git a/business/partner/purchase/jd/store_sku.go b/business/partner/purchase/jd/store_sku.go index 541dc6a95..f59822c0d 100644 --- a/business/partner/purchase/jd/store_sku.go +++ b/business/partner/purchase/jd/store_sku.go @@ -45,6 +45,8 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks var skuPriceInfoList []*jdapi.SkuPriceInfo var skuVendibilityList []*jdapi.StockVendibility var skuStockList []*jdapi.SkuStock + vendorSkuID4Price := "" + vendorSkuID4Qty := "" stationNo := storeDetail.VendorStoreID var batchBindIDs []int for _, v := range batchItemList { @@ -65,10 +67,12 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks alreadyAddStock = true } if stock.StockQty != 0 || !storeskulock.IsJdStoreSkuLocked(stationNo, storeSku.JdID) { + vendorSkuID4Qty = storeSku.VendorSkuID skuStockList = append(skuStockList, stock) } } if storeSku.StoreSkuSyncStatus&(model.SyncFlagPriceMask|model.SyncFlagNewMask) != 0 { + vendorSkuID4Price = storeSku.VendorSkuID skuPriceInfoList = append(skuPriceInfoList, &jdapi.SkuPriceInfo{ OutSkuId: utils.Int2Str(storeSku.SkuID), Price: constrainPrice(jxutils.CaculateSkuVendorPrice(int(storeSku.Price), int(storeDetail.PricePercentage), storeSku.CatPricePercentage)), @@ -110,7 +114,12 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks } } if (err == nil || isContinueWhenError) && len(skuStockList) > 0 { - if _, err = api.JdAPI.BatchUpdateCurrentQtys("", stationNo, skuStockList, ctx.GetUserName()); err == nil { + if len(skuStockList) == 1 { + err = api.JdAPI.UpdateCurrentQty(stationNo, utils.Str2Int64WithDefault(vendorSkuID4Qty, 0), skuStockList[0].StockQty) + } else { + _, err = api.JdAPI.BatchUpdateCurrentQtys("", stationNo, skuStockList, ctx.GetUserName()) + } + if err == nil { syncMask |= model.SyncFlagNewMask | model.SyncFlagDeletedMask } else { if !isPartialFailed { @@ -120,7 +129,12 @@ func (p *PurchaseHandler) syncStoreSkus(ctx *jxcontext.Context, parentTask tasks } } if (err == nil || isContinueWhenError) && len(skuPriceInfoList) > 0 { - if _, err = api.JdAPI.UpdateVendorStationPrice("", stationNo, skuPriceInfoList); err == nil { + if len(skuPriceInfoList) == 1 { + _, err = api.JdAPI.UpdateStationPrice(utils.Str2Int64WithDefault(vendorSkuID4Price, 0), stationNo, skuPriceInfoList[0].Price) + } else { + _, err = api.JdAPI.UpdateVendorStationPrice("", stationNo, skuPriceInfoList) + } + if err == nil { syncMask |= model.SyncFlagPriceMask } else { if !isPartialFailed {