Commit 01d73b8a authored by gdlcf88's avatar gdlcf88

Added TenantId to Etos

parent c6a81c9a
...@@ -8,6 +8,8 @@ namespace EasyAbp.EShop.Orders.Orders ...@@ -8,6 +8,8 @@ namespace EasyAbp.EShop.Orders.Orders
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public Guid? TenantId { get; set; }
public Guid StoreId { get; set; } public Guid StoreId { get; set; }
public Guid CustomerUserId { get; set; } public Guid CustomerUserId { get; set; }
......
using System.Threading.Tasks; using System.Threading.Tasks;
using EasyAbp.EShop.Products.Products; using EasyAbp.EShop.Products.Products;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Timing; using Volo.Abp.Timing;
using Volo.Abp.Uow; using Volo.Abp.Uow;
...@@ -9,18 +10,23 @@ namespace EasyAbp.EShop.Orders.Orders ...@@ -9,18 +10,23 @@ namespace EasyAbp.EShop.Orders.Orders
public class OrderProductInventoryReductionEventHandler : IOrderProductInventoryReductionEventHandler, ITransientDependency public class OrderProductInventoryReductionEventHandler : IOrderProductInventoryReductionEventHandler, ITransientDependency
{ {
private readonly IClock _clock; private readonly IClock _clock;
private readonly ICurrentTenant _currentTenant;
private readonly IOrderRepository _orderRepository; private readonly IOrderRepository _orderRepository;
public OrderProductInventoryReductionEventHandler( public OrderProductInventoryReductionEventHandler(
IClock clock, IClock clock,
ICurrentTenant currentTenant,
IOrderRepository orderRepository) IOrderRepository orderRepository)
{ {
_clock = clock; _clock = clock;
_currentTenant = currentTenant;
_orderRepository = orderRepository; _orderRepository = orderRepository;
} }
[UnitOfWork(true)] [UnitOfWork(true)]
public virtual async Task HandleEventAsync(ProductInventoryReductionAfterOrderPlacedResultEto eventData) public virtual async Task HandleEventAsync(ProductInventoryReductionAfterOrderPlacedResultEto eventData)
{
using (_currentTenant.Change(eventData.TenantId))
{ {
var order = await _orderRepository.GetAsync(eventData.OrderId); var order = await _orderRepository.GetAsync(eventData.OrderId);
...@@ -40,4 +46,5 @@ namespace EasyAbp.EShop.Orders.Orders ...@@ -40,4 +46,5 @@ namespace EasyAbp.EShop.Orders.Orders
await _orderRepository.UpdateAsync(order, true); await _orderRepository.UpdateAsync(order, true);
} }
} }
}
} }
\ No newline at end of file
...@@ -5,6 +5,8 @@ namespace EasyAbp.EShop.Products.Products ...@@ -5,6 +5,8 @@ namespace EasyAbp.EShop.Products.Products
[Serializable] [Serializable]
public class ProductInventoryReductionAfterOrderPlacedResultEto public class ProductInventoryReductionAfterOrderPlacedResultEto
{ {
public Guid? TenantId { get; set; }
public Guid OrderId { get; set; } public Guid OrderId { get; set; }
public bool IsSuccess { get; set; } public bool IsSuccess { get; set; }
......
...@@ -4,23 +4,27 @@ using EasyAbp.EShop.Orders.Orders; ...@@ -4,23 +4,27 @@ using EasyAbp.EShop.Orders.Orders;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed; using Volo.Abp.EventBus.Distributed;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Uow; using Volo.Abp.Uow;
namespace EasyAbp.EShop.Products.Products namespace EasyAbp.EShop.Products.Products
{ {
public class OrderCreatedEventHandler : IOrderCreatedEventHandler, ITransientDependency public class OrderCreatedEventHandler : IOrderCreatedEventHandler, ITransientDependency
{ {
private readonly ICurrentTenant _currentTenant;
private readonly IUnitOfWorkManager _unitOfWorkManager; private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IDistributedEventBus _distributedEventBus; private readonly IDistributedEventBus _distributedEventBus;
private readonly IProductRepository _productRepository; private readonly IProductRepository _productRepository;
private readonly IProductManager _productManager; private readonly IProductManager _productManager;
public OrderCreatedEventHandler( public OrderCreatedEventHandler(
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager, IUnitOfWorkManager unitOfWorkManager,
IDistributedEventBus distributedEventBus, IDistributedEventBus distributedEventBus,
IProductRepository productRepository, IProductRepository productRepository,
IProductManager productManager) IProductManager productManager)
{ {
_currentTenant = currentTenant;
_unitOfWorkManager = unitOfWorkManager; _unitOfWorkManager = unitOfWorkManager;
_distributedEventBus = distributedEventBus; _distributedEventBus = distributedEventBus;
_productRepository = productRepository; _productRepository = productRepository;
...@@ -28,6 +32,8 @@ namespace EasyAbp.EShop.Products.Products ...@@ -28,6 +32,8 @@ namespace EasyAbp.EShop.Products.Products
} }
public virtual async Task HandleEventAsync(EntityCreatedEto<OrderEto> eventData) public virtual async Task HandleEventAsync(EntityCreatedEto<OrderEto> eventData)
{
using (_currentTenant.Change(eventData.Entity.TenantId))
{ {
using var uow = _unitOfWorkManager.Begin(true, true); using var uow = _unitOfWorkManager.Begin(true, true);
...@@ -68,4 +74,5 @@ namespace EasyAbp.EShop.Products.Products ...@@ -68,4 +74,5 @@ namespace EasyAbp.EShop.Products.Products
{OrderId = eventData.Entity.Id, IsSuccess = true}); {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