hookehuyr

feat: 支付失败或取消时自动取消订单

- 在支付失败/取消时自动调用 icbcRefundAPI 取消订单
- 更新提示文案告知用户订单已自动取消
- 保证数据一致性,避免产生无效的待支付订单

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
7 */ 7 */
8 import Taro from '@tarojs/taro' 8 import Taro from '@tarojs/taro'
9 import { wxPayAPI } from '@/api/wx/pay' 9 import { wxPayAPI } from '@/api/wx/pay'
10 +import { icbcRefundAPI } from '@/api/index'
10 import { ENABLE_REPAY_FEATURE } from '@/utils/config' 11 import { ENABLE_REPAY_FEATURE } from '@/utils/config'
11 12
12 /** 13 /**
...@@ -66,6 +67,20 @@ export const wechat_pay = async ({ pay_id }) => { ...@@ -66,6 +67,20 @@ export const wechat_pay = async ({ pay_id }) => {
66 67
67 // 如果重新支付功能关闭,直接提示并返回上一页 68 // 如果重新支付功能关闭,直接提示并返回上一页
68 if (!ENABLE_REPAY_FEATURE && showConfirmAndBack) { 69 if (!ENABLE_REPAY_FEATURE && showConfirmAndBack) {
70 + // 自动取消订单
71 + Taro.showLoading({ title: '取消订单中...' })
72 + try {
73 + const { code } = await icbcRefundAPI({ pay_id: normalized_pay_id })
74 + Taro.hideLoading()
75 + if (code) {
76 + // 取消成功,更新提示文案
77 + friendlyMsg = `${friendlyMsg},订单已自动取消`
78 + }
79 + } catch (e) {
80 + Taro.hideLoading()
81 + console.error('取消订单失败:', e)
82 + }
83 +
69 await Taro.showModal({ 84 await Taro.showModal({
70 title: friendlyMsg, 85 title: friendlyMsg,
71 content: '订单未完成支付,如有需要请重新预约', 86 content: '订单未完成支付,如有需要请重新预约',
......