feat: 增加支付前订单状态和实际支付金额判断,避免不必要的微信支付。

This commit is contained in:
邹方成 2026-01-02 17:31:11 +08:00
parent 5cbd30fcb7
commit ed67c4f7fa
2 changed files with 39 additions and 29 deletions

View File

@ -289,6 +289,10 @@ async function onPaymentConfirm(paymentData) {
} }
// 2. 使 // 2. 使
// Check if order is already paid (e.g. via Game Pass or Points)
const isPaid = (joinRes?.status === 2) || (joinRes?.actual_amount <= 0)
if (!isPaid) {
const payRes = await createWechatOrder({ const payRes = await createWechatOrder({
openid: openid, openid: openid,
order_no: orderNo order_no: orderNo
@ -307,6 +311,7 @@ async function onPaymentConfirm(paymentData) {
fail: reject fail: reject
}) })
}) })
}
uni.hideLoading() uni.hideLoading()
uni.showLoading({ title: '查询结果...' }) uni.showLoading({ title: '查询结果...' })

View File

@ -378,6 +378,10 @@ async function onMachineDraw(count) {
const orderNo = joinRes?.order_no || joinRes?.data?.order_no || joinRes?.result?.order_no const orderNo = joinRes?.order_no || joinRes?.data?.order_no || joinRes?.result?.order_no
if (!orderNo) throw new Error('未获取到订单号') if (!orderNo) throw new Error('未获取到订单号')
// Check if order is already paid (e.g. via Game Pass or Points)
const isPaid = (joinRes?.status === 2) || (joinRes?.actual_amount <= 0)
if (!isPaid) {
const payRes = await createWechatOrder({ openid, order_no: orderNo }) const payRes = await createWechatOrder({ openid, order_no: orderNo })
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
uni.requestPayment({ uni.requestPayment({
@ -391,6 +395,7 @@ async function onMachineDraw(count) {
fail: reject fail: reject
}) })
}) })
}
// //
drawTotal.value = times drawTotal.value = times