Compare commits

..

4 Commits

Author SHA1 Message Date
30039a269c todo: really fix UserLogoutApi 2026-01-21 03:54:28 +08:00
9a5278c3a7 fix: user preview API 2026-01-21 03:41:58 +08:00
90d092729a todo: fix logout issue 2026-01-21 03:30:36 +08:00
971fd5f408 chore: detect keychip mismatch issue 2026-01-21 03:18:29 +08:00
6 changed files with 22 additions and 20 deletions

View File

@@ -29,7 +29,7 @@ pub struct GetResponse {
impl GetUserId { impl GetUserId {
pub fn new(qr_code: impl Into<String>) -> Self { pub fn new(qr_code: impl Into<String>) -> Self {
let chip_id = "A63E-01E54389854".to_string(); let chip_id = "A63E-01C28055905".to_string();
let timestamp = Utc::now() let timestamp = Utc::now()
.with_timezone(&FixedOffset::east_opt(8 * 60 * 60).unwrap()) .with_timezone(&FixedOffset::east_opt(8 * 60 * 60).unwrap())

View File

@@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct GetUserPreviewApi { pub struct GetUserPreviewApi {
pub user_id: u32, pub user_id: u32,
pub client_id: &'static str,
pub token: Option<String>, pub token: Option<String>,
} }
@@ -13,6 +14,7 @@ impl From<u32> for GetUserPreviewApi {
fn from(user_id: u32) -> Self { fn from(user_id: u32) -> Self {
Self { Self {
user_id, user_id,
client_id: "A63E01C2805",
token: None, token: None,
} }
} }

View File

@@ -30,6 +30,7 @@ pub struct UserLoginApiResp {
/// - `1`: success /// - `1`: success
/// - `100`: logged /// - `100`: logged
/// - `102`: QRCode expired /// - `102`: QRCode expired
/// - `110`: KeyChip mismatch
pub return_code: i32, pub return_code: i32,
/// format: yyyy-mm-dd HH:MM:SS /// format: yyyy-mm-dd HH:MM:SS
pub last_login_date: Option<String>, pub last_login_date: Option<String>,
@@ -48,18 +49,19 @@ impl UserLoginApi {
info!("login unix timestamp: {date_time}"); info!("login unix timestamp: {date_time}");
// 爱玩星球焦作解放 // 插电师北京王府井银泰
UserLoginApi { UserLoginApi {
user_id, user_id,
date_time, date_time,
region_id: 13,
acsess_code: "".to_owned(), acsess_code: "".to_owned(),
place_id: 3223.to_string(),
generic_flag: 0, generic_flag: 0,
token, token,
is_continue, is_continue,
client_id: "A63E01E6170".into(),
region_id: 1,
place_id: 1403.to_string(),
client_id: "A63E01C2805".into(),
} }
} }
} }
@@ -68,7 +70,7 @@ impl UserLoginApiResp {
pub fn error(&self) -> Option<LoginError> { pub fn error(&self) -> Option<LoginError> {
match self.return_code { match self.return_code {
1 => None, 1 => None,
100 => Some(LoginError::AlreadyLogged), 100 | 110 => Some(LoginError::AlreadyLogged),
102 => Some(LoginError::QRCodeExpired), 102 => Some(LoginError::QRCodeExpired),
103 => Some(LoginError::AccountUnregistered), 103 => Some(LoginError::AccountUnregistered),
106 => Some(LoginError::KeychipMismatch), 106 => Some(LoginError::KeychipMismatch),

View File

@@ -1,5 +1,3 @@
use std::time::{SystemTime, UNIX_EPOCH};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize)] #[derive(Debug, Clone, PartialEq, Serialize)]
@@ -13,7 +11,7 @@ pub struct UserLogoutApi {
/// keychip without dash, 11 bytes /// keychip without dash, 11 bytes
pub client_id: String, pub client_id: String,
/// Unix timestamp /// Unix timestamp
pub date_time: u64, pub login_date_time: u64,
#[serde(rename = "type")] #[serde(rename = "type")]
pub type_: i64, pub type_: i64,
} }
@@ -27,19 +25,15 @@ pub struct UserLogoutApiResp {
impl Default for UserLogoutApi { impl Default for UserLogoutApi {
fn default() -> Self { fn default() -> Self {
let user_id = 0; let user_id = 0;
let date_time = SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|t| t.as_secs())
.unwrap_or_default();
Self { Self {
user_id, user_id,
date_time,
region_id: 22, region_id: 22,
place_id: 3490, place_id: 3490,
client_id: "A63E01E9564".into(), client_id: "A63E01C2805".into(),
type_: 1, type_: 1,
access_code: "", access_code: "",
login_date_time: 0,
} }
} }
} }

View File

@@ -153,7 +153,7 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
user_id, user_id,
UserLogoutApi { UserLogoutApi {
user_id, user_id,
date_time: timestamp, login_date_time: timestamp,
..Default::default() ..Default::default()
}, },
) )
@@ -170,7 +170,11 @@ async fn main() -> Result<(), Box<dyn snafu::Error>> {
&client, &client,
APIMethod::GetUserPreviewApi, APIMethod::GetUserPreviewApi,
user_id, user_id,
GetUserPreviewApi { user_id, token }, GetUserPreviewApi {
user_id,
client_id: "A63E01C2805",
token,
},
) )
.await?; .await?;

View File

@@ -19,7 +19,7 @@ pub async fn login_action<R>(
action: impl AsyncFnOnce(UserLoginApiResp) -> R, action: impl AsyncFnOnce(UserLoginApiResp) -> R,
) -> Result<R, ApiError> { ) -> Result<R, ApiError> {
let login = UserLoginApi::new(user_id, true, token); let login = UserLoginApi::new(user_id, true, token);
let date_time = login.date_time; let login_date_time = login.date_time;
let login_resp: UserLoginApiResp = let login_resp: UserLoginApiResp =
Sdgb1_53::request(&client, APIMethod::UserLoginApi, user_id, login).await?; Sdgb1_53::request(&client, APIMethod::UserLoginApi, user_id, login).await?;
@@ -37,7 +37,7 @@ pub async fn login_action<R>(
user_id, user_id,
UserLogoutApi { UserLogoutApi {
user_id, user_id,
date_time, login_date_time,
..Default::default() ..Default::default()
}, },
) )