- 同步京东到家门店商品信息时,单商品用相应的特殊接口,减轻访问频的情况
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user