fix: 后台定时清理refresh_token+清理payment.rs死代码
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
use actix_web::{web, get, put, post, delete, HttpResponse};
|
use actix_web::{web, get, put, post, delete, HttpResponse};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::postgres::PgPool;
|
use sqlx::postgres::PgPool;
|
||||||
use chrono::Utc;
|
|
||||||
|
|
||||||
use crate::db;
|
use crate::db;
|
||||||
use crate::error::AppError;
|
use crate::error::AppError;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ use crate::models::{Claims, CreateOrderRequest, MockConfirmRequest};
|
|||||||
struct PackageInfo {
|
struct PackageInfo {
|
||||||
amount: i32,
|
amount: i32,
|
||||||
display_amount: &'static str,
|
display_amount: &'static str,
|
||||||
original_amount: &'static str,
|
|
||||||
display_name: &'static str,
|
display_name: &'static str,
|
||||||
days: Option<i64>,
|
days: Option<i64>,
|
||||||
}
|
}
|
||||||
@@ -31,28 +30,24 @@ fn get_package_info(package_type: &str) -> Option<PackageInfo> {
|
|||||||
"monthly" => Some(PackageInfo {
|
"monthly" => Some(PackageInfo {
|
||||||
amount: 590,
|
amount: 590,
|
||||||
display_amount: "5.9",
|
display_amount: "5.9",
|
||||||
original_amount: "9.9",
|
|
||||||
display_name: "包月会员",
|
display_name: "包月会员",
|
||||||
days: Some(30),
|
days: Some(30),
|
||||||
}),
|
}),
|
||||||
"quarterly" => Some(PackageInfo {
|
"quarterly" => Some(PackageInfo {
|
||||||
amount: 1680,
|
amount: 1680,
|
||||||
display_amount: "16.8",
|
display_amount: "16.8",
|
||||||
original_amount: "29",
|
|
||||||
display_name: "季卡会员",
|
display_name: "季卡会员",
|
||||||
days: Some(90),
|
days: Some(90),
|
||||||
}),
|
}),
|
||||||
"half_year" => Some(PackageInfo {
|
"half_year" => Some(PackageInfo {
|
||||||
amount: 3190,
|
amount: 3190,
|
||||||
display_amount: "31.9",
|
display_amount: "31.9",
|
||||||
original_amount: "49",
|
|
||||||
display_name: "半年会员",
|
display_name: "半年会员",
|
||||||
days: Some(182),
|
days: Some(182),
|
||||||
}),
|
}),
|
||||||
"yearly" => Some(PackageInfo {
|
"yearly" => Some(PackageInfo {
|
||||||
amount: 6020,
|
amount: 6020,
|
||||||
display_amount: "60.2",
|
display_amount: "60.2",
|
||||||
original_amount: "99",
|
|
||||||
display_name: "包年会员",
|
display_name: "包年会员",
|
||||||
days: Some(365),
|
days: Some(365),
|
||||||
}),
|
}),
|
||||||
@@ -81,22 +76,6 @@ impl AlipayConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// URL 编码(RFC 3986)
|
|
||||||
fn urlencoding(s: &str) -> String {
|
|
||||||
let mut result = String::new();
|
|
||||||
for c in s.chars() {
|
|
||||||
match c {
|
|
||||||
'A'..='Z' | 'a'..='z' | '0'..='9' | '-' | '_' | '.' | '~' => result.push(c),
|
|
||||||
_ => {
|
|
||||||
for b in c.to_string().as_bytes() {
|
|
||||||
result.push_str(&format!("%{:02X}", b));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
/// RSA2 (SHA256) 签名
|
/// RSA2 (SHA256) 签名
|
||||||
fn rsa2_sign(content: &str, private_key_pem: &str) -> Result<String, String> {
|
fn rsa2_sign(content: &str, private_key_pem: &str) -> Result<String, String> {
|
||||||
let private_key = match RsaPrivateKey::from_pkcs8_pem(private_key_pem) {
|
let private_key = match RsaPrivateKey::from_pkcs8_pem(private_key_pem) {
|
||||||
|
|||||||
@@ -270,6 +270,9 @@ async fn main() -> std::io::Result<()> {
|
|||||||
|
|
||||||
// 会员到期前 7 天提醒
|
// 会员到期前 7 天提醒
|
||||||
let _ = db::check_member_expiry_soon(&pool_clone).await;
|
let _ = db::check_member_expiry_soon(&pool_clone).await;
|
||||||
|
|
||||||
|
// 清理过期的 refresh_token
|
||||||
|
let _ = db::cleanup_expired_refresh_tokens(&pool_clone).await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user