feat: 添加PAYMENT_MAINTENANCE_MODE维护模式 + ServiceUnavailable错误

This commit is contained in:
2026-05-25 13:32:16 +08:00
parent 72cbb8ff28
commit f82dd8d5de
4 changed files with 48 additions and 9 deletions

View File

@@ -16,8 +16,13 @@ pub async fn get_current_user_profile(
info!("获取当前用户信息, 用户ID: {}", user_id);
let user = db::get_user_by_id(pool.get_ref(), user_id).await?;
let is_paid_active = user.is_paid &&
user.paid_expires_at.map_or(true, |expires| expires > chrono::Utc::now());
let is_maintenance = std::env::var("PAYMENT_MAINTENANCE_MODE").ok() == Some("true".to_string());
let is_paid_active = if is_maintenance {
true
} else {
user.is_paid &&
user.paid_expires_at.map_or(true, |expires| expires > chrono::Utc::now())
};
Ok(HttpResponse::Ok().json(serde_json::json!({
"success": true,