fix: 取消订单错误提示区分已支付/已取消状态+支付确认提示优化

This commit is contained in:
2026-06-17 13:32:01 +08:00
parent fb224c829f
commit 6d066c8e82

View File

@@ -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(());
}