diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalePlanAppService.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalePlanAppService.cs index 63bb7c10..18b9a9fd 100644 --- a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalePlanAppService.cs +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalePlanAppService.cs @@ -10,6 +10,7 @@ using EasyAbp.EShop.Products.Products.Dtos; using EasyAbp.EShop.Stores.Stores; using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Options; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Caching; @@ -54,6 +55,8 @@ public class FlashSalePlanAppService : protected IDistributedCache DistributedCache { get; } + protected FlashSalesOptions Options { get; } + public FlashSalePlanAppService( IFlashSalePlanRepository flashSalePlanRepository, IProductAppService productAppService, @@ -64,7 +67,8 @@ public class FlashSalePlanAppService : IAbpDistributedLock distributedLock, IFlashSalePlanHasher flashSalePlanHasher, IFlashSaleInventoryManager flashSaleInventoryManager, - IDistributedCache distributedCache) + IDistributedCache distributedCache, + IOptionsMonitor optionsMonitor) : base(flashSalePlanRepository) { FlashSalePlanRepository = flashSalePlanRepository; @@ -77,6 +81,7 @@ public class FlashSalePlanAppService : FlashSalePlanHasher = flashSalePlanHasher; FlashSaleInventoryManager = flashSaleInventoryManager; DistributedCache = distributedCache; + Options = optionsMonitor.CurrentValue; } public override async Task GetAsync(Guid id) @@ -359,7 +364,7 @@ public class FlashSalePlanAppService : InventoryProviderName = product.InventoryProviderName, }, new DistributedCacheEntryOptions() { - AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(3) + AbsoluteExpirationRelativeToNow = Options.PreOrderExpirationTime }); } diff --git a/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalesOptions.cs b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalesOptions.cs new file mode 100644 index 00000000..a09478dd --- /dev/null +++ b/plugins/FlashSales/src/EasyAbp.EShop.Plugins.FlashSales.Application/EasyAbp/EShop/Plugins/FlashSales/FlashSalePlans/FlashSalesOptions.cs @@ -0,0 +1,11 @@ +using System; + +namespace EasyAbp.EShop.Plugins.FlashSales.FlashSalePlans; + +public class FlashSalesOptions +{ + /// + /// Default: 3 minutes + /// + public TimeSpan PreOrderExpirationTime { get; set; } = TimeSpan.FromMinutes(3); +}