fix: 优惠券方法更新
This commit is contained in:
@@ -31,10 +31,14 @@
|
||||
<!-- 打包费 -->
|
||||
<template v-if="carts.packNum > 0">
|
||||
<div class="cart-title"><span>打包费</span></div>
|
||||
<extra-fee name="打包费" :number="carts.packNum" :price="carts.packFee"></extra-fee>
|
||||
<extra-fee
|
||||
name="打包费"
|
||||
:number="carts.packNum"
|
||||
:price="carts.orderCostSummary.packFee"
|
||||
></extra-fee>
|
||||
</template>
|
||||
<!-- 餐位费 -->
|
||||
<template v-if="perpole >= 1">
|
||||
<template v-if="perpole >= 1 && carts.dinnerType == 'dine-in'">
|
||||
<div class="cart-title"><span>餐位费</span></div>
|
||||
<extra-fee name="餐位费" :number="perpole" :price="canWeiFee"></extra-fee>
|
||||
</template>
|
||||
|
||||
@@ -253,11 +253,7 @@ function refGuaZhangConfirm(guazhangRen) {
|
||||
function refGuaZhangShow() {
|
||||
refGuaZhang.value.open();
|
||||
}
|
||||
//商品列表
|
||||
let goodsArr = [];
|
||||
|
||||
//优惠券
|
||||
let $goodsPayPriceMap = {};
|
||||
const refCoupon = ref();
|
||||
let quansSelArr = ref([]);
|
||||
function openCoupon() {
|
||||
@@ -276,7 +272,6 @@ function refCouponConfirm(e, goodsList) {
|
||||
title: v.name,
|
||||
};
|
||||
});
|
||||
goodsArr = goodsList;
|
||||
console.log("refCouponConfirm", e);
|
||||
carts.setCoupons(e);
|
||||
|
||||
@@ -291,7 +286,6 @@ function delQuan(row) {
|
||||
}
|
||||
carts.setCoupons(quansSelArr.value);
|
||||
}
|
||||
function couponChange(data) {}
|
||||
|
||||
//打折
|
||||
const refDiscount = ref();
|
||||
@@ -313,25 +307,40 @@ function discountConfirm(e) {
|
||||
usePointsNumber.value = 0;
|
||||
}
|
||||
|
||||
//计算商家减免前金额
|
||||
// 计算商家减免前金额(使用bignumber.js确保精度)
|
||||
function returnMerchantReductionDiscount() {
|
||||
const {
|
||||
goodsOriginalAmount, // 商品原价总和
|
||||
goodsDiscountAmount, // 减去商品折扣
|
||||
couponDeductionAmount, // 减去优惠券抵扣
|
||||
pointDeductionAmount, // 减去积分抵扣
|
||||
merchantReductionActualAmount, // 减去商家实际减免金额
|
||||
seatFee, // 加上餐位费(不参与减免)
|
||||
packFee, // 加上打包费(不参与减免)
|
||||
goodsDiscountAmount, // 商品折扣
|
||||
couponDeductionAmount, // 优惠券抵扣
|
||||
pointDeductionAmount, // 积分抵扣
|
||||
seatFee, // 餐位费(不参与减免)
|
||||
packFee, // 打包费(不参与减免)
|
||||
additionalFee,
|
||||
} = carts.orderCostSummary;
|
||||
const total =
|
||||
goodsOriginalAmount - // 商品原价总和
|
||||
goodsDiscountAmount - // 减去商品折扣
|
||||
couponDeductionAmount; // 减去优惠券抵扣
|
||||
|
||||
return total <= 0 ? 0 : total;
|
||||
// 将所有金额转换为BigNumber实例
|
||||
const originalAmount = new BigNumber(goodsOriginalAmount);
|
||||
const discountAmount = new BigNumber(goodsDiscountAmount);
|
||||
const couponAmount = new BigNumber(couponDeductionAmount);
|
||||
const pointAmount = new BigNumber(pointDeductionAmount);
|
||||
const seat = new BigNumber(seatFee);
|
||||
const pack = new BigNumber(packFee);
|
||||
const additional = new BigNumber(additionalFee);
|
||||
|
||||
// 按照原逻辑进行精确计算
|
||||
const total = originalAmount
|
||||
.minus(discountAmount) // 减去商品折扣
|
||||
.minus(couponAmount) // 减去优惠券抵扣
|
||||
.minus(pointAmount) // 减去积分抵扣
|
||||
.plus(seat) // 加上餐位费
|
||||
.plus(pack) // 加上打包费
|
||||
.plus(additional); // 加上附加费
|
||||
|
||||
// 确保结果不小于0,返回数字类型
|
||||
return total.lte(0) ? 0 : total.toNumber();
|
||||
}
|
||||
|
||||
function discountShow(e) {
|
||||
refDiscount.value.open({
|
||||
// amount: carts.goodsTotal - productCouponDiscountAmount.value,
|
||||
@@ -396,7 +405,11 @@ const pointsRes = ref({ usable: true, maxUsablePoints: 0, minDeductionPoints: 0
|
||||
const usePointsNumber = ref(0);
|
||||
//积分可抵扣最大金额
|
||||
const scoreMaxMoney = computed(() => {
|
||||
return carts.orderCostSummary.finalPayAmount + carts.orderCostSummary.pointDeductionAmount;
|
||||
return (
|
||||
carts.orderCostSummary.finalPayAmount +
|
||||
carts.orderCostSummary.pointDeductionAmount -
|
||||
carts.orderCostSummary.merchantReduction.actualAmount
|
||||
);
|
||||
});
|
||||
watch(
|
||||
() => scoreMaxMoney.value,
|
||||
@@ -433,14 +446,7 @@ const emits = defineEmits(["chooseUser", "paysuccess"]);
|
||||
function chooseUser() {
|
||||
emits("chooseUser");
|
||||
}
|
||||
const coupDiscount = computed(() => {
|
||||
const total =
|
||||
props.orderInfo.fullCouponDiscountAmount * 1 + props.orderInfo.productCouponDiscountAmount * 1;
|
||||
if (total <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return total.toFixed(2);
|
||||
});
|
||||
|
||||
const score = reactive({
|
||||
list: [],
|
||||
sel: -1,
|
||||
@@ -495,7 +501,7 @@ function returnPayParams() {
|
||||
orderId: props.orderInfo.id,
|
||||
// discountRatio: (checkOrderPay.discount / 100).toFixed(2),
|
||||
discountRatio: 0,
|
||||
seatNum: props.perpole * 1,
|
||||
seatNum: carts.dinnerType == "dine-in" ? props.perpole * 1 : 0,
|
||||
originAmount: carts.orderCostSummary.goodsRealAmount,
|
||||
discountAmount: discountAmount.value,
|
||||
productCouponDiscountAmount: carts.orderCostSummary.productCouponDeduction,
|
||||
|
||||
Reference in New Issue
Block a user