fix: 修改订单计算逻辑

This commit is contained in:
2025-09-19 18:32:44 +08:00
parent f76dff67d4
commit 4934f20446
5 changed files with 343 additions and 239 deletions

View File

@@ -110,12 +110,7 @@
</el-table-column>
<el-table-column prop="discountAmount" label="抵扣">
<template v-slot="scope">
<span class="color-red" v-if="scope.row.type == 1">
{{ scope.row.discountAmount }}
</span>
<span class="color-red" v-if="scope.row.type == 2">
{{ returnProDiscount(scope.row, scope.row.index) }}
</span>
<span class="color-red">{{ scope.row.discountAmount }}</span>
</template>
</el-table-column>
<el-table-column prop="useRestrictions" label="操作">
@@ -274,34 +269,28 @@ let $goodsPayPriceMap = {};
const refCoupon = ref();
let quansSelArr = ref([]);
function openCoupon() {
refCoupon.value.open(carts.goodsTotal, props.orderInfo);
//商品订单金额
const price = new BigNumber(carts.orderCostSummary.goodsOriginalAmount)
.minus(carts.orderCostSummary.goodsDiscountAmount)
.toFixed(2);
refCoupon.value.open(price, props.orderInfo);
}
//返回商品券抵扣金额
function returnProDiscount(row) {
//相同商品抵扣券数组
const arr = quansSelArr.value.filter((v) => v.type == 2 && v.proId == row.proId);
console.log(arr);
const index = arr.findIndex((v) => v.id == row.id);
const item = goodsArr.find((v) => v.productId == row.proId);
if (index != -1) {
const n = quanUtil.returnProductCoupAllPrice(
$goodsPayPriceMap[row.proId],
index,
row.num,
props.user.id && props.user.isVip
);
return n.toFixed(2);
} else {
return 0;
}
}
function refCouponConfirm(e, goodsPayPriceMap, goodsList) {
function refCouponConfirm(e, goodsList) {
e = e.map((v) => {
return {
...v,
couponType: v.type,
title: v.name,
};
});
goodsArr = goodsList;
usePointsNumber.value = 0;
pointsDiscountAmount.value = 0;
score.sel = -1;
console.log("refCouponConfirm", e);
quansSelArr.value = e;
$goodsPayPriceMap = goodsPayPriceMap;
carts.setCoupons(e);
checkOrderPay.discountAmount = 0;
checkOrderPay.discount = 0;
score.sel = -1;