|
|
|
@ -2,7 +2,9 @@ |
|
|
|
using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults; |
|
|
|
using EasyAbp.EShop.Plugins.FlashSales.FlashSaleResults.Dtos; |
|
|
|
using EasyAbp.Eshop.Products.Products; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
using Volo.Abp.EventBus.Distributed; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
@ -17,6 +19,7 @@ public class FlashSaleOrderCreationResultEventHandler : IDistributedEventHandler |
|
|
|
protected IFlashSaleInventoryManager FlashSaleInventoryManager { get; } |
|
|
|
protected IUnitOfWorkManager UnitOfWorkManager { get; } |
|
|
|
protected IObjectMapper ObjectMapper { get; } |
|
|
|
protected IAbpApplication AbpApplication { get; } |
|
|
|
protected IFlashSaleCurrentResultCache FlashSaleCurrentResultCache { get; } |
|
|
|
protected IFlashSaleResultRepository FlashSaleResultRepository { get; } |
|
|
|
|
|
|
|
@ -25,6 +28,7 @@ public class FlashSaleOrderCreationResultEventHandler : IDistributedEventHandler |
|
|
|
IFlashSaleInventoryManager flashSaleInventoryManager, |
|
|
|
IUnitOfWorkManager unitOfWorkManager, |
|
|
|
IObjectMapper objectMapper, |
|
|
|
IAbpApplication abpApplication, |
|
|
|
IFlashSaleCurrentResultCache flashSaleCurrentResultCache, |
|
|
|
IFlashSaleResultRepository flashSaleResultRepository) |
|
|
|
{ |
|
|
|
@ -32,6 +36,7 @@ public class FlashSaleOrderCreationResultEventHandler : IDistributedEventHandler |
|
|
|
FlashSaleInventoryManager = flashSaleInventoryManager; |
|
|
|
UnitOfWorkManager = unitOfWorkManager; |
|
|
|
ObjectMapper = objectMapper; |
|
|
|
AbpApplication = abpApplication; |
|
|
|
FlashSaleCurrentResultCache = flashSaleCurrentResultCache; |
|
|
|
FlashSaleResultRepository = flashSaleResultRepository; |
|
|
|
} |
|
|
|
@ -86,11 +91,16 @@ public class FlashSaleOrderCreationResultEventHandler : IDistributedEventHandler |
|
|
|
|
|
|
|
protected virtual async Task ResetFlashSaleCurrentResultCacheAsync(FlashSaleResult flashSaleResult) |
|
|
|
{ |
|
|
|
await FlashSaleCurrentResultCache.SetAsync(flashSaleResult.PlanId, flashSaleResult.UserId, |
|
|
|
using var scope = AbpApplication.ServiceProvider.CreateScope(); |
|
|
|
|
|
|
|
var objectMapper = scope.ServiceProvider.GetRequiredService<IObjectMapper>(); |
|
|
|
var flashSaleCurrentResultCache = scope.ServiceProvider.GetRequiredService<IFlashSaleCurrentResultCache>(); |
|
|
|
|
|
|
|
await flashSaleCurrentResultCache.SetAsync(flashSaleResult.PlanId, flashSaleResult.UserId, |
|
|
|
new FlashSaleCurrentResultCacheItem |
|
|
|
{ |
|
|
|
TenantId = flashSaleResult.TenantId, |
|
|
|
ResultDto = ObjectMapper.Map<FlashSaleResult, FlashSaleResultDto>(flashSaleResult) |
|
|
|
ResultDto = objectMapper.Map<FlashSaleResult, FlashSaleResultDto>(flashSaleResult) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |