优化结算
This commit is contained in:
@@ -92,7 +92,7 @@
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
import { findCoupon } from '@/api/account.js'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import * as UTILS from '@/utils/coupon-utils.js';
|
||||
import { useUser } from "@/store/user.js";
|
||||
|
||||
@@ -203,8 +203,6 @@ function selectCoupon($event, e) {
|
||||
}
|
||||
}
|
||||
|
||||
updateSelCoupon();
|
||||
|
||||
console.log('goodsStore.cartInfo===', goodsStore.cartInfo);
|
||||
|
||||
|
||||
@@ -248,6 +246,7 @@ function selectCoupon($event, e) {
|
||||
// showDialog.value = false
|
||||
}
|
||||
|
||||
let orderPrice = ref(goodsStore.cartInfo.costSummary.goodsRealAmount);
|
||||
function updateSelCoupon() {
|
||||
const newval = [...goodsCoupon.value, ...discountCoupon.value];
|
||||
|
||||
@@ -266,7 +265,7 @@ function updateSelCoupon() {
|
||||
canDikouGoodsArr,
|
||||
v,
|
||||
user,
|
||||
goodsStore.cartInfo.costSummary.goodsRealAmount,
|
||||
orderPrice.value,
|
||||
[],
|
||||
shopInfo
|
||||
);
|
||||
@@ -277,36 +276,65 @@ function updateSelCoupon() {
|
||||
};
|
||||
});
|
||||
otherCoupon = otherCoupon.map((v) => {
|
||||
const canuseResult = UTILS.returnCouponCanUse({
|
||||
canDikouGoodsArr,
|
||||
coupon: v,
|
||||
orderPrice: orderPrice.value,
|
||||
user: user,
|
||||
selCoupon: goodsCoupon,
|
||||
shopInfo: shopInfo,
|
||||
});
|
||||
|
||||
const discount = UTILS.returnCouponDiscount(
|
||||
canDikouGoodsArr,
|
||||
v,
|
||||
user,
|
||||
goodsStore.cartInfo.costSummary.goodsRealAmount,
|
||||
orderPrice.value,
|
||||
goodsCoupon,
|
||||
shopInfo
|
||||
);
|
||||
return {
|
||||
...v,
|
||||
canuseResult,
|
||||
discount,
|
||||
discountAmount: discount ? discount.discountPrice : v.discountAmount,
|
||||
};
|
||||
});
|
||||
|
||||
console.log('otherCoupon[0]===', otherCoupon[0]);
|
||||
console.log('goodsCoupon[0]===', goodsCoupon[0]);
|
||||
|
||||
discountCoupon.value = [otherCoupon[0]];
|
||||
goodsCoupon.value = [goodsCoupon[0]];
|
||||
if (!otherCoupon[0].canuseResult.canUse) {
|
||||
ElMessage.warning('已为您自动剔除叠加不可用的优惠券')
|
||||
discountCoupon.value = [];
|
||||
goodsCoupon.value = goodsCoupon;
|
||||
return;
|
||||
}
|
||||
goodsCoupon.value = goodsCoupon;
|
||||
discountCoupon.value = otherCoupon;
|
||||
}
|
||||
}
|
||||
|
||||
// 确认选择优惠券,然后关闭弹窗
|
||||
function selectCouponConfirm() {
|
||||
showDialog.value = false
|
||||
const data = [...goodsCoupon.value, ...discountCoupon.value]
|
||||
updateSelCoupon();
|
||||
|
||||
let ngoodsCoupon = goodsCoupon.value.filter(item => item.discountAmount > 0)
|
||||
let ndiscountCoupon = discountCoupon.value.filter(item => item.discountAmount > 0)
|
||||
|
||||
if (ngoodsCoupon.length != goodsCoupon.value.length || ndiscountCoupon.length != discountCoupon.value.length) {
|
||||
ElMessage.warning('已为您自动剔除叠加不可用的优惠券')
|
||||
}
|
||||
|
||||
console.log('ngoodsCoupon', ngoodsCoupon);
|
||||
console.log('ndiscountCoupon', ndiscountCoupon);
|
||||
|
||||
const data = [...ngoodsCoupon, ...ndiscountCoupon]
|
||||
|
||||
console.log(data);
|
||||
|
||||
// return
|
||||
emits('success', data)
|
||||
goodsCoupon.value = []
|
||||
discountCoupon.value = []
|
||||
|
||||
showDialog.value = false
|
||||
}
|
||||
|
||||
const querForm = ref({
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
<div class="t2">
|
||||
<span>商品原价:¥{{ goodsStore.cartInfo.costSummary.goodsRealAmount || 0 }}</span>
|
||||
<span>餐位费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.seatFee || 0)
|
||||
}}</span>
|
||||
}}</span>
|
||||
<span>打包费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.packFee || 0)
|
||||
}}</span>
|
||||
}}</span>
|
||||
<span>优惠:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.totalDiscountAmount || 0) }}</span>
|
||||
<!-- <span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
|
||||
<span>折扣:{{ goodsStore.cartInfo.costSummary.goodsDiscountAmount }}</span>
|
||||
@@ -123,8 +123,8 @@
|
||||
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
||||
</el-dialog>
|
||||
<el-dialog v-model="showCoupon"
|
||||
:title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount || 0)})`"
|
||||
top="5vh" width="80%" @open="couponDialogOpen">
|
||||
:title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount || 0)})`" top="5vh" width="80%"
|
||||
@open="couponDialogOpen">
|
||||
<div class="coupom_dialog">
|
||||
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
||||
<el-form-item label="选择会员">
|
||||
@@ -443,7 +443,7 @@ function upadatePayData() {
|
||||
vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价
|
||||
allPack: goodsStore.allSelected, // 是否整单打包
|
||||
userId: goodsStore.vipUserInfo.userId || '',
|
||||
seatNum: goodsStore.tableInfo.num, // 用餐人数
|
||||
seatNum: goodsStore.allSelected ? 0 : goodsStore.tableInfo.num, // 用餐人数
|
||||
originAmount: formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
|
||||
discountAmount: discountRateNumber.value, // 手动优惠金额
|
||||
|
||||
Reference in New Issue
Block a user