From 95a94301ea6513f11fe39f4435e891c00937d199 Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 15 Jul 2019 12:35:08 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=90=8C=E6=AD=A5=E4=BA=AC=E4=B8=9C?= =?UTF-8?q?=E5=88=B0=E5=AE=B6=E9=97=A8=E5=BA=97=E5=95=86=E5=93=81=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=97=B6=EF=BC=8C=E5=8D=95=E5=95=86=E5=93=81=E7=94=A8?= =?UTF-8?q?=E7=9B=B8=E5=BA=94=E7=9A=84=E7=89=B9=E6=AE=8A=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=87=8F=E8=BD=BB=E8=AE=BF=E9=97=AE=E9=A2=91=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 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 {