Browse Source

Check quantity in `BasicBasketItemProductInfoUpdater`

pull/190/head
gdlcf88 4 years ago
parent
commit
63eda717d2
  1. 10
      plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketItems/BasicBasketItemProductInfoUpdater.cs

10
plugins/Baskets/src/EasyAbp.EShop.Plugins.Baskets.Application/EasyAbp/EShop/Plugins/Baskets/BasketItems/BasicBasketItemProductInfoUpdater.cs

@ -1,3 +1,4 @@
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using EasyAbp.EShop.Products.Products; using EasyAbp.EShop.Products.Products;
using EasyAbp.EShop.Products.Products.Dtos; using EasyAbp.EShop.Products.Products.Dtos;
@ -31,7 +32,6 @@ public class BasicBasketItemProductInfoUpdater : IBasketItemProductInfoUpdater,
if (productSkuDto == null) if (productSkuDto == null)
{ {
item.SetIsInvalid(true); item.SetIsInvalid(true);
return; return;
} }
@ -52,11 +52,19 @@ public class BasicBasketItemProductInfoUpdater : IBasketItemProductInfoUpdater,
if (productDto.InventoryStrategy != InventoryStrategy.NoNeed && targetQuantity > productSkuDto.Inventory) if (productDto.InventoryStrategy != InventoryStrategy.NoNeed && targetQuantity > productSkuDto.Inventory)
{ {
item.SetIsInvalid(true); item.SetIsInvalid(true);
return;
} }
if (!productDto.IsPublished) if (!productDto.IsPublished)
{ {
item.SetIsInvalid(true); item.SetIsInvalid(true);
return;
}
if (!targetQuantity.IsBetween(productSkuDto.OrderMinQuantity, productSkuDto.OrderMaxQuantity))
{
item.SetIsInvalid(true);
return;
} }
} }
} }
Loading…
Cancel
Save