mirror of https://github.com/EasyAbp/EShop.git
8 changed files with 107 additions and 22 deletions
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Services; |
|||
|
|||
namespace EasyAbp.EShop.Products.Products |
|||
{ |
|||
public interface IProductDiscountManager : IDomainService |
|||
{ |
|||
Task<decimal> GetDiscountedPriceAsync(Product product, ProductSku productSku, Guid storeId); |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace EasyAbp.EShop.Products.Products |
|||
{ |
|||
public interface IProductDiscountProvider |
|||
{ |
|||
Task<decimal> GetDiscountedPriceAsync(Product product, ProductSku productSku, Guid storeId, decimal currentPrice); |
|||
} |
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
namespace EasyAbp.EShop.Products.Products |
|||
{ |
|||
public interface IProductPriceProvider |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
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<decimal> GetDiscountedPriceAsync(Product product, ProductSku productSku, Guid storeId) |
|||
{ |
|||
var currentPrice = productSku.Price; |
|||
|
|||
foreach (var provider in ServiceProvider.GetServices<IProductDiscountProvider>()) |
|||
{ |
|||
currentPrice = await provider.GetDiscountedPriceAsync(product, productSku, storeId, currentPrice); |
|||
} |
|||
|
|||
return currentPrice; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue