增加项目,分层
This commit is contained in:
1 parent
6e995a5bdb
commit
0a3e5af6a9
234 files changed
+26994
-1
No files matched your search
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Product.Models.PublishParameters.Price
|
||||
{
|
||||
/// <summary>
|
||||
/// 计算操作符
|
||||
/// </summary>
|
||||
public enum ComputationType
|
||||
{
|
||||
/// <summary>
|
||||
/// 加
|
||||
/// </summary>
|
||||
ADD,
|
||||
/// <summary>
|
||||
/// 减法
|
||||
/// </summary>
|
||||
SUB
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using Store.Product.Models.Product.Sku;
|
||||
using System.Linq;
|
||||
|
||||
namespace Store.Product.Models.PublishParameters.Price
|
||||
{
|
||||
/// <summary>
|
||||
/// 高低价格配置
|
||||
/// </summary>
|
||||
public class HighLowPrice : PriceConfigBase
|
||||
{
|
||||
public override PriceStrategyType PriceType => PriceStrategyType.高低价格;
|
||||
|
||||
/// <summary>
|
||||
/// 低价倍数
|
||||
/// </summary>
|
||||
public decimal LowMultiples { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// 其他倍数
|
||||
/// </summary>
|
||||
public decimal OtherMultiples { get; set; } = 1;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 计算价格
|
||||
/// </summary>
|
||||
/// <param name="oldPrice"></param>
|
||||
/// <returns></returns>
|
||||
public override decimal ComputedPrice(decimal oldPrice)
|
||||
{
|
||||
return oldPrice * OtherMultiples;
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算最低价
|
||||
/// </summary>
|
||||
/// <param name="oldPrice"></param>
|
||||
/// <returns></returns>
|
||||
public decimal ComputedLowPrice(decimal oldPrice)
|
||||
{
|
||||
return oldPrice * LowMultiples;
|
||||
}
|
||||
|
||||
|
||||
public override SkuMaps ComputedPrice(SkuMaps skuMaps)
|
||||
{
|
||||
decimal minPrice = skuMaps.Min(a => a.Price);
|
||||
foreach (var item in skuMaps)
|
||||
{
|
||||
if (item.Price == minPrice)
|
||||
{
|
||||
ComputedLowPrice(item.Price);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Price = ComputedPrice(item.Price);
|
||||
}
|
||||
}
|
||||
return skuMaps;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
|
||||
using Store.Product.Models.Product.Sku;
|
||||
|
||||
namespace Store.Product.Models.PublishParameters.Price
|
||||
{
|
||||
/// <summary>
|
||||
/// 翻倍价格配置
|
||||
/// </summary>
|
||||
public class MultiplesPrice : PriceConfigBase
|
||||
{
|
||||
public override PriceStrategyType PriceType => PriceStrategyType.常规价格;
|
||||
/// <summary>
|
||||
/// 翻 x 倍
|
||||
/// </summary>
|
||||
public int Multiples { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// 计算
|
||||
/// </summary>
|
||||
public ComputationType Computation { get; set; } = ComputationType.ADD;
|
||||
/// <summary>
|
||||
/// 基础加价
|
||||
/// </summary>
|
||||
public decimal AddPrice { get; set; }
|
||||
public MultiplesPrice() { }
|
||||
/// <summary>
|
||||
/// 翻倍价格配置
|
||||
/// </summary>
|
||||
/// <param name="multiples">倍数</param>
|
||||
/// <param name="addprice">加价</param>
|
||||
public MultiplesPrice(int multiples, decimal addprice)
|
||||
{
|
||||
Multiples = multiples;
|
||||
AddPrice = addprice;
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算价格
|
||||
/// </summary>
|
||||
/// <param name="oldPrice"></param>
|
||||
/// <returns></returns>
|
||||
public override decimal ComputedPrice(decimal oldPrice)
|
||||
{
|
||||
var newPrice = oldPrice;
|
||||
newPrice = oldPrice * Multiples;
|
||||
switch (Computation)
|
||||
{
|
||||
case ComputationType.ADD:
|
||||
newPrice = newPrice + AddPrice;
|
||||
break;
|
||||
case ComputationType.SUB:
|
||||
newPrice = newPrice - AddPrice;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return newPrice;
|
||||
}
|
||||
|
||||
public override SkuMaps ComputedPrice(SkuMaps skuMaps)
|
||||
{
|
||||
foreach (var item in skuMaps)
|
||||
{
|
||||
item.Price = ComputedPrice(item.Price);
|
||||
}
|
||||
return skuMaps;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
using Store.Product.Models.Product.Sku;
|
||||
|
||||
namespace Store.Product.Models.PublishParameters.Price
|
||||
{
|
||||
/// <summary>
|
||||
/// 价格配置
|
||||
/// </summary>
|
||||
public abstract class PriceConfigBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 价格类型
|
||||
/// </summary>
|
||||
public abstract PriceStrategyType PriceType { get; }
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 快递费是否增加到商品价格
|
||||
///// </summary>
|
||||
//public bool IsExpressAddPrice { get; set; } = false;
|
||||
///// <summary>
|
||||
///// 是否随机增加金额 0-1元
|
||||
///// </summary>
|
||||
//public bool IsRandomAddPrice { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 计算价格
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract decimal ComputedPrice(decimal oldPrice);
|
||||
|
||||
/// <summary>
|
||||
/// 计算价格
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract SkuMaps ComputedPrice(SkuMaps skuMaps);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Product.Models.PublishParameters.Price
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class PriceStrategyFactory
|
||||
{
|
||||
public static PriceConfigBase GetPriceStrategy(PriceStrategyType strategyType)
|
||||
{
|
||||
PriceConfigBase priceConfig;
|
||||
switch (strategyType)
|
||||
{
|
||||
case PriceStrategyType.常规价格:
|
||||
priceConfig = new MultiplesPrice();
|
||||
break;
|
||||
case PriceStrategyType.高低价格:
|
||||
priceConfig = new HighLowPrice();
|
||||
break;
|
||||
case PriceStrategyType.分段价格:
|
||||
priceConfig = new SectionPrice();
|
||||
break;
|
||||
default:
|
||||
priceConfig = null;
|
||||
break;
|
||||
}
|
||||
return priceConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Store.Product.Models.PublishParameters.Price
|
||||
{
|
||||
/// <summary>
|
||||
/// 价格策略类型
|
||||
/// </summary>
|
||||
public enum PriceStrategyType
|
||||
{
|
||||
常规价格 = 0,
|
||||
高低价格 = 1,
|
||||
分段价格 = 2
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user