feat: 增加支付前订单状态和实际支付金额判断,避免不必要的微信支付。
This commit is contained in:
parent
5cbd30fcb7
commit
ed67c4f7fa
@ -289,24 +289,29 @@ async function onPaymentConfirm(paymentData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. 使用返回的订单号去发起支付
|
// 2. 使用返回的订单号去发起支付
|
||||||
const payRes = await createWechatOrder({
|
// Check if order is already paid (e.g. via Game Pass or Points)
|
||||||
openid: openid,
|
const isPaid = (joinRes?.status === 2) || (joinRes?.actual_amount <= 0)
|
||||||
order_no: orderNo
|
|
||||||
})
|
|
||||||
|
|
||||||
// 调起微信支付
|
if (!isPaid) {
|
||||||
await new Promise((resolve, reject) => {
|
const payRes = await createWechatOrder({
|
||||||
uni.requestPayment({
|
openid: openid,
|
||||||
provider: 'wxpay',
|
order_no: orderNo
|
||||||
timeStamp: payRes.timeStamp || payRes.timestamp,
|
})
|
||||||
nonceStr: payRes.nonceStr || payRes.noncestr,
|
|
||||||
package: payRes.package,
|
// 调起微信支付
|
||||||
signType: payRes.signType || 'MD5',
|
await new Promise((resolve, reject) => {
|
||||||
paySign: payRes.paySign,
|
uni.requestPayment({
|
||||||
success: resolve,
|
provider: 'wxpay',
|
||||||
fail: reject
|
timeStamp: payRes.timeStamp || payRes.timestamp,
|
||||||
})
|
nonceStr: payRes.nonceStr || payRes.noncestr,
|
||||||
})
|
package: payRes.package,
|
||||||
|
signType: payRes.signType || 'MD5',
|
||||||
|
paySign: payRes.paySign,
|
||||||
|
success: resolve,
|
||||||
|
fail: reject
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
uni.showLoading({ title: '查询结果...' })
|
uni.showLoading({ title: '查询结果...' })
|
||||||
|
|||||||
@ -378,19 +378,24 @@ 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('未获取到订单号')
|
||||||
|
|
||||||
const payRes = await createWechatOrder({ openid, order_no: orderNo })
|
// Check if order is already paid (e.g. via Game Pass or Points)
|
||||||
await new Promise((resolve, reject) => {
|
const isPaid = (joinRes?.status === 2) || (joinRes?.actual_amount <= 0)
|
||||||
uni.requestPayment({
|
|
||||||
provider: 'wxpay',
|
if (!isPaid) {
|
||||||
timeStamp: payRes.timeStamp || payRes.timestamp,
|
const payRes = await createWechatOrder({ openid, order_no: orderNo })
|
||||||
nonceStr: payRes.nonceStr || payRes.noncestr,
|
await new Promise((resolve, reject) => {
|
||||||
package: payRes.package,
|
uni.requestPayment({
|
||||||
signType: payRes.signType || 'MD5',
|
provider: 'wxpay',
|
||||||
paySign: payRes.paySign,
|
timeStamp: payRes.timeStamp || payRes.timestamp,
|
||||||
success: resolve,
|
nonceStr: payRes.nonceStr || payRes.noncestr,
|
||||||
fail: reject
|
package: payRes.package,
|
||||||
|
signType: payRes.signType || 'MD5',
|
||||||
|
paySign: payRes.paySign,
|
||||||
|
success: resolve,
|
||||||
|
fail: reject
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
// 支付成功后立即显示开奖加载弹窗
|
// 支付成功后立即显示开奖加载弹窗
|
||||||
drawTotal.value = times
|
drawTotal.value = times
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user