mirror of https://github.com/EasyAbp/EShop.git
10 changed files with 331 additions and 20 deletions
@ -0,0 +1,35 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using EasyAbp.EShop.Products.Products; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Domain.Entities.Events.Distributed; |
||||
|
using Volo.Abp.EventBus.Distributed; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Orders.Orders |
||||
|
{ |
||||
|
public class OrderCreatedEventHandler : IDistributedEventHandler<EntityCreatedEto<OrderEto>>, ITransientDependency |
||||
|
{ |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
private readonly IDistributedEventBus _distributedEventBus; |
||||
|
|
||||
|
public OrderCreatedEventHandler( |
||||
|
ICurrentTenant currentTenant, |
||||
|
IDistributedEventBus distributedEventBus) |
||||
|
{ |
||||
|
_currentTenant = currentTenant; |
||||
|
_distributedEventBus = distributedEventBus; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task HandleEventAsync(EntityCreatedEto<OrderEto> eventData) |
||||
|
{ |
||||
|
using var changeTenant = _currentTenant.Change(eventData.Entity.TenantId); |
||||
|
|
||||
|
await _distributedEventBus.PublishAsync(new ProductInventoryReductionAfterOrderPlacedResultEto |
||||
|
{ |
||||
|
TenantId = eventData.Entity.TenantId, |
||||
|
OrderId = eventData.Entity.Id, |
||||
|
IsSuccess = true |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using EasyAbp.PaymentService.Payments; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.EventBus.Distributed; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Payments.Payments |
||||
|
{ |
||||
|
public class TestCreatePaymentEventHandler : IDistributedEventHandler<CreatePaymentEto>, ISingletonDependency |
||||
|
{ |
||||
|
public bool IsEventPublished { get; protected set; } |
||||
|
|
||||
|
public Task HandleEventAsync(CreatePaymentEto eventData) |
||||
|
{ |
||||
|
IsEventPublished = true; |
||||
|
|
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using EasyAbp.PaymentService.Payments; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.EventBus.Distributed; |
||||
|
|
||||
|
namespace EasyAbp.EShop.Payments.Payments |
||||
|
{ |
||||
|
public class TestRefundPaymentEventHandler : IDistributedEventHandler<RefundPaymentEto>, ISingletonDependency |
||||
|
{ |
||||
|
public bool IsEventPublished { get; protected set; } |
||||
|
|
||||
|
public Task HandleEventAsync(RefundPaymentEto eventData) |
||||
|
{ |
||||
|
IsEventPublished = true; |
||||
|
|
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue