diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductSkuDto.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductSkuDto.cs index 4ff46b3d..ad0728ac 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductSkuDto.cs +++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application.Contracts/EasyAbp/EShop/Products/Products/Dtos/ProductSkuDto.cs @@ -19,9 +19,6 @@ namespace EasyAbp.EShop.Products.Products.Dtos /// public decimal Price { get; set; } - /// - /// Price from IProductDiscountManager - /// public decimal DiscountedPrice { get; set; } public int Inventory { get; set; } diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs index b2f8395c..3ab012bd 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs +++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Application/EasyAbp/EShop/Products/Products/ProductAppService.cs @@ -23,7 +23,6 @@ namespace EasyAbp.EShop.Products.Products protected override string GetListPolicyName { get; set; } = null; private readonly IProductManager _productManager; - private readonly IProductDiscountManager _productDiscountManager; private readonly IProductInventoryProvider _productInventoryProvider; private readonly IAttributeOptionIdsSerializer _attributeOptionIdsSerializer; private readonly IProductStoreRepository _productStoreRepository; @@ -31,14 +30,12 @@ namespace EasyAbp.EShop.Products.Products public ProductAppService( IProductManager productManager, - IProductDiscountManager productDiscountManager, IProductInventoryProvider productInventoryProvider, IAttributeOptionIdsSerializer attributeOptionIdsSerializer, IProductStoreRepository productStoreRepository, IProductRepository repository) : base(repository) { _productManager = productManager; - _productDiscountManager = productDiscountManager; _productInventoryProvider = productInventoryProvider; _attributeOptionIdsSerializer = attributeOptionIdsSerializer; _productStoreRepository = productStoreRepository; @@ -284,7 +281,7 @@ namespace EasyAbp.EShop.Products.Products { foreach (var productSkuDto in productDto.ProductSkus) { - productSkuDto.DiscountedPrice = await _productDiscountManager.GetDiscountedPriceAsync(product, + productSkuDto.DiscountedPrice = await _productManager.GetDiscountedPriceAsync(product, product.ProductSkus.Single(sku => sku.Id == productSkuDto.Id), storeId); } diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IProductDiscountManager.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IProductDiscountManager.cs deleted file mode 100644 index 89d1eb7c..00000000 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IProductDiscountManager.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace EasyAbp.EShop.Products.Products -{ - public interface IProductDiscountManager : IDomainService - { - Task GetDiscountedPriceAsync(Product product, ProductSku productSku, Guid storeId); - } -} \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IProductManager.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IProductManager.cs index 0171a064..c0f1e31c 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IProductManager.cs +++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/IProductManager.cs @@ -28,5 +28,7 @@ namespace EasyAbp.EShop.Products.Products Task TryIncreaseInventoryAsync(Product product, ProductSku productSku, Guid storeId, int quantity); Task TryReduceInventoryAsync(Product product, ProductSku productSku, Guid storeId, int quantity); + + Task GetDiscountedPriceAsync(Product product, ProductSku productSku, Guid storeId); } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductDiscountManager.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductDiscountManager.cs deleted file mode 100644 index dc55954a..00000000 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductDiscountManager.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Domain.Services; - -namespace EasyAbp.EShop.Products.Products -{ - public class ProductDiscountManager : DomainService, IProductDiscountManager - { - public async Task GetDiscountedPriceAsync(Product product, ProductSku productSku, Guid storeId) - { - var currentPrice = productSku.Price; - - foreach (var provider in ServiceProvider.GetServices()) - { - currentPrice = await provider.GetDiscountedPriceAsync(product, productSku, storeId, currentPrice); - } - - return currentPrice; - } - } -} \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductManager.cs b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductManager.cs index 1b604186..e2b9f65b 100644 --- a/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductManager.cs +++ b/modules/EasyAbp.EShop.Products/src/EasyAbp.EShop.Products.Domain/EasyAbp/EShop/Products/Products/ProductManager.cs @@ -3,9 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using EasyAbp.EShop.Products.ProductCategories; -using EasyAbp.EShop.Products.ProductDetails; using EasyAbp.EShop.Products.ProductStores; -using Volo.Abp.Domain.Entities; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Domain.Services; namespace EasyAbp.EShop.Products.Products @@ -205,5 +204,17 @@ namespace EasyAbp.EShop.Products.Products { return await _productInventoryProvider.TryReduceInventoryAsync(product, productSku, storeId, quantity); } + + public virtual async Task GetDiscountedPriceAsync(Product product, ProductSku productSku, Guid storeId) + { + var currentPrice = productSku.Price; + + foreach (var provider in ServiceProvider.GetServices()) + { + currentPrice = await provider.GetDiscountedPriceAsync(product, productSku, storeId, currentPrice); + } + + return currentPrice; + } } } \ No newline at end of file