fix(wallet): 删除与过期删除 API Key 时同步禁用关联钱包 (#315)

- 在 delete_user_api_key 和 delete_standalone_api_key 事务中,先将关联 wallets.status 更新为 disabled
- 在过期 Key 自动清理流程中,删除前同步禁用对应钱包
- 保留 wallet 与交易流水,避免出现 orphaned 且 active 的钱包状态
This commit is contained in:
AAEE86
2026-04-20 14:03:17 +08:00
committed by GitHub
parent 13bf222b8d
commit b2ff7d2c28
3 changed files with 38 additions and 7 deletions
@@ -570,6 +570,13 @@ const DELETE_EXPIRED_API_KEY_SQL: &str = r#"
DELETE FROM api_keys
WHERE id = $1
"#;
const DISABLE_EXPIRED_API_KEY_WALLET_SQL: &str = r#"
UPDATE wallets
SET status = 'disabled',
updated_at = NOW()
WHERE api_key_id = $1
AND status <> 'disabled'
"#;
const DISABLE_EXPIRED_API_KEY_SQL: &str = r#"
UPDATE api_keys
SET is_active = FALSE,