diff --git a/business/partner/purchase/jd/store_sku2.go b/business/partner/purchase/jd/store_sku2.go index af5a8acd3..5fda21747 100644 --- a/business/partner/purchase/jd/store_sku2.go +++ b/business/partner/purchase/jd/store_sku2.go @@ -92,29 +92,41 @@ func (p *PurchaseHandler) UpdateStoreSkusStatus(ctx *jxcontext.Context, storeID } func (p *PurchaseHandler) UpdateStoreSkusPrice(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) { - var skuPriceInfoList []*jdapi.SkuPriceInfo - for _, v := range storeSkuList { - skuPriceInfoList = append(skuPriceInfoList, &jdapi.SkuPriceInfo{ - OutSkuId: utils.Int2Str(v.SkuID), - Price: int(v.Price), - }) - } - if globals.EnableJdStoreWrite { - _, err = api.JdAPI.UpdateVendorStationPrice("", vendorStoreID, skuPriceInfoList) + if len(storeSkuList) == 1 { + if globals.EnableJdStoreWrite { + _, err = api.JdAPI.UpdateStationPrice(utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), vendorStoreID, int(storeSkuList[0].Price)) + } + } else { + var skuPriceInfoList []*jdapi.SkuPriceInfo + for _, v := range storeSkuList { + skuPriceInfoList = append(skuPriceInfoList, &jdapi.SkuPriceInfo{ + OutSkuId: utils.Int2Str(v.SkuID), + Price: int(v.Price), + }) + } + if globals.EnableJdStoreWrite { + _, err = api.JdAPI.UpdateVendorStationPrice("", vendorStoreID, skuPriceInfoList) + } } return err } func (p *PurchaseHandler) UpdateStoreSkusStock(ctx *jxcontext.Context, storeID int, vendorStoreID string, storeSkuList []*partner.StoreSkuInfo) (err error) { - var skuStockList []*jdapi.SkuStock - for _, v := range storeSkuList { - skuStockList = append(skuStockList, &jdapi.SkuStock{ - OutSkuId: utils.Int2Str(v.SkuID), - StockQty: v.Stock, - }) - } - if globals.EnableJdStoreWrite { - _, err = api.JdAPI.BatchUpdateCurrentQtys("", vendorStoreID, skuStockList, ctx.GetUserName()) + if len(storeSkuList) == 1 { + if globals.EnableJdStoreWrite { + err = api.JdAPI.UpdateCurrentQty(vendorStoreID, utils.Str2Int64WithDefault(storeSkuList[0].VendorSkuID, 0), storeSkuList[0].Stock) + } + } else { + var skuStockList []*jdapi.SkuStock + for _, v := range storeSkuList { + skuStockList = append(skuStockList, &jdapi.SkuStock{ + OutSkuId: utils.Int2Str(v.SkuID), + StockQty: v.Stock, + }) + } + if globals.EnableJdStoreWrite { + _, err = api.JdAPI.BatchUpdateCurrentQtys("", vendorStoreID, skuStockList, ctx.GetUserName()) + } } return err }