Browse Source

Close #73: Check inventory when creating an order

pull/87/head v0.4.0
gdlcf88 6 years ago
parent
commit
455f203dc8
  1. 2
      common.props
  2. 7
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs

2
common.props

@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>0.3.8</Version>
<Version>0.4.0</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>EasyAbp Team</Authors>

7
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Application/EasyAbp/EShop/Orders/Orders/NewOrderGenerator.cs

@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using EasyAbp.EShop.Orders.Orders.Dtos;
using EasyAbp.EShop.Products.ProductInventories;
using EasyAbp.EShop.Products.Products;
using EasyAbp.EShop.Products.Products.Dtos;
using Volo.Abp.DependencyInjection;
@ -75,6 +76,12 @@ namespace EasyAbp.EShop.Orders.Orders
{
throw new OrderLineInvalidQuantityException(product.Id, productSku.Id, input.Quantity);
}
if (productSku.Inventory < input.Quantity)
{
throw new InventoryInsufficientException(input.ProductId, input.ProductSkuId, input.Quantity,
productSku.Inventory);
}
return new OrderLine(
id: _guidGenerator.Create(),

Loading…
Cancel
Save