问题修复

This commit is contained in:
gyq 2025-10-13 18:55:30 +08:00
parent 8e3bc9cc3b
commit 125365f3dc
9 changed files with 138 additions and 69 deletions

File diff suppressed because one or more lines are too long

8
package-lock.json generated
View File

@ -27,7 +27,7 @@
"uuid": "^10.0.0",
"vue": "^3.3.8",
"vue-router": "^4.2.5",
"ysk-utils": "^1.0.42"
"ysk-utils": "^1.0.45"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.5.0",
@ -7636,9 +7636,9 @@
}
},
"node_modules/ysk-utils": {
"version": "1.0.42",
"resolved": "https://registry.npmmirror.com/ysk-utils/-/ysk-utils-1.0.42.tgz",
"integrity": "sha512-bXeCu3hhUVpYaURf0LAYUqmcjRwhw2SC7TluyaowVlEjiFp9iaV/fsaC7gwj9Uu8i9gQGSY3EOTDNoEThAWVOQ==",
"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==",
"dependencies": {
"bignumber.js": "^9.3.1",
"lodash": "^4.17.21"

View File

@ -30,7 +30,7 @@
"uuid": "^10.0.0",
"vue": "^3.3.8",
"vue-router": "^4.2.5",
"ysk-utils": "^1.0.42"
"ysk-utils": "^1.0.45"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.5.0",

View File

@ -205,6 +205,9 @@ function selectCoupon($event, e) {
updateSelCoupon();
console.log('goodsStore.cartInfo===', goodsStore.cartInfo);
// if (query.value.type == 1) {
// emits('success', { type: query.value.type, couponList: [{ ...row }] })

View File

@ -13,16 +13,15 @@
</div> -->
</div>
<div class="t2">
<span>原价:{{ goodsStore.cartInfo.costSummary.goodsOriginalAmount }}</span>
<span>餐位费:{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount.seatFee || 0)
}}</span>
<span>打包费:{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount.packFee || 0)
}}</span>
<span>优惠:{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsOriginalAmount -
goodsStore.cartInfo.costSummary.finalPayAmount) }}</span>
<span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
<span>商品原价:{{ goodsStore.cartInfo.costSummary.goodsRealAmount || 0 }}</span>
<span>餐位费:{{ formatDecimal(goodsStore.cartInfo.costSummary.seatFee || 0)
}}</span>
<span>打包费:{{ formatDecimal(goodsStore.cartInfo.costSummary.packFee || 0)
}}</span>
<span>优惠:{{ formatDecimal(goodsStore.cartInfo.costSummary.totalDiscountAmount || 0) }}</span>
<!-- <span v-if="goodsStore.cartInfo.costSummary.goodsDiscountAmount">
<span>折扣:{{ goodsStore.cartInfo.costSummary.goodsDiscountAmount }}</span>
</span>
</span> -->
</div>
</div>
</div>
@ -123,8 +122,9 @@
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px"
: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)}`"
@open="couponDialogOpen" @closed="resetCouponFormHandle" top="5vh" width="80%">
<el-dialog v-model="showCoupon"
: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="选择会员">
@ -284,7 +284,9 @@ const props = defineProps({
const discountAmount = ref(null)
watch(props, () => {
money.value = formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount)
if (goodsStore.cartInfo.costSummary) {
money.value = formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount)
}
// originOrderAmount.value = formatDecimal(props.amount - (goodsStore.tableInfo.tableFee || 0) -
// (goodsStore.cartInfo.packFee || 0))
})
@ -449,7 +451,7 @@ function upadatePayData() {
otherCouponDiscountAmount: goodsStore.cartInfo.costSummary.fullCouponDeduction, //
couponList: couponResList1.value.map(item => item.id), // 使
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount, //
roundAmount: goodsStore.cartInfo.costSummary.goodsDiscountAmount, //
roundAmount: 0, //
pointsDiscountAmount: goodsStore.cartInfo.costSummary.pointDeductionAmount, // (tb_points_basic_setting)
pointsNum: goodsStore.cartInfo.costSummary.pointUsed, // 使 ( enable_deduction使)
isPrint: 1
@ -564,29 +566,67 @@ function delHandle() {
payData.value.checkOrderPay.orderAmount = money.value;
}
/**
* 检查goodsStore.cartInfo.costSummary是否为真值的Promise
* @param {number} [interval=100] 轮询检查间隔(ms)
* @param {number} [timeout=5000] 超时时间(ms)超过则reject
* @returns {Promise} 当costSummary为真时resolve超时则reject
*/
function checkCostSummaryIsTruthy(interval = 100, timeout = 5000) {
return new Promise((resolve, reject) => {
//
const startTime = Date.now();
//
const check = () => {
const targetValue = goodsStore.cartInfo.costSummary;
// nullundefined0''falseNaN
if (targetValue) {
resolve(targetValue); //
return;
}
//
if (Date.now() - startTime >= timeout) {
reject(new Error('检查超时costSummary始终为假值'));
return;
}
//
setTimeout(check, interval);
};
//
check();
});
}
//
async function queryPayTypeAjax() {
try {
const res = await getPayType();
function queryPayTypeAjax() {
checkCostSummaryIsTruthy().then(async () => {
try {
const res = await getPayType();
res.map((item) => {
if (goodsStore.cartInfo.costSummary.finalPayAmount <= 0 && item.payType == "scanCode") {
item.disabled = true;
} else {
item.disabled = false;
}
});
res.map((item) => {
if (goodsStore.cartInfo.costSummary.finalPayAmount <= 0 && item.payType == "scanCode") {
item.disabled = true;
} else {
item.disabled = false;
}
});
payList.value = res.filter(item => item.isDisplay);
if (payList.value.length) {
if (payList.value[0].payType == "scanCode" && !payList.value[0].disabled) {
scanModalRef.value.show();
payType.value = payList.value[0].payType;
payList.value = res.filter(item => item.isDisplay);
if (payList.value.length) {
if (payList.value[0].payType == "scanCode" && !payList.value[0].disabled) {
scanModalRef.value.show();
payType.value = payList.value[0].payType;
}
}
} catch (error) {
console.log(error);
}
} catch (error) {
console.log(error);
}
})
}
/** 添加优惠 start */
@ -637,7 +677,7 @@ function clearCouponUser() {
updateCartCalc()
resetCouponFormHandle()
// resetCouponFormHandle()
}
//
@ -756,16 +796,16 @@ const calcPointMoney = async () => {
// dialog
function couponDialogOpen() {
couponResList2Amount.value = 0
couponForm.value.discountRatio = ''
// couponResList2Amount.value = 0
// couponForm.value.discountRatio = ''
//
couponForm.value.amount = formatDecimal(originOrderAmount.value - roundAmount.value)
couponForm.value.originAmount = couponForm.value.amount
resetCouponForm.value = { ...couponForm.value }
// //
// couponForm.value.amount = formatDecimal(originOrderAmount.value - roundAmount.value)
// couponForm.value.originAmount = couponForm.value.amount
// resetCouponForm.value = { ...couponForm.value }
couponResList1.value = []
couponResList2.value = []
// couponResList1.value = []
// couponResList2.value = []
//
if (goodsStore.vipUserInfo.id) {
@ -786,6 +826,10 @@ function couponDialogOpen() {
// dialog
function resetCouponFormHandle() {
couponForm.value = { ...resetCouponForm.value }
couponForm.value.pointsNum = ''
couponForm.value.discountRatio = ''
discountRateNumber.value = 0
// clearCouponUser()
cancelAllDiscount()
}
@ -1062,7 +1106,8 @@ async function payCardInit() {
}
defineExpose({
payCardInit
payCardInit,
resetCouponFormHandle
})
</script>

View File

@ -13,6 +13,18 @@ import { ElMessage } from "element-plus";
import yskUtils from "ysk-utils";
const initialCostSummary = {
finalPayAmount: 0,
goodsRealAmount: 0,
seatFee: 0,
packFee: 0,
totalDiscountAmount: 0,
productCouponDeduction: 0,
fullCouponDeduction: 0,
pointDeductionAmount: 0,
pointUsed: 0,
};
// 商品store + 购物车store
export const useGoods = defineStore("goods", {
state: () => ({
@ -44,7 +56,11 @@ export const useGoods = defineStore("goods", {
// tableFee: 0,
// },
// 购物车信息,
cartInfo: '',
cartInfo: {
costSummary: {
...initialCostSummary
}
},
goodsName: "", // 商品名称,
categoryIndex: useStorage.get("categoryIndex") || 0, // 商品分类索引,
categoryList: [], // 商品分类列表
@ -681,7 +697,9 @@ export const useGoods = defineStore("goods", {
// 清空购物车回执操作
async successClearCart() {
this.cartList = [];
this.cartInfo = {};
this.cartInfo = {
costSummary: { ...initialCostSummary }
};
this.orderList = [];
this.orderListInfo = "";
@ -914,6 +932,9 @@ export const useGoods = defineStore("goods", {
isEnabled: !store.shopInfo.isTableFee,
});
console.log('seatFeeConfig', seatFeeConfig.value);
//积分规则
const pointDeductionRule = ref({
pointsPerYuan: options.pointsPerYuan,

View File

@ -181,17 +181,15 @@ export function returnCouponCanUse(args) {
};
}
}
// 商品兑换券,第二件半价和买一送一判断是否有可用商品
if ([2, 4, 5].includes(coupon.type)) {
console.log("商品兑换券", fullAmount, coupon.fullAmount);
if (coupon.type == 2 && fullAmount < coupon.fullAmount) {
console.log("商品兑换券", coupon);
return {
canUse: false,
reason: `${coupon.fullAmount}元可用,当前可参与金额${fullAmount}`,
};
}
// 没有符合条件的商品
if (isDikouAll && canDikouGoodsArr.length === 0) {
return {
@ -219,8 +217,8 @@ export function returnCouponCanUse(args) {
let canUse = false;
if (isDikouAll) {
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
} else if (canCalcGoodsArr.length > 0) {
canUse = canCalcGoodsArr.some((v) => v.num >= 2);
} else if (canUseGoodsArr.length > 0) {
canUse = canUseGoodsArr.some((v) => v.num >= 2);
}
if (!canUse) {
@ -236,10 +234,9 @@ export function returnCouponCanUse(args) {
let canUse = false;
if (isDikouAll) {
canUse = canDikouGoodsArr.some((v) => v.num >= 2);
} else if (canCalcGoodsArr.length > 0) {
canUse = canCalcGoodsArr.some((v) => v.num >= 2);
} else if (canUseGoodsArr.length > 0) {
canUse = canUseGoodsArr.some((v) => v.num >= 2);
}
if (!canUse) {
return {
canUse: false,

View File

@ -252,6 +252,7 @@ function paySuccess() {
socket.cartInit()
goodsStore.successClearCart()
goodsStore.clearVipUserInfo()
payCardRef.value.resetCouponFormHandle()
}
const payCardRef = ref(null)
@ -294,6 +295,8 @@ function returnHandle() {
backendCoupons: [],
fixedAmount: ''
})
payCardRef.value.resetCouponFormHandle()
}
defineExpose({

View File

@ -128,7 +128,7 @@
<el-text class="t">外带</el-text>
</div>
<div class="left" v-else></div>
<div class="right">
<div class="right" v-if="goodsStore.cartInfo.costSummary">
<el-text>
{{ formatDecimal(goodsStore.cartInfo.costSummary.goodsTotal || 0, 2, true) }}
</el-text>{{ formatDecimal(goodsStore.cartInfo.costSummary.finalPayAmount || 0) }}