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",
|
"name": "vite-electron",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "2.0.8",
|
"version": "2.0.9",
|
||||||
"main": "dist-electron/main.js",
|
"main": "dist-electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "chcp 65001 && vite",
|
"dev": "chcp 65001 && vite",
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ export function findCoupon(params) {
|
|||||||
export function calcUsablePoints(params) {
|
export function calcUsablePoints(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "/account/admin/points/memberPoints/calcUsablePoints",
|
url: "/market/admin/points/userPoints",
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,7 @@
|
|||||||
<el-form-item label="积分抵扣">
|
<el-form-item label="积分抵扣">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<el-input v-model="couponForm.pointsNum"
|
<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"
|
:placeholder="pointOptions.usable ? '请输入需要抵扣的积分' : pointOptions.unusableReason"
|
||||||
v-loading="pointOptions.loading" @input="pointInput">
|
v-loading="pointOptions.loading" @input="pointInput">
|
||||||
<template #prepend>现有积分:{{ couponFormUser.accountPoints || 0 }}</template>
|
<template #prepend>现有积分:{{ couponFormUser.accountPoints || 0 }}</template>
|
||||||
@@ -252,7 +252,7 @@ import CouponModal from '@/components/payCard/couponModal.vue'
|
|||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { staffPermission } from "@/api/user.js";
|
import { staffPermission } from "@/api/user.js";
|
||||||
import { cashPay, buyerPage, creditPay, vipPay } from "@/api/order.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";
|
import { useGoods } from "@/store/goods.js";
|
||||||
|
|
||||||
const emit = defineEmits(["paySuccess", 'orderExpired', 'reset']);
|
const emit = defineEmits(["paySuccess", 'orderExpired', 'reset']);
|
||||||
@@ -651,13 +651,21 @@ const couponResList1 = ref([])
|
|||||||
const couponResList2 = ref([])
|
const couponResList2 = ref([])
|
||||||
|
|
||||||
const pointOptions = ref({
|
const pointOptions = ref({
|
||||||
min: 0,
|
// 新接口字段
|
||||||
max: 0,
|
enableRewards: 0, // 是否开启消费赠送积分(1 开启)
|
||||||
minPaymentAmount: 0,
|
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,
|
usable: true,
|
||||||
unusableReason: '',
|
unusableReason: '',
|
||||||
amount: 0,
|
amount: 0, // 抵扣金额(元)
|
||||||
equivalentPoints: '',
|
|
||||||
loading: false
|
loading: false
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -734,9 +742,15 @@ function cancelAllDiscount() {
|
|||||||
|
|
||||||
// 同意更新商品计算
|
// 同意更新商品计算
|
||||||
function updateCartCalc() {
|
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({
|
goodsStore.calcCartInfo({
|
||||||
pointsPerYuan: pointOptions.value.equivalentPoints,
|
pointsPerYuan: pointOptions.value.pointsPerYuan,
|
||||||
maxDeductionAmount: pointOptions.value.max,
|
maxDeductionAmount: maxDeductionAmount,
|
||||||
userPoints: couponForm.value.pointsNum,
|
userPoints: couponForm.value.pointsNum,
|
||||||
backendCoupons: couponResList1.value,
|
backendCoupons: couponResList1.value,
|
||||||
fixedAmount: discountRateNumber.value
|
fixedAmount: discountRateNumber.value
|
||||||
@@ -759,13 +773,26 @@ const pointInput = _.debounce(function (e) {
|
|||||||
couponForm.value.pointsNum = inputFilterInt(e)
|
couponForm.value.pointsNum = inputFilterInt(e)
|
||||||
console.log('inputFilterInt===', couponForm.value.pointsNum);
|
console.log('inputFilterInt===', couponForm.value.pointsNum);
|
||||||
|
|
||||||
// 若如果大于最大值
|
// 未登录用户或无可用积分时直接归0并返回
|
||||||
if (couponForm.value.pointsNum > pointOptions.value.max) {
|
const userAvailablePoints = Number(couponFormUser.value && couponFormUser.value.accountPoints ? couponFormUser.value.accountPoints : 0)
|
||||||
couponForm.value.pointsNum = pointOptions.value.max
|
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) {
|
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
|
pointOptions.value.loading = true
|
||||||
calcPointMoney()
|
calcPointMoney()
|
||||||
}
|
}
|
||||||
@@ -788,16 +815,33 @@ const pointInput = _.debounce(function (e) {
|
|||||||
}, 500)
|
}, 500)
|
||||||
|
|
||||||
|
|
||||||
// 根据积分计算可抵扣金额
|
// 根据积分计算可抵扣金额(前端计算,不依赖后端)
|
||||||
const calcPointMoney = async () => {
|
const calcPointMoney = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await calcDeductionAmount({
|
const pointsPerYuan = Number(pointOptions.value.pointsPerYuan || 0) // 积分数/元,例如 20 表示 20 积分 = 1 元
|
||||||
shopUserId: goodsStore.vipUserInfo.id,
|
const points = Number(couponForm.value.pointsNum || 0)
|
||||||
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount,
|
const orderAmount = Number(goodsStore.cartInfo.costSummary.finalPayAmount || 0)
|
||||||
points: couponForm.value.pointsNum
|
|
||||||
})
|
if (!pointsPerYuan || points <= 0) {
|
||||||
pointOptions.value.amount = formatDecimal(+res)
|
pointOptions.value.amount = 0
|
||||||
couponForm.value.amount = couponForm.value.amount - res
|
// 若未初始化 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()
|
updateCartCalc()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -833,6 +877,12 @@ function couponDialogOpen() {
|
|||||||
couponFormUserList.value = []
|
couponFormUserList.value = []
|
||||||
couponFormUser.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
|
// 关闭后初始化dialog
|
||||||
@@ -881,7 +931,7 @@ async function selectUserHandle(row) {
|
|||||||
pointOptionsAjax()
|
pointOptionsAjax()
|
||||||
|
|
||||||
// 已存在选择的用户,并且切换了不通用户
|
// 已存在选择的用户,并且切换了不通用户
|
||||||
if (couponFormUser.id && row.userId != couponFormUser.value.userId) {
|
if (couponFormUser.value && couponFormUser.value.id && row.userId != couponFormUser.value.userId) {
|
||||||
resetCoupon()
|
resetCoupon()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -906,17 +956,40 @@ function resetCoupon() {
|
|||||||
// 选择完用户后开始获取积分使用配置
|
// 选择完用户后开始获取积分使用配置
|
||||||
async function pointOptionsAjax() {
|
async function pointOptionsAjax() {
|
||||||
try {
|
try {
|
||||||
const res = await calcUsablePoints({
|
const { pointsConfig, pointsUser } = await calcUsablePoints({
|
||||||
shopUserId: goodsStore.vipUserInfo.id,
|
shopUserId: goodsStore.vipUserInfo.id,
|
||||||
orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount
|
// orderAmount: goodsStore.cartInfo.costSummary.finalPayAmount
|
||||||
})
|
})
|
||||||
|
|
||||||
pointOptions.value.min = res.minDeductionPoints // 最少使用积分
|
const res = pointsConfig || {}
|
||||||
pointOptions.value.max = res.maxUsablePoints // 最大使用积分
|
const userPoint = pointsUser
|
||||||
pointOptions.value.usable = res.usable // 是否可用
|
|
||||||
pointOptions.value.unusableReason = res.unusableReason // 不可用的原因
|
couponFormUser.value.accountPoints = userPoint.id ? userPoint.pointBalance : 0
|
||||||
pointOptions.value.minPaymentAmount = res.minPaymentAmount // 最少使用的金额
|
|
||||||
pointOptions.value.equivalentPoints = res.equivalentPoints
|
// 映射最新接口字段
|
||||||
|
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) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import lodopPrintWork from "@/components/lodop/lodopPrintWork.js";
|
|||||||
import invoicePrint from "@/components/lodop/invoicePrint.js";
|
import invoicePrint from "@/components/lodop/invoicePrint.js";
|
||||||
import refundPrint from "@/components/lodop/refundPrint.js";
|
import refundPrint from "@/components/lodop/refundPrint.js";
|
||||||
import { printerList } from "@/api/account.js";
|
import { printerList } from "@/api/account.js";
|
||||||
|
import { useSocket } from './socket.js';
|
||||||
|
|
||||||
export const usePrint = defineStore("print", {
|
export const usePrint = defineStore("print", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -174,6 +175,7 @@ export const usePrint = defineStore("print", {
|
|||||||
this.isPrintService
|
this.isPrintService
|
||||||
) {
|
) {
|
||||||
const store = useUser();
|
const store = useUser();
|
||||||
|
props.deviceId = this.deviceNoteList[0].id;
|
||||||
props.deviceName = this.deviceNoteList[0].address;
|
props.deviceName = this.deviceNoteList[0].address;
|
||||||
props.shop_name = store.shopInfo.shopName;
|
props.shop_name = store.shopInfo.shopName;
|
||||||
props.loginAccount = store.userInfo.name;
|
props.loginAccount = store.userInfo.name;
|
||||||
@@ -197,17 +199,36 @@ export const usePrint = defineStore("print", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 开始打印小票
|
// 开始打印小票
|
||||||
startReceiptPrint() {
|
async startReceiptPrint() {
|
||||||
if (this.receiptTimer !== null) return;
|
try {
|
||||||
this.receiptTimer = setInterval(() => {
|
const socketStore = useSocket();
|
||||||
if (!this.receiptList.length) {
|
const userStore = useUser();
|
||||||
clearInterval(this.receiptTimer);
|
|
||||||
this.receiptTimer = null;
|
if (this.receiptTimer !== null) return;
|
||||||
} else {
|
this.receiptTimer = setInterval(() => {
|
||||||
receiptPrint(this.receiptList[0]);
|
if (!this.receiptList.length) {
|
||||||
this.receiptList.splice(0, 1);
|
clearInterval(this.receiptTimer);
|
||||||
}
|
this.receiptTimer = null;
|
||||||
}, 2000);
|
} 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) {
|
printWork(data) {
|
||||||
|
|||||||
@@ -89,6 +89,11 @@
|
|||||||
用餐模式:{{ filterLable("dineMode", scope.row.dineMode) }}
|
用餐模式:{{ filterLable("dineMode", scope.row.dineMode) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="row">订单备注:{{ scope.row.remark }}</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@@ -286,6 +291,7 @@ async function orderListAjax() {
|
|||||||
const res = await orderList(queryForm.value);
|
const res = await orderList(queryForm.value);
|
||||||
res.records.map(item => {
|
res.records.map(item => {
|
||||||
item.payLoading = false
|
item.payLoading = false
|
||||||
|
item.printStatus = JSON.parse(item.printStatus || '[]')
|
||||||
})
|
})
|
||||||
tableData.list = [];
|
tableData.list = [];
|
||||||
tableData.list = res.records;
|
tableData.list = res.records;
|
||||||
@@ -293,6 +299,8 @@ async function orderListAjax() {
|
|||||||
|
|
||||||
tableRef.value.setScrollTop(0);
|
tableRef.value.setScrollTop(0);
|
||||||
tableRef.value.setScrollLeft(0);
|
tableRef.value.setScrollLeft(0);
|
||||||
|
|
||||||
|
console.log("订单列表:", res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,14 @@
|
|||||||
:key="item.id"></el-radio-button>
|
:key="item.id"></el-radio-button>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
<div class="btns">
|
<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="warning" @click="RecordRef.show()">叫号记录</el-button>
|
||||||
<el-button type="primary" @click="SettingRef.show()">基本设置</el-button>
|
<el-button type="primary" @click="SettingRef.show()">基本设置</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user