优化结算
This commit is contained in:
parent
125365f3dc
commit
25ae5a7b80
File diff suppressed because one or more lines are too long
|
|
@ -27,7 +27,7 @@
|
||||||
"uuid": "^10.0.0",
|
"uuid": "^10.0.0",
|
||||||
"vue": "^3.3.8",
|
"vue": "^3.3.8",
|
||||||
"vue-router": "^4.2.5",
|
"vue-router": "^4.2.5",
|
||||||
"ysk-utils": "^1.0.45"
|
"ysk-utils": "^1.0.47"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^4.5.0",
|
"@vitejs/plugin-vue": "^4.5.0",
|
||||||
|
|
@ -7636,9 +7636,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ysk-utils": {
|
"node_modules/ysk-utils": {
|
||||||
"version": "1.0.45",
|
"version": "1.0.47",
|
||||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.45.tgz",
|
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.47.tgz",
|
||||||
"integrity": "sha512-VXIwQ6uvPY0YJRomPx/b77e3r4+w2i+aXYHtmCliZHSdcbaQZUGeLLSkSWZBh8k+OE5YkQbM8pmrBdwuLTDW+A==",
|
"integrity": "sha512-OoH+uLVysu0nkVYtj3VPZJlkk0c22uFgmvh25W5ERBCHfo/4CyHVyPVEmtiJdiXBiTFQiuwaFmTsQsv6l2YvUQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bignumber.js": "^9.3.1",
|
"bignumber.js": "^9.3.1",
|
||||||
"lodash": "^4.17.21"
|
"lodash": "^4.17.21"
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
"uuid": "^10.0.0",
|
"uuid": "^10.0.0",
|
||||||
"vue": "^3.3.8",
|
"vue": "^3.3.8",
|
||||||
"vue-router": "^4.2.5",
|
"vue-router": "^4.2.5",
|
||||||
"ysk-utils": "^1.0.45"
|
"ysk-utils": "^1.0.47"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^4.5.0",
|
"@vitejs/plugin-vue": "^4.5.0",
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@
|
||||||
import { ref, reactive, computed } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
import { useGoods } from '@/store/goods.js'
|
import { useGoods } from '@/store/goods.js'
|
||||||
import { findCoupon } from '@/api/account.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 * as UTILS from '@/utils/coupon-utils.js';
|
||||||
import { useUser } from "@/store/user.js";
|
import { useUser } from "@/store/user.js";
|
||||||
|
|
||||||
|
|
@ -203,8 +203,6 @@ function selectCoupon($event, e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSelCoupon();
|
|
||||||
|
|
||||||
console.log('goodsStore.cartInfo===', goodsStore.cartInfo);
|
console.log('goodsStore.cartInfo===', goodsStore.cartInfo);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -248,6 +246,7 @@ function selectCoupon($event, e) {
|
||||||
// showDialog.value = false
|
// showDialog.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let orderPrice = ref(goodsStore.cartInfo.costSummary.goodsRealAmount);
|
||||||
function updateSelCoupon() {
|
function updateSelCoupon() {
|
||||||
const newval = [...goodsCoupon.value, ...discountCoupon.value];
|
const newval = [...goodsCoupon.value, ...discountCoupon.value];
|
||||||
|
|
||||||
|
|
@ -266,7 +265,7 @@ function updateSelCoupon() {
|
||||||
canDikouGoodsArr,
|
canDikouGoodsArr,
|
||||||
v,
|
v,
|
||||||
user,
|
user,
|
||||||
goodsStore.cartInfo.costSummary.goodsRealAmount,
|
orderPrice.value,
|
||||||
[],
|
[],
|
||||||
shopInfo
|
shopInfo
|
||||||
);
|
);
|
||||||
|
|
@ -277,36 +276,65 @@ function updateSelCoupon() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
otherCoupon = otherCoupon.map((v) => {
|
otherCoupon = otherCoupon.map((v) => {
|
||||||
|
const canuseResult = UTILS.returnCouponCanUse({
|
||||||
|
canDikouGoodsArr,
|
||||||
|
coupon: v,
|
||||||
|
orderPrice: orderPrice.value,
|
||||||
|
user: user,
|
||||||
|
selCoupon: goodsCoupon,
|
||||||
|
shopInfo: shopInfo,
|
||||||
|
});
|
||||||
|
|
||||||
const discount = UTILS.returnCouponDiscount(
|
const discount = UTILS.returnCouponDiscount(
|
||||||
canDikouGoodsArr,
|
canDikouGoodsArr,
|
||||||
v,
|
v,
|
||||||
user,
|
user,
|
||||||
goodsStore.cartInfo.costSummary.goodsRealAmount,
|
orderPrice.value,
|
||||||
goodsCoupon,
|
goodsCoupon,
|
||||||
shopInfo
|
shopInfo
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
|
canuseResult,
|
||||||
discount,
|
discount,
|
||||||
discountAmount: discount ? discount.discountPrice : v.discountAmount,
|
discountAmount: discount ? discount.discountPrice : v.discountAmount,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
if (!otherCoupon[0].canuseResult.canUse) {
|
||||||
console.log('otherCoupon[0]===', otherCoupon[0]);
|
ElMessage.warning('已为您自动剔除叠加不可用的优惠券')
|
||||||
console.log('goodsCoupon[0]===', goodsCoupon[0]);
|
discountCoupon.value = [];
|
||||||
|
goodsCoupon.value = goodsCoupon;
|
||||||
discountCoupon.value = [otherCoupon[0]];
|
return;
|
||||||
goodsCoupon.value = [goodsCoupon[0]];
|
}
|
||||||
|
goodsCoupon.value = goodsCoupon;
|
||||||
|
discountCoupon.value = otherCoupon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确认选择优惠券,然后关闭弹窗
|
// 确认选择优惠券,然后关闭弹窗
|
||||||
function selectCouponConfirm() {
|
function selectCouponConfirm() {
|
||||||
showDialog.value = false
|
updateSelCoupon();
|
||||||
const data = [...goodsCoupon.value, ...discountCoupon.value]
|
|
||||||
|
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)
|
emits('success', data)
|
||||||
goodsCoupon.value = []
|
goodsCoupon.value = []
|
||||||
discountCoupon.value = []
|
discountCoupon.value = []
|
||||||
|
|
||||||
|
showDialog.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const querForm = ref({
|
const querForm = ref({
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
<div class="t2">
|
<div class="t2">
|
||||||
<span>商品原价:¥{{ goodsStore.cartInfo.costSummary.goodsRealAmount || 0 }}</span>
|
<span>商品原价:¥{{ goodsStore.cartInfo.costSummary.goodsRealAmount || 0 }}</span>
|
||||||
<span>餐位费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.seatFee || 0)
|
<span>餐位费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.seatFee || 0)
|
||||||
}}</span>
|
}}</span>
|
||||||
<span>打包费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.packFee || 0)
|
<span>打包费:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.packFee || 0)
|
||||||
}}</span>
|
}}</span>
|
||||||
<span>优惠:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.totalDiscountAmount || 0) }}</span>
|
<span>优惠:¥{{ formatDecimal(goodsStore.cartInfo.costSummary.totalDiscountAmount || 0) }}</span>
|
||||||
<!-- <span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
|
<!-- <span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
|
||||||
<span>折扣:{{ goodsStore.cartInfo.costSummary.goodsDiscountAmount }}</span>
|
<span>折扣:{{ goodsStore.cartInfo.costSummary.goodsDiscountAmount }}</span>
|
||||||
|
|
@ -123,8 +123,8 @@
|
||||||
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
:total="Number(buyerTable.total)" v-model:current-page="buyerTable.page" @current-change="getBuyerList" />
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<el-dialog v-model="showCoupon"
|
<el-dialog v-model="showCoupon"
|
||||||
:title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount || 0)})`"
|
:title="`添加优惠(¥${formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount || 0)})`" top="5vh" width="80%"
|
||||||
top="5vh" width="80%" @open="couponDialogOpen">
|
@open="couponDialogOpen">
|
||||||
<div class="coupom_dialog">
|
<div class="coupom_dialog">
|
||||||
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
<el-form ref="couponFormRef" :model="couponForm" label-width="100" label-position="left">
|
||||||
<el-form-item label="选择会员">
|
<el-form-item label="选择会员">
|
||||||
|
|
@ -443,7 +443,7 @@ function upadatePayData() {
|
||||||
vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价
|
vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价
|
||||||
allPack: goodsStore.allSelected, // 是否整单打包
|
allPack: goodsStore.allSelected, // 是否整单打包
|
||||||
userId: goodsStore.vipUserInfo.userId || '',
|
userId: goodsStore.vipUserInfo.userId || '',
|
||||||
seatNum: goodsStore.tableInfo.num, // 用餐人数
|
seatNum: goodsStore.allSelected ? 0 : goodsStore.tableInfo.num, // 用餐人数
|
||||||
originAmount: formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
|
originAmount: formatDecimal(goodsStore.cartInfo.costSummary.goodsRealAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||||
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
|
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
|
||||||
discountAmount: discountRateNumber.value, // 手动优惠金额
|
discountAmount: discountRateNumber.value, // 手动优惠金额
|
||||||
|
|
|
||||||
|
|
@ -927,8 +927,8 @@ export const useGoods = defineStore("goods", {
|
||||||
|
|
||||||
// 餐位费
|
// 餐位费
|
||||||
const seatFeeConfig = ref({
|
const seatFeeConfig = ref({
|
||||||
pricePerPerson: store.shopInfo.tableFee || 0,
|
pricePerPerson: store.shopInfo.tableFee,
|
||||||
personCount: this.tableInfo.num,
|
personCount: this.allSelected ? 0 : this.tableInfo.num,
|
||||||
isEnabled: !store.shopInfo.isTableFee,
|
isEnabled: !store.shopInfo.isTableFee,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -998,6 +998,10 @@ export const useGoods = defineStore("goods", {
|
||||||
},
|
},
|
||||||
// 购物车操作
|
// 购物车操作
|
||||||
operateCart(data, operate_type = "add") {
|
operateCart(data, operate_type = "add") {
|
||||||
|
|
||||||
|
console.log(`购物车操作${operate_type}===`, data);
|
||||||
|
|
||||||
|
|
||||||
const socket = useSocket();
|
const socket = useSocket();
|
||||||
const store = useUser();
|
const store = useUser();
|
||||||
if (socket.online) {
|
if (socket.online) {
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,9 @@ export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user, s
|
||||||
* @param shopInfo 店铺信息
|
* @param shopInfo 店铺信息
|
||||||
*/
|
*/
|
||||||
export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoupon, shopInfo) {
|
export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoupon, shopInfo) {
|
||||||
|
arr=returnCanDikouGoods(arr,user,shopInfo)
|
||||||
const canDikouGoodsArr = returnCanDikouGoodsArr(arr, selCoupon, user);
|
const canDikouGoodsArr = returnCanDikouGoodsArr(arr, selCoupon, user);
|
||||||
|
console.log('canDikouGoodsArr',canDikouGoodsArr)
|
||||||
if (coupon.type == 2) {
|
if (coupon.type == 2) {
|
||||||
return returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
return returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -395,6 +395,8 @@ function numberChange(t) {
|
||||||
let item = goodsStore.cartList.length ? goodsStore.cartList[goodsStore.cartActiveIndex] : ''
|
let item = goodsStore.cartList.length ? goodsStore.cartList[goodsStore.cartActiveIndex] : ''
|
||||||
if (!item || (item.goods_type == 'package' && item.group_type == 1)) return
|
if (!item || (item.goods_type == 'package' && item.group_type == 1)) return
|
||||||
let number = +goodsStore.cartList[goodsStore.cartActiveIndex].number
|
let number = +goodsStore.cartList[goodsStore.cartActiveIndex].number
|
||||||
|
|
||||||
|
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case 'sub':
|
case 'sub':
|
||||||
if (item.number - 1 < item.suitNum) {
|
if (item.number - 1 < item.suitNum) {
|
||||||
|
|
@ -409,7 +411,7 @@ function numberChange(t) {
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
if (goodsStore.allSelected) {
|
if (goodsStore.allSelected) {
|
||||||
goodsStore.operateCart({ ...goodsStore.cartList[goodsStore.cartActiveIndex], pack_number: number + 1 }, 'edit')
|
goodsStore.operateCart({ ...goodsStore.cartList[goodsStore.cartActiveIndex], pack_number: number + 1, number: number + 1 }, 'edit')
|
||||||
} else {
|
} else {
|
||||||
goodsStore.operateCart({ ...goodsStore.cartList[goodsStore.cartActiveIndex], number: +number + 1 }, 'edit')
|
goodsStore.operateCart({ ...goodsStore.cartList[goodsStore.cartActiveIndex], number: +number + 1 }, 'edit')
|
||||||
}
|
}
|
||||||
|
|
@ -417,6 +419,8 @@ function numberChange(t) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('numberChange===', goodsStore.cartList[goodsStore.cartActiveIndex].number);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 输入修改数量
|
// 输入修改数量
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
<SettleItem :list="orderList" />
|
<SettleItem :list="orderList" />
|
||||||
<SettleItem
|
<SettleItem
|
||||||
:list="[{ id: 'tableFee', product_name: '客座费', number: goodsStore.tableInfo.num, lowPrice: store.shopInfo.tableFee }]"
|
:list="[{ id: 'tableFee', product_name: '客座费', number: goodsStore.tableInfo.num, lowPrice: store.shopInfo.tableFee }]"
|
||||||
v-if="!store.shopInfo.isTableFee && goodsStore.tableInfo.name && (goodsStore.cartList.length || goodsStore.orderList.length)" />
|
v-if="!store.shopInfo.isTableFee && goodsStore.tableInfo.name && (goodsStore.cartList.length || goodsStore.orderList.length) && !goodsStore.allSelected" />
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<!-- <el-button icon="Edit"></el-button> -->
|
<!-- <el-button icon="Edit"></el-button> -->
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
</div>
|
</div>
|
||||||
<CartItem
|
<CartItem
|
||||||
:item="{ product_name: '客座费', number: goodsStore.tableInfo.num, lowPrice: store.shopInfo.tableFee, memberPrice: store.shopInfo.tableFee }"
|
:item="{ product_name: '客座费', number: goodsStore.tableInfo.num, lowPrice: store.shopInfo.tableFee, memberPrice: store.shopInfo.tableFee }"
|
||||||
v-if="!store.shopInfo.isTableFee && goodsStore.tableInfo.id" />
|
v-if="!store.shopInfo.isTableFee && goodsStore.tableInfo.id && !goodsStore.allSelected" />
|
||||||
<div class="order_list_item" v-for="(arr, index) in goodsStore.orderList" :key="index">
|
<div class="order_list_item" v-for="(arr, index) in goodsStore.orderList" :key="index">
|
||||||
<div class="order_num">
|
<div class="order_num">
|
||||||
<span class="l">{{ `第${arr.orderNum}次下单` }}</span>
|
<span class="l">{{ `第${arr.orderNum}次下单` }}</span>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue