diff --git a/blueprints/__pycache__/admin.cpython-312.pyc b/blueprints/__pycache__/admin.cpython-312.pyc index 883a16b..f8db394 100644 Binary files a/blueprints/__pycache__/admin.cpython-312.pyc and b/blueprints/__pycache__/admin.cpython-312.pyc differ diff --git a/blueprints/__pycache__/auth.cpython-312.pyc b/blueprints/__pycache__/auth.cpython-312.pyc index 3183e55..c123396 100644 Binary files a/blueprints/__pycache__/auth.cpython-312.pyc and b/blueprints/__pycache__/auth.cpython-312.pyc differ diff --git a/blueprints/__pycache__/payment.cpython-312.pyc b/blueprints/__pycache__/payment.cpython-312.pyc index 3190b24..ea928e7 100644 Binary files a/blueprints/__pycache__/payment.cpython-312.pyc and b/blueprints/__pycache__/payment.cpython-312.pyc differ diff --git a/blueprints/admin.py b/blueprints/admin.py index 7e0cc41..03892a2 100644 --- a/blueprints/admin.py +++ b/blueprints/admin.py @@ -194,6 +194,7 @@ def delete_notification(): @permission_required('manage_system') # 仅限超级管理员 def get_orders(): orders = Order.query.order_by(Order.created_at.desc()).all() + from datetime import timedelta return jsonify({ "orders": [{ "id": o.id, @@ -203,7 +204,7 @@ def get_orders(): "points": o.points, "status": o.status, "trade_no": o.trade_no, - "created_at": o.created_at.strftime('%Y-%m-%d %H:%M:%S'), - "paid_at": o.paid_at.strftime('%Y-%m-%d %H:%M:%S') if o.paid_at else None + "created_at": (o.created_at + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S'), + "paid_at": (o.paid_at + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S') if o.paid_at else None } for o in orders] }) \ No newline at end of file diff --git a/blueprints/auth.py b/blueprints/auth.py index 7c85826..99c45cb 100644 --- a/blueprints/auth.py +++ b/blueprints/auth.py @@ -62,8 +62,22 @@ def buy_page(): admin_orders = [] if is_admin: admin_orders = Order.query.order_by(Order.created_at.desc()).limit(10).all() + + # 处理支付成功提示 + success = request.args.get('success') == 'true' + out_trade_no = request.args.get('out_trade_no') + order = None + if out_trade_no: + order = Order.query.filter_by(out_trade_no=out_trade_no).first() - return render_template('buy.html', personal_orders=personal_orders, admin_orders=admin_orders, is_admin=is_admin) + import datetime + return render_template('buy.html', + personal_orders=personal_orders, + admin_orders=admin_orders, + is_admin=is_admin, + modules={'datetime': datetime}, + success=success, + order=order) @auth_bp.route('/api/auth/send_code', methods=['POST']) def send_code(): diff --git a/blueprints/payment.py b/blueprints/payment.py index 69f6d02..d7c294d 100644 --- a/blueprints/payment.py +++ b/blueprints/payment.py @@ -82,8 +82,8 @@ def payment_return(): if success: logger.info(f"同步回调验证成功,订单号: {out_trade_no}") - # 同步通知仅用于页面展示,实际业务逻辑在异步通知 notify 中处理 - return render_template('buy.html', success=True, order=order) + # 重定向到充值页面,并带上成功参数 + return redirect(url_for('auth.buy_page', success='true', out_trade_no=out_trade_no)) else: logger.error(f"同步回调验证失败,订单号: {out_trade_no}") return "支付验证失败", 400 @@ -101,7 +101,8 @@ def payment_history(): user_id = session['user_id'] orders = Order.query.filter_by(user_id=user_id).order_by(Order.created_at.desc()).all() - return render_template('recharge_history.html', orders=orders) + import datetime + return render_template('recharge_history.html', orders=orders, modules={'datetime': datetime}) @payment_bp.route('/api/history', methods=['GET']) def api_payment_history(): @@ -112,6 +113,7 @@ def api_payment_history(): user_id = session['user_id'] orders = Order.query.filter_by(user_id=user_id).order_by(Order.created_at.desc()).all() + from datetime import timedelta return jsonify({ "orders": [{ "id": o.id, @@ -120,8 +122,8 @@ def api_payment_history(): "points": o.points, "status": o.status, "trade_no": o.trade_no, - "created_at": o.created_at.strftime('%Y-%m-%d %H:%M:%S'), - "paid_at": o.paid_at.strftime('%Y-%m-%d %H:%M:%S') if o.paid_at else None + "created_at": (o.created_at + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S'), + "paid_at": (o.paid_at + timedelta(hours=8)).strftime('%Y-%m-%d %H:%M:%S') if o.paid_at else None } for o in orders] }) @payment_bp.route('/notify', methods=['POST']) diff --git a/templates/buy.html b/templates/buy.html index 1e00795..931cc68 100644 --- a/templates/buy.html +++ b/templates/buy.html @@ -178,7 +178,13 @@ {% endif %}