优化结算
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",
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5",
|
||||
"ysk-utils": "^1.0.45"
|
||||
"ysk-utils": "^1.0.47"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
|
|
@ -7636,9 +7636,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/ysk-utils": {
|
||||
"version": "1.0.45",
|
||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.45.tgz",
|
||||
"integrity": "sha512-VXIwQ6uvPY0YJRomPx/b77e3r4+w2i+aXYHtmCliZHSdcbaQZUGeLLSkSWZBh8k+OE5YkQbM8pmrBdwuLTDW+A==",
|
||||
"version": "1.0.47",
|
||||
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.47.tgz",
|
||||
"integrity": "sha512-OoH+uLVysu0nkVYtj3VPZJlkk0c22uFgmvh25W5ERBCHfo/4CyHVyPVEmtiJdiXBiTFQiuwaFmTsQsv6l2YvUQ==",
|
||||
"dependencies": {
|
||||
"bignumber.js": "^9.3.1",
|
||||
"lodash": "^4.17.21"
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
"uuid": "^10.0.0",
|
||||
"vue": "^3.3.8",
|
||||
"vue-router": "^4.2.5",
|
||||
"ysk-utils": "^1.0.45"
|
||||
"ysk-utils": "^1.0.47"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
|
|
|
|||
|
|
@ -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, // 手动优惠金额
|
||||
|
|
|
|||
|
|
@ -927,8 +927,8 @@ export const useGoods = defineStore("goods", {
|
|||
|
||||
// 餐位费
|
||||
const seatFeeConfig = ref({
|
||||
pricePerPerson: store.shopInfo.tableFee || 0,
|
||||
personCount: this.tableInfo.num,
|
||||
pricePerPerson: store.shopInfo.tableFee,
|
||||
personCount: this.allSelected ? 0 : this.tableInfo.num,
|
||||
isEnabled: !store.shopInfo.isTableFee,
|
||||
});
|
||||
|
||||
|
|
@ -998,6 +998,10 @@ export const useGoods = defineStore("goods", {
|
|||
},
|
||||
// 购物车操作
|
||||
operateCart(data, operate_type = "add") {
|
||||
|
||||
console.log(`购物车操作${operate_type}===`, data);
|
||||
|
||||
|
||||
const socket = useSocket();
|
||||
const store = useUser();
|
||||
if (socket.online) {
|
||||
|
|
|
|||
|
|
@ -295,7 +295,9 @@ export function calcDiscountGoodsArrPrice(discountGoodsArr, discountNum, user, s
|
|||
* @param shopInfo 店铺信息
|
||||
*/
|
||||
export function returnCouponDiscount(arr, coupon, user, goodsOrderPrice, selCoupon, shopInfo) {
|
||||
arr=returnCanDikouGoods(arr,user,shopInfo)
|
||||
const canDikouGoodsArr = returnCanDikouGoodsArr(arr, selCoupon, user);
|
||||
console.log('canDikouGoodsArr',canDikouGoodsArr)
|
||||
if (coupon.type == 2) {
|
||||
return returnCouponProductDiscount(canDikouGoodsArr, coupon, user, shopInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -395,6 +395,8 @@ function numberChange(t) {
|
|||
let item = goodsStore.cartList.length ? goodsStore.cartList[goodsStore.cartActiveIndex] : ''
|
||||
if (!item || (item.goods_type == 'package' && item.group_type == 1)) return
|
||||
let number = +goodsStore.cartList[goodsStore.cartActiveIndex].number
|
||||
|
||||
|
||||
switch (t) {
|
||||
case 'sub':
|
||||
if (item.number - 1 < item.suitNum) {
|
||||
|
|
@ -409,7 +411,7 @@ function numberChange(t) {
|
|||
break;
|
||||
case 'add':
|
||||
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 {
|
||||
goodsStore.operateCart({ ...goodsStore.cartList[goodsStore.cartActiveIndex], number: +number + 1 }, 'edit')
|
||||
}
|
||||
|
|
@ -417,6 +419,8 @@ function numberChange(t) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
console.log('numberChange===', goodsStore.cartList[goodsStore.cartActiveIndex].number);
|
||||
}
|
||||
|
||||
// 输入修改数量
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<SettleItem :list="orderList" />
|
||||
<SettleItem
|
||||
: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 class="footer">
|
||||
<!-- <el-button icon="Edit"></el-button> -->
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@
|
|||
</div>
|
||||
<CartItem
|
||||
: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_num">
|
||||
<span class="l">{{ `第${arr.orderNum}次下单` }}</span>
|
||||
|
|
|
|||
Loading…
Reference in New Issue