【优化】优化全局营销,团购,秒杀优惠模式结算策略,增加了优惠是否针对单个数量或者批量购买的情况。

This commit is contained in:
jianweie code
2023-11-08 17:02:08 +08:00
parent daa7bc371f
commit 685a9a39f1
5 changed files with 259 additions and 6 deletions

View File

@@ -269,7 +269,15 @@ namespace CoreCms.Net.Services
//此处不存储优惠后单价,防止出现针对单个产品,多个数量情况下,单一优惠券无法针对每个数量的商品进行计算售价。
//cartProducts.products.price = Math.Round(cartProducts.products.price - objMoney, 2);
//此次商品促销一共优惠了多少钱
promotionMoney = promotionInfo.type == (int)GlobalEnumVars.PromotionType.Coupon ? isApplyToNum == 1 ? objMoney : Math.Round(cartProducts.nums * objMoney, 2) : Math.Round(cartProducts.nums * objMoney, 2);
if (promotionInfo.type is (int)GlobalEnumVars.PromotionType.Coupon or (int)GlobalEnumVars.PromotionType.Seckill or (int)GlobalEnumVars.PromotionType.Group or (int)GlobalEnumVars.PromotionType.Promotion)
{
promotionMoney = isApplyToNum == 1 ? objMoney : Math.Round(cartProducts.nums * objMoney, 2);
}
else
{
promotionMoney = Math.Round(cartProducts.nums * objMoney, 2);
}
//promotionMoney = promotionInfo.type == (int)GlobalEnumVars.PromotionType.Coupon ? isApplyToNum == 1 ? objMoney : Math.Round(cartProducts.nums * objMoney, 2) : Math.Round(cartProducts.nums * objMoney, 2);
//设置商品优惠总金额
cartProducts.products.promotionAmount = Math.Round(cartProducts.products.promotionAmount + promotionMoney, 2);
//设置商品的实际销售金额(单品)
@@ -303,7 +311,16 @@ namespace CoreCms.Net.Services
//单品优惠的金额
var pmoney = Math.Round(goodsPrice - productsPrice, 2);
var promotionMoney = promotionInfo.type == (int)GlobalEnumVars.PromotionType.Coupon ? isApplyToNum == 1 ? pmoney : Math.Round(cartProducts.nums * pmoney, 2) : Math.Round(cartProducts.nums * pmoney, 2);
decimal promotionMoney = 0;
if (promotionInfo.type is (int)GlobalEnumVars.PromotionType.Coupon or (int)GlobalEnumVars.PromotionType.Seckill or (int)GlobalEnumVars.PromotionType.Group or (int)GlobalEnumVars.PromotionType.Promotion)
{
promotionMoney = isApplyToNum == 1 ? pmoney : Math.Round(cartProducts.nums * pmoney, 2);
}
else
{
promotionMoney = Math.Round(cartProducts.nums * pmoney, 2);
}
//var promotionMoney = promotionInfo.type == (int)GlobalEnumVars.PromotionType.Coupon ? isApplyToNum == 1 ? pmoney : Math.Round(cartProducts.nums * pmoney, 2) : Math.Round(cartProducts.nums * pmoney, 2);
//设置商品优惠总金额
cartProducts.products.promotionAmount = Math.Round(cartProducts.products.promotionAmount + promotionMoney, 2);
//设置商品的实际销售总金额
@@ -331,7 +348,15 @@ namespace CoreCms.Net.Services
var productsPrice = Math.Round(objMoney, 2);
//单品优惠的金额
var pmoney = Math.Round(goodsPrice - productsPrice, 2);
promotionMoney = promotionInfo.type == (int)GlobalEnumVars.PromotionType.Coupon ? isApplyToNum == 1 ? pmoney : Math.Round(cartProducts.nums * pmoney, 2) : Math.Round(cartProducts.nums * pmoney, 2);
if (promotionInfo.type is (int)GlobalEnumVars.PromotionType.Coupon or (int)GlobalEnumVars.PromotionType.Seckill or (int)GlobalEnumVars.PromotionType.Group or (int)GlobalEnumVars.PromotionType.Promotion)
{
promotionMoney = isApplyToNum == 1 ? pmoney : Math.Round(cartProducts.nums * pmoney, 2);
}
else
{
promotionMoney = Math.Round(cartProducts.nums * pmoney, 2);
}
//promotionMoney = promotionInfo.type == (int)GlobalEnumVars.PromotionType.Coupon ? isApplyToNum == 1 ? pmoney : Math.Round(cartProducts.nums * pmoney, 2) : Math.Round(cartProducts.nums * pmoney, 2);
//设置商品优惠总金额
cartProducts.products.promotionAmount = Math.Round(cartProducts.products.promotionAmount + promotionMoney, 2);
//设置商品的实际销售总金额