fix: payment/success 同步确认订单(防止异步回调未到)
This commit is contained in:
@@ -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<AlipaySuccessQuery>) -> HttpResponse {
|
||||
pub async fn payment_success(
|
||||
pool: web::Data<PgPool>,
|
||||
query: web::Query<AlipaySuccessQuery>,
|
||||
) -> 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)
|
||||
|
||||
Reference in New Issue
Block a user