增加支付检测是否锁定

This commit is contained in:
gyq
2025-05-10 09:13:13 +08:00
parent ca3b0eddbc
commit 4d939b2889
4 changed files with 74 additions and 9 deletions

View File

@@ -64,6 +64,8 @@ import { useGlobal } from '@/store/global.js'
import { formatDecimal } from '@/utils'
import { microPay, queryOrderStatus, microPayVip, vipPay, queryPayStatus } from '@/api/order.js'
import { ElMessage } from "element-plus";
import { useGoods } from "@/store/goods.js";
const goodsStore = useGoods();
const store = useUser();
const emits = defineEmits(["success", 'orderExpired']);
@@ -111,6 +113,7 @@ const userPayWait = ref(false);
const fastOrder = ref('')
const submitHandle = _.throttle(submitHandleAjax, 200);
const table_code = ref('')
// 提交扫码支付
async function submitHandleAjax() {
@@ -118,6 +121,12 @@ async function submitHandleAjax() {
try {
if (!scanCode.value || scanCode.value.length > 18) return;
loading.value = true;
// 判断订单是否锁定
await goodsStore.isOrderLock({
table_code: goodsStore.orderListInfo.tableCode
})
if (props.selecttype == 0) {
// 下单扫码支付
if (props.payType == 'scanCode') {
@@ -174,6 +183,11 @@ async function submitHandleAjax() {
} catch (error) {
console.log(error);
if (error.code === 211) {
// 开始锁单
goodsStore.isOrderLock({
table_code: table_code.value
}, 'pay_lock')
userPayWait.value = true;
fastOrder.value = error.data
autoCheckOrder()
@@ -213,6 +227,10 @@ const timer = ref(null)
function autoCheckOrder() {
closeStateTimerFuc()
timer.value = setInterval(() => {
// 开始锁单
goodsStore.isOrderLock({
table_code: table_code.value
}, 'pay_lock')
checkPayStauts(false)
}, 2000)
}
@@ -274,6 +292,11 @@ async function checkPayStauts(tips = true) {
// 扫码下单
const res = await queryOrderStatus({ orderId: props.payData.checkOrderPay.orderId });
if (res == "done") {
// 支付成功,解锁订单
await goodsStore.isOrderLock({
table_code: table_code.value
}, 'pay_unlock')
userPayWait.value = false
loading.value = false;
scanCode.value = "";
@@ -342,6 +365,7 @@ const inputChange = _.debounce(function (e) {
function show() {
dialogVisible.value = true;
table_code.value = goodsStore.orderListInfo.tableCode
setTimeout(() => {
inputRef.value.focus();
}, 500);
@@ -357,6 +381,11 @@ function reset() {
scanCode.value = "";
closeState.value = false
closeStateTime.value = 5
// 关闭锁单
goodsStore.isOrderLock({
table_code: table_code.value
}, 'pay_unlock')
}
defineExpose({