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