Commit 01d73b8a authored by gdlcf88's avatar gdlcf88

Added TenantId to Etos

parent c6a81c9a
......@@ -8,6 +8,8 @@ namespace EasyAbp.EShop.Orders.Orders
{
public Guid Id { get; set; }
public Guid? TenantId { get; set; }
public Guid StoreId { get; set; }
public Guid CustomerUserId { get; set; }
......
using System.Threading.Tasks;
using EasyAbp.EShop.Products.Products;
using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Timing;
using Volo.Abp.Uow;
......@@ -9,18 +10,23 @@ namespace EasyAbp.EShop.Orders.Orders
public class OrderProductInventoryReductionEventHandler : IOrderProductInventoryReductionEventHandler, ITransientDependency
{
private readonly IClock _clock;
private readonly ICurrentTenant _currentTenant;
private readonly IOrderRepository _orderRepository;
public OrderProductInventoryReductionEventHandler(
IClock clock,
ICurrentTenant currentTenant,
IOrderRepository orderRepository)
{
_clock = clock;
_currentTenant = currentTenant;
_orderRepository = orderRepository;
}
[UnitOfWork(true)]
public virtual async Task HandleEventAsync(ProductInventoryReductionAfterOrderPlacedResultEto eventData)
{
using (_currentTenant.Change(eventData.TenantId))
{
var order = await _orderRepository.GetAsync(eventData.OrderId);
......@@ -40,4 +46,5 @@ namespace EasyAbp.EShop.Orders.Orders
await _orderRepository.UpdateAsync(order, true);
}
}
}
}
\ No newline at end of file
......@@ -5,6 +5,8 @@ namespace EasyAbp.EShop.Products.Products
[Serializable]
public class ProductInventoryReductionAfterOrderPlacedResultEto
{
public Guid? TenantId { get; set; }
public Guid OrderId { get; set; }
public bool IsSuccess { get; set; }
......
......@@ -4,23 +4,27 @@ using EasyAbp.EShop.Orders.Orders;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow;
namespace EasyAbp.EShop.Products.Products
{
public class OrderCreatedEventHandler : IOrderCreatedEventHandler, ITransientDependency
{
private readonly ICurrentTenant _currentTenant;
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IDistributedEventBus _distributedEventBus;
private readonly IProductRepository _productRepository;
private readonly IProductManager _productManager;
public OrderCreatedEventHandler(
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IDistributedEventBus distributedEventBus,
IProductRepository productRepository,
IProductManager productManager)
{
_currentTenant = currentTenant;
_unitOfWorkManager = unitOfWorkManager;
_distributedEventBus = distributedEventBus;
_productRepository = productRepository;
......@@ -28,6 +32,8 @@ namespace EasyAbp.EShop.Products.Products
}
public virtual async Task HandleEventAsync(EntityCreatedEto<OrderEto> eventData)
{
using (_currentTenant.Change(eventData.Entity.TenantId))
{
using var uow = _unitOfWorkManager.Begin(true, true);
......@@ -68,4 +74,5 @@ namespace EasyAbp.EShop.Products.Products
{OrderId = eventData.Entity.Id, IsSuccess = true});
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment