增加项目,分层

This commit is contained in:
chfei committed 2026-09-11 19:11:12 +08:00
1 parent 6e995a5bdb
commit 0a3e5af6a9
234 files changed
+26994 -1

No files matched your search

@@ -0,0 +1,72 @@
using Store.Product.Models.Product.Sku;
using System.Collections.Generic;
using System.Linq;
namespace Store.Product.Models.PublishParameters.Price
{
/// <summary>
/// 区间价格配置
/// </summary>
public class SectionPrice : PriceConfigBase
{
public override PriceStrategyType PriceType => PriceStrategyType.分段价格;
/// <summary>
/// 区间列表
/// </summary>
public List<SectionItemPrice> SectionList { get; set; } = new List<SectionItemPrice>();
/// <summary>
/// 计算价格
/// </summary>
/// <param name="oldPrice"></param>
/// <returns></returns>
public override decimal ComputedPrice(decimal oldPrice)
{
var newPrice = oldPrice;
if (SectionList != null && SectionList.Count > 0)
{
foreach (var item in SectionList)
{
if (item.BeginPrice < newPrice && newPrice < item.EndPrice)
{
newPrice = item.ComputedPrice(newPrice);
}
}
if (newPrice == oldPrice)
{
newPrice = SectionList.Last().ComputedPrice(newPrice);
}
}
return newPrice;
}
public override SkuMaps ComputedPrice(SkuMaps skuMaps)
{
foreach (var item in skuMaps)
{
item.Price = ComputedPrice(item.Price);
}
return skuMaps;
}
/// <summary>
/// 指定区间价格
/// </summary>
public class SectionItemPrice : MultiplesPrice
{
/// <summary>
/// 开始价格
/// </summary>
public decimal BeginPrice { get; set; } = 0;
/// <summary>
/// 结束价格
/// </summary>
public decimal EndPrice { get; set; } = 10000000;
}
}
}