优化会员支付,已会员价结算

This commit is contained in:
gyq 2025-03-19 18:29:46 +08:00
parent a101cc4fb7
commit 87e8976353
11 changed files with 177 additions and 70 deletions

View File

@ -187,7 +187,7 @@ export function callTableConfigPut(data) {
*/
export function addCallTable(data) {
return request({
method: "post",
method: data.id ? "put" : "post",
url: "/account/admin/callTable",
data,
});

View File

@ -358,12 +358,23 @@ async function vipPayAjax(row) {
return
}
goodsStore.showVipPrice = 1
goodsStore.vipUserInfo = row
goodsStore.calcCartInfo()
reset()
payData.value.payType = 'userPay'
payData.value.shopUserId = row.id
payData.value.checkOrderPay.userId = row.userId
payLoading.value = true;
await vipPay(payData.value)
goodsStore.showVipPrice = 0
goodsStore.vipUserInfo = ''
emit("paySuccess");
} catch (error) {
console.log(error);
@ -392,12 +403,12 @@ async function payTypeChange(index, item) {
//
showBuyerHandle();
}
if(item.payType == 'deposit'){
if (item.payType == 'deposit') {
scanModalRef.value.show();
}
// if (payActive.value != "buyer") {
// if (payList.value[payActive.value].payType == "deposit") {
// }
// }
} catch (error) {
@ -820,7 +831,7 @@ function reset() {
orderId: goodsStore.orderListInfo.id,
vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 使
allPack: goodsStore.allSelected, //
userId: goodsStore.vipUserInfo.id,
userId: goodsStore.vipUserInfo.userId,
seatNum: goodsStore.tableInfo.num, //
originAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // +
discountRatio: '', // ( )

View File

@ -103,7 +103,7 @@ const beforeUpload = (file) => {
return true;
};
function init(arr) {
function init(arr = []) {
fileList.value = arr
}

View File

@ -24,23 +24,25 @@ export const usePrint = defineStore("print", {
// 获取本地打印机
ipcRenderer.send("getPrintList");
ipcRenderer.on("printList", (event, arg) => {
// localPrintList.value = arg;
// console.log(localPrintList.value);
this.localDevices = arg;
});
// 获取已添加的打印机
const res = await printerList();
this.deviceNoteList = res.records.filter(
(item) => item.status && item.subType == "cash"
);
this.deviceLableList = res.records.filter(
(item) => item.status && item.subType == "label"
);
console.log("打印队列初始化成功", {
deviceNoteList: this.deviceNoteList,
deviceLableList: this.deviceLableList,
});
try {
// 获取已添加的打印机
const res = await printerList();
this.deviceNoteList = res.records.filter(
(item) => item.status && item.subType == "cash"
);
this.deviceLableList = res.records.filter(
(item) => item.status && item.subType == "label"
);
console.log("打印队列初始化成功", {
deviceNoteList: this.deviceNoteList,
deviceLableList: this.deviceLableList,
});
} catch (error) {
console.error("获取已添加的打印机列表失败", error);
}
},
// 检查本地打印机是否能正常使用
checkLocalPrint(address) {

View File

@ -18,10 +18,7 @@
</div>
<div class="btm">
<span class="p">服务员{{ store.userInfo.name || "暂无" }}</span>
<!-- <span class="t">{{
props.orderInfo.createdAt &&
dayjs(props.orderInfo.createdAt).format("MM-DD HH:mm")
}}</span> -->
<span class="t">{{ dayjs().format("M月D日 HH:mm") }}</span>
</div>
</div>
</div>
@ -88,7 +85,7 @@ import payCard from "@/components/payCard/payCard.vue";
import SettleItem from './settleItem.vue'
import { print } from "@/api/pay";
import { shopStaffInfo } from '@/api/account.js'
import { ElMessage } from "element-plus";
import { dayjs, ElMessage } from "element-plus";
import { formatPhoneNumber, getOrderByIdAjax, commOrderPrintData } from '@/utils/index.js'
import useStorage from '@/utils/useStorage.js'
import { useGlobal } from '@/store/global.js'
@ -136,7 +133,6 @@ const props = defineProps({
}
});
const cartList = ref([])
const orderList = ref([])
const isPrint = ref(1);
const discountLoading = ref(false)
@ -196,19 +192,24 @@ const printHandle = _.throttle(async function () {
//
async function printOrderLable(isBefore = false) {
try {
if (printStore.deviceNoteList.length) {
// 使
const data = await getOrderByIdAjax(goodsStore.orderListInfo.id);
let orderId = goodsStore.orderListInfo.id
const data = await getOrderByIdAjax(orderId);
if (printStore.deviceLableList.length) {
if (!isBefore) {
//
printStore.labelPrint(commOrderPrintData(data))
}
}
if (printStore.deviceNoteList.length) {
// 使
printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore }));
} else {
// 使
await orderPrint({
type: isBefore ? 1 : 0,
id: goodsStore.orderListInfo.id,
id: orderId,
});
printLoading.value = false;
ElMessage.success(`云打印${isBefore ? '预' : ''}结算单成功`);
@ -220,10 +221,10 @@ async function printOrderLable(isBefore = false) {
//
function paySuccess() {
if (isPrint.value) printOrderLable()
emits('success')
dialogVisible.value = false;
ElMessage.success('支付成功')
if (isPrint.value) printOrderLable()
useStorage.del('tableCode')
socket.cartInit()
goodsStore.successClearCart()
@ -237,9 +238,6 @@ function show(t) {
console.log(cartInfo.value);
orderList.value = [...goodsStore.cartList, ...goodsStore.orderList.map(item => item.goods).flat()]
console.log('orderList===', orderList.value);
// paycard
setTimeout(() => {
payCardRef.value.reset()
@ -304,11 +302,12 @@ defineExpose({
$padding: 10px;
.master_id {
height: 77px;
font-size: calc(var(--el-font-size-base) + 10px);
border-bottom: 1px solid #ececec;
padding: $padding 0;
display: flex;
align-items: center;
flex-direction: column;
justify-content: space-between;
.member_info {
@ -336,7 +335,7 @@ defineExpose({
.list_wrap {
padding: 0 var(--el-font-size-base);
height: calc(100vh - 200px);
height: calc(100vh - 222px);
overflow-y: auto;
}

View File

@ -139,6 +139,10 @@ function resetHandle() {
function show() {
showDialog.value = true
setTimeout(() => {
UploadImgRef.value.init()
}, 50)
}
defineExpose({

View File

@ -1,5 +1,5 @@
<template>
<el-dialog v-model="visableDialog" title="余额明细" top="10vh" width="500" @closed="closeHandle">
<el-dialog v-model="visableDialog" title="余额明细" top="10vh" width="550" @closed="closeHandle">
<div class="box">
<div class="box1" v-loading="tableData.loading">
<div class="dialog_footer" v-for="(item, index) in tableData.list" :key="index">
@ -29,7 +29,7 @@
</div>
<div class="page_wrap">
<el-pagination v-model:current-page="tableData.page" background layout="prev, pager, next, total"
:total="tableData.total" @current-change="memberqueryMemberAccountAjax" />
:total="tableData.total" :pager-count="5" @current-change="memberqueryMemberAccountAjax" />
</div>
<el-dialog v-model="showDialog" top="1vh" title="会员充值退款">
<el-form ref="formRef" :model="form" :rules="rules" label-width="100">
@ -205,7 +205,13 @@ async function showRefundHandle(item) {
})
refundItem.value = res
if (res.amount - res.giftAmount - res.giftRefundAmount >= (res.inAmount - res.inRefundAmount)) {
if (res.amount - (res.giftAmount - res.giftRefundAmount) - (res.inAmount - res.inRefundAmount) <= 0) {
ElMessage.error('剩余可退款金额不足')
form.amount = 0
return
}
if (res.amount - (res.giftAmount - res.giftRefundAmount) >= (res.inAmount - res.inRefundAmount)) {
form.amount = formatDecimal(res.inAmount - res.inRefundAmount, 2, true)
} else {
form.amount = formatDecimal(res.amount - res.giftAmount - res.giftRefundAmount, 2, true)

View File

@ -48,7 +48,6 @@
<el-table-column label="钱包余额" prop="amount" width="150"></el-table-column>
<el-table-column label="消费累计" prop="consumeAmount" width="150"></el-table-column>
<el-table-column label="消费次数累计" prop="consumeCount" width="150"></el-table-column>
<el-table-column label="消费次数累计" prop="consumeCount" width="150"></el-table-column>
</el-table>
</div>
<div class="pagination">

View File

@ -127,6 +127,8 @@
</div>
</template>
</el-drawer>
<takeFoodCode ref="takeFoodCodeRef" title="退款密码" :type="2" input-type="password" placeholder="请输入退款密码"
@success="passwordSuccess" />
</template>
<script setup>
@ -139,6 +141,7 @@ import { ElMessageBox, ElMessage } from 'element-plus'
import { usePrint } from "@/store/print.js";
import { useUser } from '@/store/user.js'
import dayjs from 'dayjs'
import takeFoodCode from "@/components/takeFoodCode.vue";
const emits = defineEmits(['success'])
@ -161,13 +164,53 @@ const remarkTagList = ref([
'打包费'
])
const loading = ref(false)
const takeFoodCodeRef = ref(null)
const cash = ref(false)
// 退
async function passwordSuccess(e = '') {
try {
loading.value = true
let rows = tableRef.value.getSelectionRows()
let refundDetails = []
if (refundType.value != 1) {
refundDetails = tableRef.value.getSelectionRows().map(val => {
return {
id: val.id,
returnAmount: val.payAmount,
num: val.refund_number
}
})
}
let data = {
orderId: item.value.id,
refundAmount: formatDecimal(+refundAmount.value),
modify: modify.value,
cash: cash.value,
refundReason: remark.value,
refundDetails: refundDetails,
pwd: e,
};
await refundOrder(data)
ElMessage.success('退款成功')
await printRefund(rows)
isShow.value = false
emits('success')
} catch (error) {
console.log(error);
}
loading.value = false
}
// 退
function handleRefund() {
ElMessageBox.confirm('请线下手动转账给客户或现金,一旦操作完成无法修改订单状态,请慎重操作!', '注意', {
confirmButtonText: '已在线下完成退款'
}).then(() => {
refundHandle(true)
cash.value = true
refundHandle()
}).catch(() => { })
}
@ -192,37 +235,18 @@ async function refundHandle(cash = false) {
return
}
let refundDetails = []
if (refundType.value != 1) {
refundDetails = tableRef.value.getSelectionRows().map(val => {
return {
id: val.id,
returnAmount: val.payAmount,
num: val.refund_number
}
})
}
if (refundAmount.value <= 0) {
ElMessage.error('无可退金额')
return
}
let data = {
orderId: item.value.id,
refundAmount: formatDecimal(+refundAmount.value),
modify: modify.value,
cash: cash,
refundReason: remark.value,
refundDetails: refundDetails
};
loading.value = true
await refundOrder(data)
ElMessage.success('退款成功')
await printRefund(rows)
isShow.value = false
emits('success')
await store.getShopInfo()
if (store.shopInfo.isReturnPwd == 1) {
takeFoodCodeRef.value.show();
} else {
passwordSuccess()
}
} catch (error) {
console.log(error);
}
@ -300,6 +324,7 @@ function resetDrawer() {
refundAmount.value = ''
refundType.value = 1
remark.value = ''
cash.value = false
}
function show(row) {

View File

@ -16,16 +16,38 @@
</div>
<div class="table_wrap">
<div class="table">
<el-table :data="tableData.list" v-loading="tableData.loading" border strip height="100%">
<el-table ref="tableRef" :data="tableData.list" v-loading="tableData.loading" border strip height="100%">
<el-table-column label="台桌" prop="tableName" align="center">
<template v-slot="scope">
<span v-if="scope.row.tableName">{{ scope.row.tableName }}</span>
<span v-else></span>
</template>
</el-table-column>
<el-table-column label="商品信息" width="150">
<el-table-column label="商品信息" width="250">
<template v-slot="scope">
{{ goodsNameFilter(scope.row.goods) }}
<div class="goods_wrap">
<div class="row" v-for="item in scope.row.goods" :key="item.id">
<div class="cover">
<el-image :src="item.productImg" style="width: 40px;height: 40px;"></el-image>
</div>
<div class="info">
<div class="name">
<span>{{ item.productName }}</span>
<span class="amount">{{ formatDecimal(+item.payAmount) }}</span>
</div>
<div class="num">
<span>{{ formatDecimal(+item.unitPrice) }}</span>
<span>x{{ item.num }}</span>
</div>
<div class="num" v-if="item.returnNum">
<span>退菜数量{{ item.returnNum }}</span>
</div>
<div class="num" v-if="item.refundNum">
<span>退单数量{{ item.refundNum }}</span>
</div>
</div>
</div>
</div>
</template>
</el-table-column>
<el-table-column label="状态" width="100">
@ -132,6 +154,7 @@ import { onMounted, ref, reactive } from "vue";
import { orderList } from "@/api/order.js";
import { useGlobal } from "@/store/global.js";
import { useGoods } from '@/store/goods.js'
import { formatDecimal } from '@/utils/index.js'
import DateRange from "./components/dateRange.vue";
import RefundDrawer from "./components/refundDrawer.vue";
import PrintDrawer from "./components/printDrawer.vue";
@ -141,6 +164,7 @@ const RefundDrawerRef = ref(null);
const PrintDrawerRef = ref(null);
const DateRangeRef = ref(null);
const SettleAccountRef = ref(null)
const tableRef = ref(null);
const goodsStore = useGoods()
const globalStore = useGlobal();
@ -236,6 +260,7 @@ async function orderDoneHandle(row) {
//
async function orderListAjax() {
try {
tableData.loading = true;
const res = await orderList(queryForm.value);
res.records.map(item => {
@ -244,6 +269,9 @@ async function orderListAjax() {
tableData.list = [];
tableData.list = res.records;
tableData.total = +res.totalRow;
tableRef.value.setScrollTop(0);
tableRef.value.setScrollLeft(0);
} catch (error) {
console.log(error);
}
@ -313,4 +341,37 @@ onMounted(() => {
justify-content: flex-end;
padding-top: var(--el-font-size-base);
}
.goods_wrap {
.row {
display: flex;
padding: 10px 0;
&:not(:last-child) {
border-bottom: 1px solid #ececec;
}
.info {
padding-left: 10px;
.name {
width: 160px;
display: flex;
gap: 10px;
justify-content: space-between;
.amount {
color: var(--el-color-danger);
}
}
.num {
color: #999;
font-size: 14px;
display: flex;
gap: 10px;
}
}
}
}
</style>

View File

@ -63,7 +63,7 @@ const addTabForm = ref({
start: '',
isPostpone: 0,
postponeNum: 1, //
nearNum: ''
nearNum: 1
})
const addTabFormRules = ref({
@ -113,7 +113,7 @@ function addTabConfirmHandle() {
if (addTabForm.value.id) {
addTabForm.value.callTableId = addTabForm.value.id
}
const res = await addCallTable(addTabForm.value)
await addCallTable(addTabForm.value)
addTabFormLoading.value = false
showAddTable.value = false
ElMessage.success(addTabForm.value.id ? '编辑成功' : '添加成功')