From e6e04979dca6d02a0f234f8ebee522952c4941dc Mon Sep 17 00:00:00 2001 From: milky0217 Date: Mon, 25 May 2026 13:45:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20get=5Fuser=5Fquota=20=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=20was=5Fpaid=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db.rs | 4 ++-- src/handlers/payment.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/db.rs b/src/db.rs index 9be64ca..f73b851 100644 --- a/src/db.rs +++ b/src/db.rs @@ -682,12 +682,12 @@ pub async fn refund_payment_order( pub async fn get_user_quota( pool: &PgPool, user_id: i32, -) -> Result<(i64, bool, Option>), AppError> { +) -> Result<(i64, bool, Option>, bool), AppError> { let user = get_user_by_id(pool, user_id).await?; let is_paid_active = user.is_paid && user.paid_expires_at.map_or(true, |expires| expires > chrono::Utc::now()); let used = count_user_weather_data(pool, user_id).await?; - Ok((used, is_paid_active, user.paid_expires_at)) + Ok((used, is_paid_active, user.paid_expires_at, user.is_paid)) } // ===== 收藏功能 DB 函数 ===== diff --git a/src/handlers/payment.rs b/src/handlers/payment.rs index c4bfd9d..2349e81 100644 --- a/src/handlers/payment.rs +++ b/src/handlers/payment.rs @@ -1071,7 +1071,7 @@ pub async fn get_user_quota( let is_maintenance = std::env::var("PAYMENT_MAINTENANCE_MODE").ok() == Some("true".to_string()); - let (used, is_paid_active, paid_expires_at) = + let (used, is_paid_active, paid_expires_at, was_paid) = db::get_user_quota(pool.get_ref(), user_id).await?; // 维护模式使用更高的临时限额,但非会员仍然有限制防止滥用 @@ -1097,6 +1097,7 @@ pub async fn get_user_quota( "unlimited": unlimited, "is_paid_active": active, "paid_expires_at": paid_expires_at, + "was_paid": was_paid, "maintenance_mode": is_maintenance, } })))