对接订单打印小票

This commit is contained in:
gyq
2025-03-05 09:35:34 +08:00
parent 573dd88b24
commit db3fc1f6dc
22 changed files with 838 additions and 206 deletions

View File

@@ -17,7 +17,7 @@ export default (data) => {
let t1 = 40;
let t2 = (100 - t1) / 3;
let html = `
<div style="font-size: 30px;display:flex;justify-content:center;">
<div style="font-size: 22px;display:flex;justify-content:center;">
${data.shop_name}
</div>
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:6px;">
@@ -64,7 +64,7 @@ export default (data) => {
</tr>
`;
let proGroupInfo = JSON.parse(item.proGroupInfo);
let proGroupInfo = item.proGroupInfo;
for (let item of proGroupInfo) {
table += `
<tr>
@@ -110,14 +110,14 @@ export default (data) => {
</div>
<div style="margin-top: 6px; font-size: 12px;display:flex;justify-content: space-between;">
<span>折扣</span>
<span>-${formatDecimal(data.amount - data.discountAmount)}</span>
<span>-${data.discountAmount}</span>
</div>
<div style="margin-top: 6px;margin-bottom: 6px;width: 100%">
<hr/>
</div>
<div style="margin-top: 6px; font-size: 22px;display:flex;justify-content: space-between;">
<span>实付</span>
<span>¥${data.discountAmount}</span>
<span>¥${data.amount}</span>
</div>
<div style="margin-top: 6px;margin-bottom: 6px;width: 100%">
<hr/>

View File

@@ -299,7 +299,7 @@ async function payTypeChange(index, item) {
showBuyerHandle()
}
if (payActive.value != 'buyer') {
if (payList.value[payActive.value].payType == 'deposit' && !global.orderMemberInfo.id) {
if (payList.value[payActive.value].payType == 'deposit') {
scanModalRef.value.show()
}
}
@@ -313,11 +313,12 @@ async function confirmOrder() {
try {
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
ElMessage.success('支付成功')
goodsStore.successDeleteCartItem()
emit('paySuccess')
return
await staffPermission('yun_xu_shou_kuan')
@@ -491,27 +492,27 @@ function cancelDiscount() {
onMounted(() => {
money.value = `${formatDecimal(props.amount)}`
payData.value = {
shopId: store.shopInfo.id,
buyerRemark: '', // 订单备注
checkOrderPay: {
orderId: goodsStore.orderListInfo.id,
userId: '',
vipPrice: 0, // 是否使用会员价
allPack: 0,// 是否整单打包
userId: goodsStore.vipUserInfo.id,
seatNum: goodsStore.tableInfo.num, // 用餐人数
originAmount: goodsStore.orderListInfo.originAmount, // 订单原金额(包含打包费+餐位费) 不含折扣价格
originAmount: formatDecimal(+goodsStore.cartInfo.totalAmount), // 订单原金额(包含打包费+餐位费) 不含折扣价格
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
discountAmount: 0, // 手动优惠金额
productCouponDiscountAmount: 0, // 商品优惠券抵扣金额
fullCouponDiscountAmount: 0, // 满减优惠券抵扣金额
couponList: [], // 用户使用的卡券
orderAmount: goodsStore.orderListInfo.originAmount, // 订单金额
orderAmount: formatDecimal(+goodsStore.cartInfo.totalAmount - goodsStore.cartInfo.packFee), // 订单金额
roundAmount: 0, // 抹零金额 减免多少钱
pointsDiscountAmount: 0, // 积分抵扣金额(tb_points_basic_setting表)
pointsNum: 0 // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
}
}
queryPayTypeAjax()
})

View File

@@ -58,7 +58,7 @@ import { scanpay, queryOrder, quickPay, queryQuickPayStatus, accountPay, querySc
import { useUser } from "@/store/user.js";
import { useGlobal } from '@/store/global.js'
import { formatDecimal } from '@/utils'
import { microPay } from '@/api/order.js'
import { microPay, queryOrderStatus } from '@/api/order.js'
const store = useUser();
const global = useGlobal()
@@ -133,6 +133,7 @@ async function submitHandle() {
...props.payData,
authCode: scanCode.value
});
emits('success')
}
if (props.payType == 'deposit') {
await accountPay({
@@ -153,7 +154,7 @@ async function submitHandle() {
emits("success");
} catch (error) {
console.log(error);
if (error.code === "100015") {
if (error.code === 211) {
userPayWait.value = true;
fastOrder.value = error.data
autoCheckOrder()
@@ -178,8 +179,8 @@ function autoCheckOrder() {
function clearAutoCheckOrder() {
clearInterval(timer.value)
timer.value = null
// 开启叫号功能
global.updateData(true)
// // 开启叫号功能
// global.updateData(true)
}
// 查询用户支付状态
@@ -235,8 +236,8 @@ async function checkPayStauts(tips = true) {
}
} else {
// 扫码下单
const res = await queryOrder({ orderId: props.orderId });
if (res.status == "closed") {
const res = await queryOrderStatus({ orderId: props.payData.checkOrderPay.orderId });
if (res == "done") {
userPayWait.value = false
loading.value = false;
scanCode.value = "";
@@ -246,14 +247,14 @@ async function checkPayStauts(tips = true) {
emits("success");
return;
}
if (res.status == "paying") {
if (res == "unpaid") {
if (tips) {
ElMessage.warning("用户支付中...");
}
return;
} else {
clearAutoCheckOrder()
ElMessage.error(res.payRemark || "支付失败!");
ElMessage.error(res.msg);
return;
}
}

View File

@@ -34,7 +34,12 @@
<script setup>
import { ref, reactive } from 'vue'
import { shopUserList } from "@/api/account.js";
import { formatDecimal } from '@/utils/index.js'
import { useGoods } from '@/store/goods.js'
import { useUser } from '@/store/user.js'
const useStore = useUser()
const goodsStore = useGoods()
const showDialog = ref(false)
const tableData = reactive({
phone: '',
@@ -49,8 +54,11 @@ const tableData = reactive({
// 选择会员去下单
async function toHomeMember(row) {
try {
console.log(row);
// 选择会员后的操作
goodsStore.vipUserInfo = { ...row }
if (useStore.shopInfo.isMemberPrice) {
goodsStore.showVipPrice = true
goodsStore.calcCartInfo()
}
} catch (error) {
console.log(error);
}