修复后台用户目标跨节点读取
Project CI / Backend tests (pull_request) Successful in 10m20s
Project CI / Repository checks (pull_request) Successful in 2m35s
Project CI / Frontend tests (pull_request) Successful in 5m5s
Project CI / Native shell tests (pull_request) Successful in 16m57s

后台充值与钱包操作先刷新用户认证正式投影

避免目标用户仅存在于其他 API 节点时被误判不存在
This commit is contained in:
2026-08-27 20:57:45 +08:00
parent 2b8d44b369
commit 347eca2056
@@ -64,6 +64,7 @@ pub async fn admin_list_recharge_orders(
Extension(_admin): Extension<AuthenticatedAdmin>,
Query(query): Query<AdminRechargeOrderListQuery>,
) -> Result<Json<Value>, Response> {
refresh_auth_projection(&state, &request_context).await?;
let user_id = resolve_optional_user_id(&state, query.user_id, query.public_user_code)
.map_err(|error| error_response(&request_context, error))?;
let input = build_runtime_profile_recharge_order_admin_list_input(
@@ -112,6 +113,7 @@ pub async fn admin_get_user_detail(
Extension(admin): Extension<AuthenticatedAdmin>,
Query(query): Query<AdminUserDetailQuery>,
) -> Result<Json<Value>, Response> {
refresh_auth_projection(&state, &request_context).await?;
let user = resolve_user(&state, query.user_id, query.public_user_code)
.map_err(|error| error_response(&request_context, error))?;
let wallet_detail = state
@@ -181,6 +183,7 @@ pub async fn admin_reconcile_user_consumption(
Extension(admin): Extension<AuthenticatedAdmin>,
Json(payload): Json<AdminUserConsumptionReconcileRequest>,
) -> Result<Json<Value>, Response> {
refresh_auth_projection(&state, &request_context).await?;
let user = resolve_user(&state, Some(payload.user_id), None)
.map_err(|error| error_response(&request_context, error))?;
let input = build_runtime_profile_wallet_consumption_reconcile_input(
@@ -589,6 +592,7 @@ pub async fn admin_update_wallet_restriction(
Extension(admin): Extension<AuthenticatedAdmin>,
Json(payload): Json<AdminWalletRestrictionRequest>,
) -> Result<Json<Value>, Response> {
refresh_auth_projection(&state, &request_context).await?;
let user = resolve_user(&state, Some(payload.user_id), None)
.map_err(|error| error_response(&request_context, error))?;
let input = build_runtime_profile_wallet_manual_restriction_upsert_input(
@@ -1040,6 +1044,22 @@ fn map_hold(hold: RuntimeProfileRechargeRefundHoldSnapshot) -> AdminRechargeRefu
}
}
async fn refresh_auth_projection(
state: &AppState,
request_context: &RequestContext,
) -> Result<(), Response> {
state
.refresh_auth_store_from_spacetime()
.await
.map_err(|error| {
error_response(
request_context,
AppError::from_status(StatusCode::BAD_GATEWAY)
.with_message(format!("刷新用户认证信息失败:{error}")),
)
})
}
fn resolve_optional_user_id(
state: &AppState,
user_id: Option<String>,