From c82bb303f77278686442a7fcc39243e844610226 Mon Sep 17 00:00:00 2001 From: Milky0217 Date: Thu, 7 May 2026 16:52:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20payment/success=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E8=AE=A2=E5=8D=95=EF=BC=88=E9=98=B2=E6=AD=A2?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E5=9B=9E=E8=B0=83=E6=9C=AA=E5=88=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/handlers/payment.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/handlers/payment.rs b/src/handlers/payment.rs index d212b1c..bb44a6e 100644 --- a/src/handlers/payment.rs +++ b/src/handlers/payment.rs @@ -852,10 +852,20 @@ fn format_error_html(msg: &str, order_no: &str) -> String { } #[get("/payment/success")] -pub async fn payment_success(query: web::Query) -> HttpResponse { +pub async fn payment_success( + pool: web::Data, + query: web::Query, +) -> HttpResponse { let order_no = query.order_no.as_deref().unwrap_or(""); - let html = build_success_html(order_no); + // 同步确认订单(幂等:已确认的订单会跳过) + if !order_no.is_empty() { + if let Err(e) = db::confirm_payment_order_by_orderno(pool.get_ref(), order_no).await { + tracing::warn!("支付成功页同步确认失败(可能是异步回调已处理): {}", e); + } + } + + let html = build_success_html(order_no); HttpResponse::Ok() .content_type("text/html; charset=utf-8") .body(html)