From 685a9a39f10b13bfbccfd046f56bf8e938d21639 Mon Sep 17 00:00:00 2001 From: jianweie code Date: Wed, 8 Nov 2023 17:02:08 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=85=A8=E5=B1=80=E8=90=A5=E9=94=80=EF=BC=8C=E5=9B=A2?= =?UTF-8?q?=E8=B4=AD=EF=BC=8C=E7=A7=92=E6=9D=80=E4=BC=98=E6=83=A0=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=BB=93=E7=AE=97=E7=AD=96=E7=95=A5=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E4=BC=98=E6=83=A0=E6=98=AF=E5=90=A6=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E5=8D=95=E4=B8=AA=E6=95=B0=E9=87=8F=E6=88=96=E8=80=85?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E8=B4=AD=E4=B9=B0=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoreCmsPromotionResultServices.cs | 31 ++- .../wwwroot/views/promotion/coupon/edit.html | 2 +- .../wwwroot/views/promotion/group/edit.html | 8 +- .../views/promotion/group/resultcreate.html | 26 ++- .../views/promotion/group/resultedit.html | 198 ++++++++++++++++++ 5 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 CoreCms.Net.Web.Admin/wwwroot/views/promotion/group/resultedit.html diff --git a/CoreCms.Net.Services/Promotion/CoreCmsPromotionResultServices.cs b/CoreCms.Net.Services/Promotion/CoreCmsPromotionResultServices.cs index f3ab7287..bae96fc0 100644 --- a/CoreCms.Net.Services/Promotion/CoreCmsPromotionResultServices.cs +++ b/CoreCms.Net.Services/Promotion/CoreCmsPromotionResultServices.cs @@ -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); //设置商品的实际销售总金额 diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/promotion/coupon/edit.html b/CoreCms.Net.Web.Admin/wwwroot/views/promotion/coupon/edit.html index ce96989c..89366e1d 100644 --- a/CoreCms.Net.Web.Admin/wwwroot/views/promotion/coupon/edit.html +++ b/CoreCms.Net.Web.Admin/wwwroot/views/promotion/coupon/edit.html @@ -78,7 +78,7 @@
- 1、优惠券结果为多条叠加,请注意,如:设置了商品减免20元,又设置了订单减免50元,那么一个优惠券将优惠了70元 + 1、优惠券结果只能为一个结果。但是优惠券可以和全局促销一起使用。请注意合理规避计算风险。
商品优惠的金额
+
+ +
+ + +
+
是否针对所有数量都计算优惠
+
+ + + + + + + + + \ No newline at end of file