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)