|
|
@ -3,7 +3,6 @@ using EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans; |
|
|
using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults.Dtos; |
|
|
using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults.Dtos; |
|
|
using EasyAbp.Eshop.Products.Products; |
|
|
using EasyAbp.Eshop.Products.Products; |
|
|
using EasyAbp.EShop.Products.Products; |
|
|
using EasyAbp.EShop.Products.Products; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
|
|
using Microsoft.Extensions.Logging; |
|
|
using Microsoft.Extensions.Logging; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp.DependencyInjection; |
|
|
using Volo.Abp.DependencyInjection; |
|
|
@ -23,7 +22,6 @@ public class CreateFlashSaleResultEventHandler : IDistributedEventHandler<Create |
|
|
protected IObjectMapper ObjectMapper { get; } |
|
|
protected IObjectMapper ObjectMapper { get; } |
|
|
protected ICurrentTenant CurrentTenant { get; } |
|
|
protected ICurrentTenant CurrentTenant { get; } |
|
|
protected IUnitOfWorkManager UnitOfWorkManager { get; } |
|
|
protected IUnitOfWorkManager UnitOfWorkManager { get; } |
|
|
protected IServiceScopeFactory ServiceScopeFactory { get; } |
|
|
|
|
|
protected ILogger<CreateFlashSaleResultEventHandler> Logger { get; } |
|
|
protected ILogger<CreateFlashSaleResultEventHandler> Logger { get; } |
|
|
protected IAbpDistributedLock AbpDistributedLock { get; } |
|
|
protected IAbpDistributedLock AbpDistributedLock { get; } |
|
|
protected IDistributedEventBus DistributedEventBus { get; } |
|
|
protected IDistributedEventBus DistributedEventBus { get; } |
|
|
@ -35,7 +33,6 @@ public class CreateFlashSaleResultEventHandler : IDistributedEventHandler<Create |
|
|
IObjectMapper objectMapper, |
|
|
IObjectMapper objectMapper, |
|
|
ICurrentTenant currentTenant, |
|
|
ICurrentTenant currentTenant, |
|
|
IUnitOfWorkManager unitOfWorkManager, |
|
|
IUnitOfWorkManager unitOfWorkManager, |
|
|
IServiceScopeFactory serviceScopeFactory, |
|
|
|
|
|
ILogger<CreateFlashSaleResultEventHandler> logger, |
|
|
ILogger<CreateFlashSaleResultEventHandler> logger, |
|
|
IAbpDistributedLock abpDistributedLock, |
|
|
IAbpDistributedLock abpDistributedLock, |
|
|
IDistributedEventBus distributedEventBus, |
|
|
IDistributedEventBus distributedEventBus, |
|
|
@ -46,7 +43,6 @@ public class CreateFlashSaleResultEventHandler : IDistributedEventHandler<Create |
|
|
ObjectMapper = objectMapper; |
|
|
ObjectMapper = objectMapper; |
|
|
CurrentTenant = currentTenant; |
|
|
CurrentTenant = currentTenant; |
|
|
UnitOfWorkManager = unitOfWorkManager; |
|
|
UnitOfWorkManager = unitOfWorkManager; |
|
|
ServiceScopeFactory = serviceScopeFactory; |
|
|
|
|
|
Logger = logger; |
|
|
Logger = logger; |
|
|
AbpDistributedLock = abpDistributedLock; |
|
|
AbpDistributedLock = abpDistributedLock; |
|
|
DistributedEventBus = distributedEventBus; |
|
|
DistributedEventBus = distributedEventBus; |
|
|
@ -84,11 +80,7 @@ public class CreateFlashSaleResultEventHandler : IDistributedEventHandler<Create |
|
|
// try to roll back the inventory.
|
|
|
// try to roll back the inventory.
|
|
|
UnitOfWorkManager.Current.OnCompleted(async () => |
|
|
UnitOfWorkManager.Current.OnCompleted(async () => |
|
|
{ |
|
|
{ |
|
|
using var scope = ServiceScopeFactory.CreateScope(); |
|
|
if (!await FlashSaleInventoryManager.TryRollBackInventoryAsync(eventData.TenantId, |
|
|
|
|
|
|
|
|
var flashSaleInventoryManager = scope.ServiceProvider.GetRequiredService<IFlashSaleInventoryManager>(); |
|
|
|
|
|
|
|
|
|
|
|
if (!await flashSaleInventoryManager.TryRollBackInventoryAsync(eventData.TenantId, |
|
|
|
|
|
eventData.ProductInventoryProviderName, eventData.Plan.StoreId, |
|
|
eventData.ProductInventoryProviderName, eventData.Plan.StoreId, |
|
|
eventData.Plan.ProductId, eventData.Plan.ProductSkuId)) |
|
|
eventData.Plan.ProductId, eventData.Plan.ProductSkuId)) |
|
|
{ |
|
|
{ |
|
|
|