This commit is contained in:
@@ -742,11 +742,19 @@ class OrderViewSet(viewsets.ModelViewSet):
|
||||
else:
|
||||
description = f"支付订单 {order.id}"
|
||||
|
||||
# 强制修正回调地址为正确的后端接口地址
|
||||
# 用户配置可能是 /pay (前端页面),我们需要的是 /api/finish/ (后端回调接口)
|
||||
current_notify = wechat_config.notify_url
|
||||
if 'quant-speed.com' in current_notify:
|
||||
notify_url = "https://market.quant-speed.com/api/finish/"
|
||||
else:
|
||||
notify_url = current_notify # Fallback
|
||||
|
||||
print(f"准备发起微信支付(小程序):")
|
||||
print(f" OutTradeNo: {out_trade_no}")
|
||||
print(f" Amount: {amount_in_cents} 分")
|
||||
print(f" OpenID: {user.openid}")
|
||||
print(f" NotifyURL: {wechat_config.notify_url}")
|
||||
print(f" NotifyURL: {notify_url}")
|
||||
|
||||
# 统一下单 (JSAPI)
|
||||
code, message = wxpay.pay(
|
||||
@@ -754,7 +762,7 @@ class OrderViewSet(viewsets.ModelViewSet):
|
||||
out_trade_no=out_trade_no,
|
||||
amount={'total': amount_in_cents, 'currency': 'CNY'},
|
||||
payer={'openid': user.openid}, # 小程序支付必须传 openid
|
||||
notify_url=wechat_config.notify_url
|
||||
notify_url=notify_url
|
||||
)
|
||||
|
||||
print(f"微信支付响应: Code={code}, Message={message}")
|
||||
|
||||
@@ -9,6 +9,7 @@ export const createOrder = (data: any) => request({ url: '/orders/', method: 'PO
|
||||
export const getOrder = (id: number) => request({ url: `/orders/${id}/` })
|
||||
export const getMyOrders = () => request({ url: '/orders/' })
|
||||
export const prepayMiniprogram = (orderId: number) => request({ url: `/orders/${orderId}/prepay_miniprogram/`, method: 'POST' })
|
||||
export const queryOrderStatus = (orderId: number) => request({ url: `/orders/${orderId}/query_status/` })
|
||||
|
||||
// AI Services
|
||||
export const getServices = () => request({ url: '/services/' })
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { View, Text, Button } from '@tarojs/components'
|
||||
import Taro, { useRouter, useLoad } from '@tarojs/taro'
|
||||
import { useState } from 'react'
|
||||
import { getOrder, prepayMiniprogram } from '../../api'
|
||||
import { getOrder, prepayMiniprogram, queryOrderStatus } from '../../api'
|
||||
import './payment.scss'
|
||||
|
||||
export default function Payment() {
|
||||
@@ -36,6 +36,14 @@ export default function Payment() {
|
||||
})
|
||||
|
||||
Taro.showToast({ title: '支付成功', icon: 'success' })
|
||||
|
||||
// 主动查询订单状态,确保后台已更新
|
||||
try {
|
||||
await queryOrderStatus(order.id)
|
||||
} catch (e) {
|
||||
console.error('Query status failed', e)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
Taro.redirectTo({ url: '/pages/order/list' })
|
||||
}, 1500)
|
||||
|
||||
Reference in New Issue
Block a user