diff --git a/src/db.rs b/src/db.rs index 182897f..f6fe9ef 100644 --- a/src/db.rs +++ b/src/db.rs @@ -578,7 +578,14 @@ pub async fn confirm_payment_order( } if status != "pending" { - return Err(AppError::BadRequest("订单状态异常,无法确认支付".to_string())); + let hint = if status == "paid" { + "该订单已支付成功,无需重复操作" + } else if status == "cancelled" { + "该订单已被取消,如已扣款请联系客服处理" + } else { + "该订单状态异常,请联系客服" + }; + return Err(AppError::BadRequest(hint.to_string())); } // 一次性完成:更新订单状态 + 累加计算新的到期时间(纯 SQL) @@ -692,7 +699,7 @@ pub async fn confirm_payment_order_by_orderno( // 0 行 update 说明订单已被取消/退款/已确认(竞态保护生效) if result.rows_affected() == 0 { - tracing::warn!("支付确认: 订单 {} 状态已变更,跳过处理", order_no); + tracing::warn!("支付确认: 订单 {} 状态已变更,跳过处理(可能是竞态或重复回调)", order_no); return Ok(()); }