1.对接会员列表 2.对接排队叫号

This commit is contained in:
gyq
2025-03-06 19:28:01 +08:00
parent db3fc1f6dc
commit 5cf2355d28
29 changed files with 1920 additions and 1136 deletions

View File

@@ -1,19 +1,21 @@
<template>
<div class="card">
<div class="header">
<div class="t1">
<span class="title">应收:</span>
<span class="num">{{ money }}</span>
</div>
<div class="t2">
<span>原价{{ formatDecimal(props.amount) }}</span>
<span style="margin-left: 20px;">优惠{{ formatDecimal(props.amount - money) }}</span>
<span style="margin-left: 20px;" v-if="props.discount" @click="cancelDiscount">折扣{{
formatDecimal(props.discount * 10, 1, true) }}
<el-icon style="margin-left: 6px;">
<CircleClose />
</el-icon>
</span>
<div class="left">
<div class="t1">
<span class="title">应收:</span>
<span class="num">{{ money }}</span>
</div>
<div class="t2">
<span>原价{{ formatDecimal(props.amount) }}</span>
<span style="margin-left: 20px">优惠{{ formatDecimal(props.amount - money) }}</span>
<span style="margin-left: 20px" v-if="props.discount" @click="cancelDiscount">折扣{{
formatDecimal(props.discount * 10, 1, true) }}
<el-icon style="margin-left: 6px">
<CircleClose />
</el-icon>
</span>
</div>
</div>
</div>
<div class="number_wrap">
@@ -37,15 +39,18 @@
</div> -->
</div>
<div class="input_wrap">
<div class="input" style="flex: 1;">储值:{{ money }}</div>
<!-- <div class="input" v-if="waitPayMoney > 0">待支付:{{ waitPayMoney }}</div> -->
<div class="input" style="flex: 1">储值{{ money }}</div>
<el-button type="primary" style="width: 120px;border-radius: 6px; height: 60px;"
@click="showCouponHandle">添加优惠</el-button>
</div>
<div class="blance">
<!-- 可用余额0.00 -->
</div>
<div class="keybord_wrap">
<div class="left">
<div class="item" v-for="item in 9" :key="item" @click="amountInput(`${item}`)">{{ item }}</div>
<div class="item" v-for="item in 9" :key="item" @click="amountInput(`${item}`)">
{{ item }}
</div>
<div class="item" @click="amountInput('.')">.</div>
<div class="item" @click="amountInput('0')">0</div>
<div class="item" @click="delHandle">
@@ -90,7 +95,7 @@
</template>
</el-table-column>
</el-table>
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px;"
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px"
:total="Number(tableData.total)" v-model:current-page="tableData.page" @current-change="getMemberList" />
</el-dialog>
<!-- 选择挂账人员 -->
@@ -135,64 +140,84 @@
</template>
</el-table-column>
</el-table>
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px;"
<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="添加优惠">
<el-form ref="couponFormRef" :model="couponForm">
<el-form-item label="会员">
<el-select>
<el-option label="会员1" value="1"></el-option>
</el-select>
</el-form-item>
</el-form>
</el-dialog>
</template>
<script setup>
import { onMounted, ref, computed, watch, reactive } from 'vue'
import { queryPayType, accountPay, vipPay, buyerPage, payCreditPay } from '@/api/pay'
import { queryMembermember, createMembermember, membermemberScanPay, accountPaymember } from '@/api/member/index.js'
import { useUser } from "@/store/user.js"
import { clearNoNum, formatDecimal } from '@/utils'
import { onMounted, ref, computed, watch, reactive } from "vue";
import {
queryPayType,
accountPay,
vipPay,
buyerPage,
payCreditPay,
} from "@/api/pay";
import {
queryMembermember,
createMembermember,
membermemberScanPay,
accountPaymember,
} from "@/api/member/index.js";
import { useUser } from "@/store/user.js";
import { clearNoNum, formatDecimal } from "@/utils";
import { getPayType } from '@/api/account.js'
import { getPayType } from "@/api/account.js";
import scanModal from '@/components/payCard/scanModal.vue'
import scanModal from "@/components/payCard/scanModal.vue";
import { ElMessage } from "element-plus";
import { useGlobal } from '@/store/global.js'
import { staffPermission } from '@/api/user.js'
import { cashPay } from '@/api/order.js'
import { useGlobal } from "@/store/global.js";
import { staffPermission } from "@/api/user.js";
import { cashPay } from "@/api/order.js";
import { useGoods } from '@/store/goods.js'
import { useGoods } from "@/store/goods.js";
const goodsStore = useGoods()
const goodsStore = useGoods();
const global = useGlobal()
const global = useGlobal();
const store = useUser()
const store = useUser();
const props = defineProps({
amount: {
type: Number,
default: 0
default: 0,
},
selecttype: {
type: Number,
default: 0
default: 0,
},
orderId: {
type: [String, Number],
default: ''
default: "",
},
discount: {
type: [String, Number],
default: 0
}
})
default: 0,
},
});
const emit = defineEmits(['paySuccess', 'cancelDiscount'])
const emit = defineEmits(["paySuccess", "cancelDiscount"]);
const money = ref('0')
const scanModalRef = ref(null)
const money = ref("0");
const scanModalRef = ref(null);
watch(props, (value) => {
money.value = `${formatDecimal(props.amount)}`
money.value = `${formatDecimal(props.amount)}`;
if (props.discount > 0) {
money.value = `${formatDecimal(props.amount * props.discount)}`
money.value = `${formatDecimal(props.amount * props.discount)}`;
}
})
});
// const waitPayMoney = computed(() => {
// let num = JSON.stringify(props.amount - money.value)
@@ -200,54 +225,54 @@ watch(props, (value) => {
// return num
// })
const payActive = ref(0)
const payType = ref('')
const payList = ref([])
const payLoading = ref(false)
const payData = ref({})
const payActive = ref(0);
const payType = ref("");
const payList = ref([]);
const payLoading = ref(false);
const payData = ref({});
// 挂账人 start
const showBuyer = ref(false)
const showBuyer = ref(false);
const buyerTable = reactive({
keywords: '',
keywords: "",
loading: false,
page: 1,
size: 10,
total: 0,
list: []
})
list: [],
});
// 显示挂账人
function showBuyerHandle() {
showBuyer.value = true
getBuyerList()
showBuyer.value = true;
getBuyerList();
}
//
//
function resetBuyerTable() {
buyerTable.keywords = ''
buyerTable.page = 1
getBuyerList()
buyerTable.keywords = "";
buyerTable.page = 1;
getBuyerList();
}
// 获取挂账人列表
async function getBuyerList() {
try {
buyerTable.loading = true
buyerTable.loading = true;
const res = await buyerPage({
page: buyerTable.page,
size: buyerTable.size,
shopId: store.userInfo.shopId,
keywords: buyerTable.keywords,
status: 1,
responsiblePerson: '',
repaymentStatus: ''
})
buyerTable.loading = false
buyerTable.list = res.list
buyerTable.total = res.total
responsiblePerson: "",
repaymentStatus: "",
});
buyerTable.loading = false;
buyerTable.list = res.list;
buyerTable.total = res.total;
} catch (error) {
buyerTable.loading = false
buyerTable.loading = false;
console.log(error);
}
}
@@ -255,22 +280,23 @@ async function getBuyerList() {
// 选择挂账人支付
async function payCreditPayHandle(row) {
try {
payLoading.value = true
buyerTable.loading = true
payLoading.value = true;
buyerTable.loading = true;
const res = await payCreditPay({
creditBuyerId: row.id,
orderId: props.orderId,
payAmount: props.discount > 0 ? money.value : '',
discountAmount: props.discount > 0 ? formatDecimal(props.amount - money.value) : ''
})
showBuyer.value = false
payLoading.value = false
buyerTable.loading = false
ElMessage.success('支付成功')
emit('paySuccess')
payAmount: props.discount > 0 ? money.value : "",
discountAmount:
props.discount > 0 ? formatDecimal(props.amount - money.value) : "",
});
showBuyer.value = false;
payLoading.value = false;
buyerTable.loading = false;
ElMessage.success("支付成功");
emit("paySuccess");
} catch (error) {
buyerTable.loading = false
payLoading.value = false
buyerTable.loading = false;
payLoading.value = false;
console.log(error);
}
}
@@ -278,7 +304,7 @@ async function payCreditPayHandle(row) {
// 获得扫码值
function scanCodeSuccess() {
emit('paySuccess')
emit("paySuccess");
}
// 切换支付类型
@@ -286,21 +312,21 @@ async function payTypeChange(index, item) {
try {
// await staffPermission('yun_xu_shou_kuan')
// if (item.disabled) return
payActive.value = index
payType.value = item.payType
if (item.payType == 'scanCode') {
scanModalRef.value.show()
payActive.value = index;
payType.value = item.payType;
if (item.payType == "scanCode") {
scanModalRef.value.show();
}
if (item.payType == 'vipPay') {
showDialog.value = true
getMemberList()
if (item.payType == "vipPay") {
showDialog.value = true;
getMemberList();
}
if (item.payType == 'buyer') {
showBuyerHandle()
if (item.payType == "buyer") {
showBuyerHandle();
}
if (payActive.value != 'buyer') {
if (payList.value[payActive.value].payType == 'deposit') {
scanModalRef.value.show()
if (payActive.value != "buyer") {
if (payList.value[payActive.value].payType == "deposit") {
scanModalRef.value.show();
}
}
} catch (error) {
@@ -311,27 +337,27 @@ async function payTypeChange(index, item) {
// 结算支付
async function confirmOrder() {
try {
payLoading.value = true
payLoading.value = true;
// 暂时使用现金支付
payData.value.checkOrderPay.orderAmount = formatDecimal(+money.value)
payData.value.checkOrderPay.roundAmount = formatDecimal(props.amount - money.value)
payData.value.checkOrderPay.userId = goodsStore.vipUserInfo.userId ? goodsStore.vipUserInfo.userId : ''
payData.value.checkOrderPay.vipPrice = goodsStore.vipUserInfo.userId ? 1 : 0
await cashPay(payData.value)
payLoading.value = false
emit('paySuccess')
return
await staffPermission('yun_xu_shou_kuan')
if (payLoading.value) return
if (payActive.value == 'buyer') {
showBuyerHandle()
} else if (payList.value[payActive.value].payType == 'scanCode') {
scanModalRef.value.show()
payData.value.checkOrderPay.orderAmount = formatDecimal(+money.value);
payData.value.checkOrderPay.roundAmount = formatDecimal(props.amount - money.value);
payData.value.checkOrderPay.userId = goodsStore.vipUserInfo.userId ? goodsStore.vipUserInfo.userId : "";
payData.value.checkOrderPay.vipPrice = goodsStore.vipUserInfo.userId ? 1 : 0;
await cashPay(payData.value);
payLoading.value = false;
emit("paySuccess");
return;
await staffPermission("yun_xu_shou_kuan");
if (payLoading.value) return;
if (payActive.value == "buyer") {
showBuyerHandle();
} else if (payList.value[payActive.value].payType == "scanCode") {
scanModalRef.value.show();
} else {
// if (money.value < props.amount) return
payLoading.value = true
payLoading.value = true;
switch (payList.value[payActive.value].payType) {
case 'deposit'://储值卡
case "deposit": //储值卡
// if (props.selecttype == 1) {
// } else {
@@ -341,122 +367,125 @@ async function confirmOrder() {
await accountPay({
orderId: props.orderId,
memberId: global.orderMemberInfo.id,
memberAccount: ''
})
memberAccount: "",
});
} else {
payLoading.value = false
scanModalRef.value.show()
return
payLoading.value = false;
scanModalRef.value.show();
return;
}
break;
case 'cash'://现金
case "cash": //现金
if (props.selecttype == 1) {
await accountPaymember({
shopId: store.userInfo.shopId,
memberId: props.orderId,
amount: props.amount
})
amount: props.amount,
});
} else {
await cashPay({
orderId: props.orderId,
payAmount: props.discount > 0 ? money.value : '',
discountAmount: props.discount > 0 ? formatDecimal(props.amount - money.value) : ''
})
payAmount: props.discount > 0 ? money.value : "",
discountAmount:
props.discount > 0
? formatDecimal(props.amount - money.value)
: "",
});
}
break;
case 'vipPay':
case "vipPay":
// 会员支付
console.log('使用会员id支付');
payLoading.value = false
showDialog.value = true
return
console.log("使用会员id支付");
payLoading.value = false;
showDialog.value = true;
return;
break;
default:
break;
}
payLoading.value = false
ElMessage.success('支付成功')
emit('paySuccess')
payLoading.value = false;
ElMessage.success("支付成功");
emit("paySuccess");
}
} catch (error) {
console.log(error)
payLoading.value = false
scanModalRef.value.loading = false
console.log(error);
payLoading.value = false;
scanModalRef.value.loading = false;
}
}
// 输入
function amountInput(num) {
if (money.value + num <= props.amount) {
money.value = clearNoNum({ value: (money.value += num) })
money.value = clearNoNum({ value: (money.value += num) });
} else {
money.value = clearNoNum({ value: `${props.amount}` })
money.value = clearNoNum({ value: `${props.amount}` });
}
}
// 删除
function delHandle() {
if (!money.value) return
money.value = money.value.substring(0, money.value.length - 1)
if (!money.value) return;
money.value = money.value.substring(0, money.value.length - 1);
if (!money.value) {
money.value = '0'
money.value = "0";
}
}
// 获取支付方式
async function queryPayTypeAjax() {
try {
const res = await getPayType()
const res = await getPayType();
res.map(item => {
if (props.amount <= 0 && item.payType == 'scanCode') {
item.disabled = true
res.map((item) => {
if (props.amount <= 0 && item.payType == "scanCode") {
item.disabled = true;
} else {
item.disabled = false
item.disabled = false;
}
})
});
payList.value = res
if (res[0].payType == 'scanCode' && !res[0].disabled) {
scanModalRef.value.show()
payType.value = res[0].payType
payList.value = res;
if (res[0].payType == "scanCode" && !res[0].disabled) {
scanModalRef.value.show();
payType.value = res[0].payType;
}
} catch (error) {
console.log(error)
console.log(error);
}
}
const showDialog = ref(false)
const showDialog = ref(false);
const tableData = reactive({
phone: '',
phone: "",
loading: false,
list: [],
page: 1,
size: 10,
total: 0
})
total: 0,
});
// 重置表格
function resetTable() {
tableData.phone = ''
tableData.page = 1
getMemberList()
tableData.phone = "";
tableData.page = 1;
getMemberList();
}
// 获取会员列表
async function getMemberList() {
try {
tableData.loading = true
tableData.loading = true;
const res = await queryMembermember({
shopId: store.userInfo.shopId,
phone: tableData.phone,
page: tableData.page,
pageSize: tableData.size,
isFlag: 1
})
tableData.loading = false
tableData.list = res.list
tableData.total = res.total
isFlag: 1,
});
tableData.loading = false;
tableData.list = res.list;
tableData.total = res.total;
} catch (error) {
console.log(error);
}
@@ -465,57 +494,76 @@ async function getMemberList() {
// 选择会员去下单
async function toHomeMember(row) {
try {
showDialog.value = false
payLoading.value = true
showDialog.value = false;
payLoading.value = true;
const res = await vipPay({
orderId: props.orderId,
vipUserId: row.id,
payAmount: props.discount > 0 ? money.value : '',
discountAmount: props.discount > 0 ? formatDecimal(props.amount - money.value) : ''
})
global.setOrderTable()
global.setOrderMember()
payAmount: props.discount > 0 ? money.value : "",
discountAmount:
props.discount > 0 ? formatDecimal(props.amount - money.value) : "",
});
global.setOrderTable();
global.setOrderMember();
payLoading.value = false
ElMessage.success('支付成功')
emit('paySuccess')
payLoading.value = false;
ElMessage.success("支付成功");
emit("paySuccess");
} catch (error) {
payLoading.value = false
payLoading.value = false;
console.log(error);
}
}
// 取消折扣
function cancelDiscount() {
emit('cancelDiscount')
emit("cancelDiscount");
}
/** 添加优惠 start */
const showCoupon = ref(false)
const couponFormRef = ref(null)
const couponForm = ref({
userId: '',
discountRatio: '',
})
// 显示添加优惠
function showCouponHandle() {
showCoupon.value = true
}
/** 添加优惠 end */
onMounted(() => {
money.value = `${formatDecimal(props.amount)}`
money.value = `${formatDecimal(props.amount)}`;
payData.value = {
shopId: store.shopInfo.id,
buyerRemark: '', // 订单备注
buyerRemark: "", // 订单备注
checkOrderPay: {
orderId: goodsStore.orderListInfo.id,
vipPrice: 0, // 是否使用会员价
allPack: 0,// 是否整单打包
allPack: 0, // 是否整单打包
userId: goodsStore.vipUserInfo.id,
seatNum: goodsStore.tableInfo.num, // 用餐人数
originAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
discountAmount: 0, // 手动优惠金额
productCouponDiscountAmount: 0, // 商品优惠券抵扣金额
fullCouponDiscountAmount: 0, // 满减优惠券抵扣金额
couponList: [], // 用户使用的卡券
orderAmount: formatDecimal(+goodsStore.cartInfo.totalAmount - goodsStore.cartInfo.packFee), // 订单金额
roundAmount: 0, // 抹零金额 减免多少钱
pointsDiscountAmount: 0, // 积分抵扣金额(tb_points_basic_setting表)
pointsNum: 0 // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
}
}
queryPayTypeAjax()
})
seatNum: goodsStore.tableInfo.num, // 用餐人数
originAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
discountAmount: 0, // 手动优惠金额
productCouponDiscountAmount: 0, // 商品优惠券抵扣金额
fullCouponDiscountAmount: 0, // 满减优惠券抵扣金额
couponList: [], // 用户使用的卡券
orderAmount: formatDecimal(
+goodsStore.cartInfo.totalAmount - goodsStore.cartInfo.packFee
), // 订单金额
roundAmount: 0, // 抹零金额 减免多少钱
pointsDiscountAmount: 0, // 积分抵扣金额(tb_points_basic_setting表)
pointsNum: 0, // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
},
};
queryPayTypeAjax();
});
</script>
<style scoped lang="scss">
@@ -527,31 +575,36 @@ onMounted(() => {
.header {
padding-bottom: var(--el-font-size-base);
border-bottom: 1px solid #ececec;
display: flex;
.t1 {
display: flex;
color: var(--el-color-danger);
font-weight: bold;
.left {
flex: 1;
.title {
font-size: var(--el-font-size-base);
position: relative;
top: 14px;
}
.num {
font-size: 30px;
}
}
.t2 {
display: flex;
color: #999;
padding-top: 10px;
span {
.t1 {
display: flex;
align-items: center;
color: var(--el-color-danger);
font-weight: bold;
.title {
font-size: var(--el-font-size-base);
position: relative;
top: 14px;
}
.num {
font-size: 30px;
}
}
.t2 {
display: flex;
color: #999;
padding-top: 10px;
span {
display: flex;
align-items: center;
}
}
}
}
@@ -665,4 +718,4 @@ onMounted(() => {
font-size: calc(var(--el-font-size-base) + 10px);
}
}
</style>
</style>