Browse Source

Check whether the inventory has been deducted when creating a payment or completing the order.

pull/103/head
gdlcf88 6 years ago
parent
commit
3b991458df
  1. 2
      modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderManager.cs
  2. 5
      modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Payments/BasicPaymentCreationAuthorizationHandler.cs

2
modules/EasyAbp.EShop.Orders/src/EasyAbp.EShop.Orders.Domain/EasyAbp/EShop/Orders/Orders/OrderManager.cs

@ -43,7 +43,7 @@ namespace EasyAbp.EShop.Orders.Orders
public virtual async Task<Order> CompleteAsync(Order order)
{
if (order.CompletionTime.HasValue)
if (order.CompletionTime.HasValue || !order.ReducedInventoryAfterPaymentTime.HasValue)
{
throw new OrderIsInWrongStageException(order.Id);
}

5
modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Payments/BasicPaymentCreationAuthorizationHandler.cs

@ -14,7 +14,10 @@ namespace EasyAbp.EShop.Payments.Payments
protected override Task HandlePaymentCreationAsync(AuthorizationHandlerContext context,
PaymentOperationAuthorizationRequirement requirement, PaymentCreationResource resource)
{
if (resource.Orders.Any(order => order.PaymentId.HasValue || order.PaidTime.HasValue))
if (resource.Orders.Any(order =>
!order.ReducedInventoryAfterPlacingTime.HasValue ||
order.PaymentId.HasValue ||
order.PaidTime.HasValue))
{
context.Fail();
return Task.CompletedTask;

Loading…
Cancel
Save