hookehuyr

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

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

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