update pay ui
This commit is contained in:
Binary file not shown.
BIN
__pycache__/wechat_pay_worker.cpython-310.pyc
Normal file
BIN
__pycache__/wechat_pay_worker.cpython-310.pyc
Normal file
Binary file not shown.
32
app.py
32
app.py
@@ -2269,14 +2269,20 @@ def check_order_status(order_id):
|
||||
'message': '订单已过期'
|
||||
})
|
||||
|
||||
# 调用微信支付API查询真实状态
|
||||
# 调用微信支付API查询真实状态(使用 subprocess 绕过 eventlet DNS 问题)
|
||||
try:
|
||||
from wechat_pay import create_wechat_pay_instance
|
||||
wechat_pay = create_wechat_pay_instance()
|
||||
import subprocess
|
||||
|
||||
query_result = wechat_pay.query_order(order_no=order.order_no)
|
||||
script_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wechat_pay_worker.py')
|
||||
|
||||
if query_result['success']:
|
||||
query_proc = subprocess.run(
|
||||
[sys.executable, script_path, 'query', order.order_no],
|
||||
capture_output=True, text=True, timeout=30
|
||||
)
|
||||
|
||||
query_result = json.loads(query_proc.stdout) if query_proc.stdout else {'success': False, 'error': '无返回'}
|
||||
|
||||
if query_result.get('success'):
|
||||
trade_state = query_result.get('trade_state')
|
||||
transaction_id = query_result.get('transaction_id')
|
||||
|
||||
@@ -2372,14 +2378,20 @@ def force_update_order_status(order_id):
|
||||
if not order:
|
||||
return jsonify({'success': False, 'error': '订单不存在'}), 404
|
||||
|
||||
# 检查微信支付状态
|
||||
# 检查微信支付状态(使用 subprocess 绕过 eventlet DNS 问题)
|
||||
try:
|
||||
from wechat_pay import create_wechat_pay_instance
|
||||
wechat_pay = create_wechat_pay_instance()
|
||||
import subprocess
|
||||
|
||||
query_result = wechat_pay.query_order(order_no=order.order_no)
|
||||
script_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wechat_pay_worker.py')
|
||||
|
||||
if query_result['success'] and query_result.get('trade_state') == 'SUCCESS':
|
||||
query_proc = subprocess.run(
|
||||
[sys.executable, script_path, 'query', order.order_no],
|
||||
capture_output=True, text=True, timeout=30
|
||||
)
|
||||
|
||||
query_result = json.loads(query_proc.stdout) if query_proc.stdout else {'success': False, 'error': '无返回'}
|
||||
|
||||
if query_result.get('success') and query_result.get('trade_state') == 'SUCCESS':
|
||||
# 强制更新为已支付
|
||||
old_status = order.status
|
||||
order.mark_as_paid(query_result.get('transaction_id'))
|
||||
|
||||
Reference in New Issue
Block a user