Преглед изворни кода

fix(mallApp): 修正混合结算优惠金额计算

- 将秒杀商品金额从整单优惠基数剔除,并在折后按原额计入实付
- 将跑腿费排除在会员折扣和门店满减之外,保持前后端计价口径一致
shizhongqi пре 15 часа
родитељ
комит
3e91a71598
1 измењених фајлова са 29 додато и 16 уклоњено
  1. 29 16
      mallApp/src/pages/billing/affirmMix.vue

+ 29 - 16
mallApp/src/pages/billing/affirmMix.vue

@@ -737,10 +737,11 @@ export default {
 			return Math.round(price * 100) / 100;
 		},
 		/**
-		 * 整单互斥优惠前的应付:先按商品+运费包装-红包得到应付,再剔除秒杀额。
-		 * 与后端 actionCreateMixOrder 红包后的 modifyPrice,经 capSeckillExcludePrice 后的优惠基数对齐。
+		 * 整单互斥优惠前的基数(剔秒杀前):商品+运费包装-红包。
+		 * 跑腿费(sendType=2 的 sendCost)不参与会员折/门店满减基数,实付时折后原额加回;
+		 * 红包只抵商品不抵运费。与后端 actionCreateMixOrder 的 wholeDiscountPrice 口径对齐。
 		 */
-		wholeDiscountBasePrice() {
+		wholePriceBeforeSeckill() {
 			let price = Number(this.mixGoodsPrice) || 0;
 
 			if (this.hasAvailableHb && this.selectedHbId) {
@@ -748,21 +749,27 @@ export default {
 			}
 			if (price < 0) price = 0;
 
-			const unMeetSend = Number(this.form.unMeetSendCost) || 0;
-			const packCost = Number(this.form.packCost) || 0;
-
-			if (this.form.sendType == 2) {
-				price = price + Number(this.isFreeDelivery ? 0 : this.form.sendCost || 0) + unMeetSend + packCost;
-			} else if ([0, 3, 4].includes(Number(this.form.sendType))) {
-				price = price + unMeetSend + packCost;
+			// 跑腿费不计入折扣基数,各配送方式仅加运费与包装费
+			if ([0, 2, 3, 4].includes(Number(this.form.sendType))) {
+				price = price + (Number(this.form.unMeetSendCost) || 0) + (Number(this.form.packCost) || 0);
 			}
-
-			// 秒杀价不参与会员折/门店满减;剔除额不超过当前应付,避免红包已吃进秒杀时把基数打成负数
+			return parseFloat(price.toFixed(2));
+		},
+		/**
+		 * 从折扣基数剔除的秒杀额(不超过基数),实付时原额加回。
+		 * 与后端 capSeckillExcludePrice 对齐。
+		 */
+		seckillExcludePrice() {
 			let seckillPrice = Number(this.mixSeckillGoodsPrice) || 0;
-			if (seckillPrice > price) seckillPrice = price;
-			if (seckillPrice > 0) {
-				price = price - seckillPrice;
-			}
+			const base = Number(this.wholePriceBeforeSeckill) || 0;
+			if (seckillPrice > base) seckillPrice = base;
+			return seckillPrice > 0 ? parseFloat(seckillPrice.toFixed(2)) : 0;
+		},
+		/**
+		 * 整单互斥优惠基数:商品+运费包装-红包-秒杀额(不含跑腿费)。
+		 */
+		wholeDiscountBasePrice() {
+			let price = (Number(this.wholePriceBeforeSeckill) || 0) - (Number(this.seckillExcludePrice) || 0);
 			if (price < 0) price = 0;
 			return parseFloat(price.toFixed(2));
 		},
@@ -793,6 +800,12 @@ export default {
 		modifyPrice() {
 			let price = Number(this.wholeDiscountBasePrice) || 0;
 			price = price - (Number(this.wholeDiscountPick.amount) || 0);
+			// 秒杀额不参与折扣但计入实付,原额加回
+			price = price + (Number(this.seckillExcludePrice) || 0);
+			// 跑腿费不参与整单折扣,折后原额加回计入实付(免跑腿时 sendCost 已为 0)
+			if (Number(this.form.sendType) === 2 && !this.isFreeDelivery) {
+				price = price + (Number(this.form.sendCost) || 0);
+			}
 			if (price < 0) price = 0;
 			return parseFloat(price.toFixed(2));
 		},