Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ac9abe48e | |||
| 5e401a8650 | |||
| 6ff949d97a | |||
| 3b729eabcd | |||
| ecb5fc008b | |||
| cf2f61c240 |
File diff suppressed because one or more lines are too long
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "2.0.8",
|
||||
"version": "2.0.9",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
|
||||
@@ -367,7 +367,7 @@ export function findCoupon(params) {
|
||||
export function calcUsablePoints(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/account/admin/points/memberPoints/calcUsablePoints",
|
||||
url: "/market/admin/points/userPoints",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
<el-form-item label="积分抵扣">
|
||||
<div class="flex">
|
||||
<el-input v-model="couponForm.pointsNum"
|
||||
:disabled="!couponFormUser.id || !pointOptions.usable || goodsStore.cartInfo.costSummary.finalPayAmount < pointOptions.minPaymentAmount"
|
||||
:disabled="!couponFormUser.id || !pointOptions.usable || goodsStore.cartInfo.costSummary.finalPayAmount < pointOptions.minPaymentAmount || (couponFormUser.accountPoints || 0) < (pointOptions.minPoints || 0)"
|
||||
:placeholder="pointOptions.usable ? '请输入需要抵扣的积分' : pointOptions.unusableReason"
|
||||
v-loading="pointOptions.loading" @input="pointInput">
|
||||
<template #prepend>现有积分:{{ couponFormUser.accountPoints || 0 }}</template>
|
||||
@@ -252,7 +252,7 @@ import CouponModal from '@/components/payCard/couponModal.vue'
|
||||
import { ElMessage } from "element-plus";
|
||||
import { staffPermission } from "@/api/user.js";
|
||||
import { cashPay, buyerPage, creditPay, vipPay } from "@/api/order.js";
|
||||
import { calcUsablePoints, calcDeductionAmount } from '@/api/account.js'
|
||||
import { calcUsablePoints } from '@/api/account.js'
|
||||
import { useGoods } from "@/store/goods.js";
|
||||
|
||||
const emit = defineEmits(["paySuccess", 'orderExpired', 'reset']);
|
||||
@@ -651,13 +651,21 @@ const couponResList1 = ref([])
|
||||
const couponResList2 = ref([])
|
||||
|
||||
const pointOptions = ref({
|
||||
min: 0,
|
||||
max: 0,
|
||||
minPaymentAmount: 0,
|
||||
// 新接口字段
|
||||
enableRewards: 0, // 是否开启消费赠送积分(1 开启)
|
||||
consumeAmount: 0, // 每消费xx元赠送1积分
|
||||
minPaymentAmount: 0, // 下单实付抵扣门槛(元)
|
||||
maxDeductionRatio: 0, // 下单最高抵扣比例(如 0.2 表示最多抵扣 20%)
|
||||
equivalentPoints: 0, // 兼容字段:1元 = ? 积分(保留)
|
||||
pointsPerYuan: 0, // 积分数/元,例如 20 表示 20 积分 = 1 元
|
||||
enablePointsMall: 0, // 是否开启积分商城
|
||||
|
||||
// 派生字段(页面使用)
|
||||
minPoints: 0, // 最少使用积分(换算后)
|
||||
maxPoints: 0, // 最大可用积分(换算后)
|
||||
usable: true,
|
||||
unusableReason: '',
|
||||
amount: 0,
|
||||
equivalentPoints: '',
|
||||
amount: 0, // 抵扣金额(元)
|
||||
loading: false
|
||||
})
|
||||
|
||||
@@ -734,9 +742,15 @@ function cancelAllDiscount() {
|
||||
|
||||
// 同意更新商品计算
|
||||
function updateCartCalc() {
|
||||
// 计算最大抵扣金额(按订单金额 * 最大抵扣比例)
|
||||
const orderAmount = Number(goodsStore.cartInfo.costSummary.finalPayAmount || 0)
|
||||
const maxDeductionAmount = (pointOptions.value.maxDeductionRatio && pointOptions.value.pointsPerYuan)
|
||||
? orderAmount * pointOptions.value.maxDeductionRatio
|
||||
: 0
|
||||
|
||||
goodsStore.calcCartInfo({
|
||||
pointsPerYuan: pointOptions.value.equivalentPoints,
|
||||
maxDeductionAmount: pointOptions.value.max,
|
||||
pointsPerYuan: pointOptions.value.pointsPerYuan,
|
||||
maxDeductionAmount: maxDeductionAmount,
|
||||
userPoints: couponForm.value.pointsNum,
|
||||
backendCoupons: couponResList1.value,
|
||||
fixedAmount: discountRateNumber.value
|
||||
@@ -759,13 +773,26 @@ const pointInput = _.debounce(function (e) {
|
||||
couponForm.value.pointsNum = inputFilterInt(e)
|
||||
console.log('inputFilterInt===', couponForm.value.pointsNum);
|
||||
|
||||
// 若如果大于最大值
|
||||
if (couponForm.value.pointsNum > pointOptions.value.max) {
|
||||
couponForm.value.pointsNum = pointOptions.value.max
|
||||
// 未登录用户或无可用积分时直接归0并返回
|
||||
const userAvailablePoints = Number(couponFormUser.value && couponFormUser.value.accountPoints ? couponFormUser.value.accountPoints : 0)
|
||||
if (!couponFormUser.value || !couponFormUser.value.id || userAvailablePoints <= 0) {
|
||||
couponForm.value.pointsNum = 0
|
||||
pointOptions.value.amount = 0
|
||||
updateCartCalc()
|
||||
return
|
||||
}
|
||||
// 如果小于最大值
|
||||
if (couponForm.value.pointsNum < pointOptions.value.min) {
|
||||
couponForm.value.pointsNum = pointOptions.value.min
|
||||
|
||||
// 限制不得超过用户现有积分
|
||||
if (couponForm.value.pointsNum > userAvailablePoints) {
|
||||
couponForm.value.pointsNum = userAvailablePoints
|
||||
}
|
||||
|
||||
// 边界限制:不得超过最大/小于最小
|
||||
if (couponForm.value.pointsNum > pointOptions.value.maxPoints) {
|
||||
couponForm.value.pointsNum = pointOptions.value.maxPoints
|
||||
}
|
||||
if (couponForm.value.pointsNum < pointOptions.value.minPoints) {
|
||||
couponForm.value.pointsNum = pointOptions.value.minPoints
|
||||
}
|
||||
|
||||
if (!e) {
|
||||
@@ -779,7 +806,7 @@ const pointInput = _.debounce(function (e) {
|
||||
|
||||
|
||||
// 满足条件式开始计算抵扣金额,由后端返回
|
||||
if (couponForm.value.pointsNum >= pointOptions.value.min && couponForm.value.pointsNum <= pointOptions.value.max) {
|
||||
if (couponForm.value.pointsNum >= pointOptions.value.minPoints && couponForm.value.pointsNum <= pointOptions.value.maxPoints) {
|
||||
pointOptions.value.loading = true
|
||||
calcPointMoney()
|
||||
}
|
||||
@@ -788,16 +815,33 @@ const pointInput = _.debounce(function (e) {
|
||||
}, 500)
|
||||
|
||||
|
||||
// 根据积分计算可抵扣金额
|
||||
// 根据积分计算可抵扣金额(前端计算,不依赖后端)
|
||||
const calcPointMoney = async () => {
|
||||
try {
|
||||
const res = await calcDeductionAmount({
|
||||
shopUserId: goodsStore.vipUserInfo.id,
|
||||
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount,
|
||||
points: couponForm.value.pointsNum
|
||||
})
|
||||
pointOptions.value.amount = formatDecimal(+res)
|
||||
couponForm.value.amount = couponForm.value.amount - res
|
||||
const pointsPerYuan = Number(pointOptions.value.pointsPerYuan || 0) // 积分数/元,例如 20 表示 20 积分 = 1 元
|
||||
const points = Number(couponForm.value.pointsNum || 0)
|
||||
const orderAmount = Number(goodsStore.cartInfo.costSummary.finalPayAmount || 0)
|
||||
|
||||
if (!pointsPerYuan || points <= 0) {
|
||||
pointOptions.value.amount = 0
|
||||
// 若未初始化 couponForm.value.amount,则用订单原价
|
||||
couponForm.value.amount = couponForm.value.amount || originOrderAmount.value || orderAmount
|
||||
updateCartCalc()
|
||||
return
|
||||
}
|
||||
|
||||
// 积分可抵扣的金额(元) => 积分 / (积分数/元)
|
||||
let deductionFromPoints = points / pointsPerYuan
|
||||
|
||||
// 最大可抵扣金额基于订单金额和最大抵扣比例
|
||||
const maxDeductionAmount = orderAmount * (pointOptions.value.maxDeductionRatio || 0)
|
||||
|
||||
// 最终抵扣为积分抵扣金额与最大比例的较小者,且不超过订单可支付金额
|
||||
const baseAmount = Number(couponForm.value.amount || originOrderAmount.value || orderAmount)
|
||||
let deduction = Math.min(deductionFromPoints, maxDeductionAmount, baseAmount)
|
||||
|
||||
pointOptions.value.amount = formatDecimal(deduction)
|
||||
couponForm.value.amount = formatDecimal(baseAmount - deduction)
|
||||
|
||||
updateCartCalc()
|
||||
} catch (error) {
|
||||
@@ -833,6 +877,12 @@ function couponDialogOpen() {
|
||||
couponFormUserList.value = []
|
||||
couponFormUser.value = ''
|
||||
}
|
||||
|
||||
// 初始化优惠表单的金额基数:优先使用 originOrderAmount,其次使用购物车的最终支付金额
|
||||
const baseAmount = Number(originOrderAmount.value || 0) || Number(goodsStore.cartInfo.costSummary.finalPayAmount || 0)
|
||||
couponForm.value.originAmount = formatDecimal(baseAmount)
|
||||
couponForm.value.amount = formatDecimal(baseAmount - roundAmount.value)
|
||||
resetCouponForm.value = { ...couponForm.value }
|
||||
}
|
||||
|
||||
// 关闭后初始化dialog
|
||||
@@ -881,7 +931,7 @@ async function selectUserHandle(row) {
|
||||
pointOptionsAjax()
|
||||
|
||||
// 已存在选择的用户,并且切换了不通用户
|
||||
if (couponFormUser.id && row.userId != couponFormUser.value.userId) {
|
||||
if (couponFormUser.value && couponFormUser.value.id && row.userId != couponFormUser.value.userId) {
|
||||
resetCoupon()
|
||||
}
|
||||
} else {
|
||||
@@ -906,17 +956,40 @@ function resetCoupon() {
|
||||
// 选择完用户后开始获取积分使用配置
|
||||
async function pointOptionsAjax() {
|
||||
try {
|
||||
const res = await calcUsablePoints({
|
||||
const { pointsConfig, pointsUser } = await calcUsablePoints({
|
||||
shopUserId: goodsStore.vipUserInfo.id,
|
||||
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount
|
||||
// orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount
|
||||
})
|
||||
|
||||
pointOptions.value.min = res.minDeductionPoints // 最少使用积分
|
||||
pointOptions.value.max = res.maxUsablePoints // 最大使用积分
|
||||
pointOptions.value.usable = res.usable // 是否可用
|
||||
pointOptions.value.unusableReason = res.unusableReason // 不可用的原因
|
||||
pointOptions.value.minPaymentAmount = res.minPaymentAmount // 最少使用的金额
|
||||
pointOptions.value.equivalentPoints = res.equivalentPoints
|
||||
const res = pointsConfig || {}
|
||||
const userPoint = pointsUser
|
||||
|
||||
couponFormUser.value.accountPoints = userPoint.id ? userPoint.pointBalance : 0
|
||||
|
||||
// 映射最新接口字段
|
||||
pointOptions.value.enableRewards = Number(res.enableRewards || 0)
|
||||
pointOptions.value.consumeAmount = Number(res.consumeAmount || 0)
|
||||
pointOptions.value.minPaymentAmount = Number(res.minPaymentAmount || 0)
|
||||
pointOptions.value.maxDeductionRatio = Number(res.maxDeductionRatio || 0)
|
||||
pointOptions.value.equivalentPoints = Number(res.equivalentPoints || 0)
|
||||
pointOptions.value.enablePointsMall = Number(res.enablePointsMall || 0)
|
||||
|
||||
// 后端的 equivalentPoints 表示 积分数/元(例如 20 表示 20 积分 = 1 元)
|
||||
pointOptions.value.pointsPerYuan = pointOptions.value.equivalentPoints
|
||||
|
||||
// 计算页面需要的最小/最大可用积分(按接口返回的金额阈值与比例换算为积分)
|
||||
const pointsPerYuan = pointOptions.value.pointsPerYuan || 0
|
||||
const orderAmount = Number(goodsStore.cartInfo.costSummary.finalPayAmount || 0)
|
||||
|
||||
// 最少使用积分:基于最小抵扣金额换算(若无则为0),minPaymentAmount 单位为元
|
||||
pointOptions.value.minPoints = pointOptions.value.minPaymentAmount && pointsPerYuan ? Math.ceil(pointOptions.value.minPaymentAmount * pointsPerYuan) : 0
|
||||
|
||||
// 最大可用积分:基于订单金额与最大抵扣比例换算
|
||||
pointOptions.value.maxPoints = (pointOptions.value.maxDeductionRatio && pointsPerYuan) ? Math.floor(orderAmount * pointOptions.value.maxDeductionRatio * pointsPerYuan) : 0
|
||||
|
||||
// 可用性
|
||||
pointOptions.value.usable = pointOptions.value.enableRewards === 1 && pointOptions.value.maxPoints > 0
|
||||
pointOptions.value.unusableReason = pointOptions.value.usable ? '' : (pointOptions.value.enableRewards !== 1 ? '商家未开启积分抵扣' : '订单不可抵扣积分')
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import lodopPrintWork from "@/components/lodop/lodopPrintWork.js";
|
||||
import invoicePrint from "@/components/lodop/invoicePrint.js";
|
||||
import refundPrint from "@/components/lodop/refundPrint.js";
|
||||
import { printerList } from "@/api/account.js";
|
||||
import { useSocket } from './socket.js';
|
||||
|
||||
export const usePrint = defineStore("print", {
|
||||
state: () => ({
|
||||
@@ -174,6 +175,7 @@ export const usePrint = defineStore("print", {
|
||||
this.isPrintService
|
||||
) {
|
||||
const store = useUser();
|
||||
props.deviceId = this.deviceNoteList[0].id;
|
||||
props.deviceName = this.deviceNoteList[0].address;
|
||||
props.shop_name = store.shopInfo.shopName;
|
||||
props.loginAccount = store.userInfo.name;
|
||||
@@ -197,17 +199,36 @@ export const usePrint = defineStore("print", {
|
||||
}
|
||||
},
|
||||
// 开始打印小票
|
||||
startReceiptPrint() {
|
||||
if (this.receiptTimer !== null) return;
|
||||
this.receiptTimer = setInterval(() => {
|
||||
if (!this.receiptList.length) {
|
||||
clearInterval(this.receiptTimer);
|
||||
this.receiptTimer = null;
|
||||
} else {
|
||||
receiptPrint(this.receiptList[0]);
|
||||
this.receiptList.splice(0, 1);
|
||||
}
|
||||
}, 2000);
|
||||
async startReceiptPrint() {
|
||||
try {
|
||||
const socketStore = useSocket();
|
||||
const userStore = useUser();
|
||||
|
||||
if (this.receiptTimer !== null) return;
|
||||
this.receiptTimer = setInterval(() => {
|
||||
if (!this.receiptList.length) {
|
||||
clearInterval(this.receiptTimer);
|
||||
this.receiptTimer = null;
|
||||
} else {
|
||||
receiptPrint(this.receiptList[0]);
|
||||
// 在这里触发已打印操作标记
|
||||
const data = {
|
||||
type: "cashier",
|
||||
operate_type: "order_print_status",
|
||||
table_code: this.receiptList[0].orderInfo.tableCode,
|
||||
account: userStore.shopInfo.account,
|
||||
print_status: "1",
|
||||
order_id: this.receiptList[0].orderInfo.id,
|
||||
print_id: this.receiptList[0].deviceId,
|
||||
shop_id: this.receiptList[0].orderInfo.shopId,
|
||||
}
|
||||
socketStore.ws.send(JSON.stringify(data));
|
||||
this.receiptList.splice(0, 1);
|
||||
}
|
||||
}, 2000);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
// 打印交班小票
|
||||
printWork(data) {
|
||||
|
||||
@@ -89,6 +89,11 @@
|
||||
用餐模式:{{ filterLable("dineMode", scope.row.dineMode) }}
|
||||
</div>
|
||||
<div class="row">订单备注:{{ scope.row.remark }}</div>
|
||||
<div class="row">打印状态:
|
||||
<span v-if="scope.row.printStatus.length > 0" style="color: var(--el-color-danger)">
|
||||
打印失败({{scope.row.printStatus.map(item => item.name).join('、')}})
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -286,6 +291,7 @@ async function orderListAjax() {
|
||||
const res = await orderList(queryForm.value);
|
||||
res.records.map(item => {
|
||||
item.payLoading = false
|
||||
item.printStatus = JSON.parse(item.printStatus || '[]')
|
||||
})
|
||||
tableData.list = [];
|
||||
tableData.list = res.records;
|
||||
@@ -293,6 +299,8 @@ async function orderListAjax() {
|
||||
|
||||
tableRef.value.setScrollTop(0);
|
||||
tableRef.value.setScrollLeft(0);
|
||||
|
||||
console.log("订单列表:", res);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,14 @@
|
||||
:key="item.id"></el-radio-button>
|
||||
</el-radio-group>
|
||||
<div class="btns">
|
||||
<el-button type="danger" @click="GetNumberRef.show(tabHeader)">取号</el-button>
|
||||
<el-button type="danger" :disabled="!tabHeader.length" @click="GetNumberRef.show(tabHeader)">
|
||||
<template v-if="tabHeader.length">
|
||||
取号
|
||||
</template>
|
||||
<template v-else>
|
||||
请在基本设置添加桌型后取号
|
||||
</template>
|
||||
</el-button>
|
||||
<el-button type="warning" @click="RecordRef.show()">叫号记录</el-button>
|
||||
<el-button type="primary" @click="SettingRef.show()">基本设置</el-button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user