bf57aed17a
- git mv sanguo_web → _retired/sanguo_web/(git 历史保全+墓碑 README:
归档原因/拍板记录/现役=sanguo_api)
- 退出启动面三处: promote.sh ALL_MODS 白名单(15→14 模块)+docker/Dockerfile:63
COPY+docker/Dockerfile.nas:16 COPY——不可再被部署或启动为服务
- 背景(架构审计 P0-3): 硬编码 SECRET_KEY/admin123 默认口令/CORS 全开/可下
真实订单/零测试/与 sanguo_api 路由冲突; 生产从未部署为服务, 纯误启动风险
(README 旧「生产模式 uvicorn sanguo_web」指引已于 f6ca85e 勘误)
- three-env §3.1 模块清单+§12 矩阵行同步; session-guide §5 角色表前端行
勘误(旧表把 sanguo_web 当前端模块推——实为 legacy 后端, 前端=frontend/)
- 零外部 import(runuweb/tests/packages 全 grep 实证), pytest testpaths=tests
不受影响
Co-Authored-By: Claude Code <notify@anthropic.com>
98 lines
2.5 KiB
Python
98 lines
2.5 KiB
Python
"""
|
|
资金监控路由
|
|
处理账户资金查询
|
|
"""
|
|
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from typing import List
|
|
import logging
|
|
|
|
from ..deps import get_current_user, get_vn_service
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/", response_model=List[dict])
|
|
async def get_all_accounts(
|
|
current_user: dict = Depends(get_current_user),
|
|
vn_service=Depends(get_vn_service)
|
|
):
|
|
"""
|
|
获取所有账户资金
|
|
|
|
返回所有账户的资金信息,包括账号、余额、冻结、可用资金等
|
|
"""
|
|
accounts = await vn_service.get_accounts()
|
|
|
|
return [
|
|
{
|
|
"accountid": acc.get("account_id", ""),
|
|
"balance": acc.get("balance", 0.0),
|
|
"frozen": acc.get("frozen", 0.0),
|
|
"available": acc.get("available", 0.0),
|
|
"gateway_name": acc.get("gateway_name", ""),
|
|
}
|
|
for acc in accounts
|
|
]
|
|
|
|
|
|
@router.get("/{accountid}", response_model=dict)
|
|
async def get_account(
|
|
accountid: str,
|
|
current_user: dict = Depends(get_current_user),
|
|
vn_service=Depends(get_vn_service)
|
|
):
|
|
"""
|
|
获取指定账户的资金信息
|
|
|
|
- **accountid**: 账号
|
|
"""
|
|
accounts = await vn_service.get_accounts()
|
|
|
|
account = next(
|
|
(acc for acc in accounts if acc.get("account_id", "") == accountid),
|
|
None
|
|
)
|
|
|
|
if not account:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
detail=f"Account {accountid} not found"
|
|
)
|
|
|
|
return {
|
|
"accountid": account.get("account_id", ""),
|
|
"balance": account.get("balance", 0.0),
|
|
"frozen": account.get("frozen", 0.0),
|
|
"available": account.get("available", 0.0),
|
|
"gateway_name": account.get("gateway_name", ""),
|
|
}
|
|
|
|
|
|
@router.get("/summary/total", response_model=dict)
|
|
async def get_account_summary(
|
|
current_user: dict = Depends(get_current_user),
|
|
vn_service=Depends(get_vn_service)
|
|
):
|
|
"""
|
|
获取所有账户的资金汇总
|
|
|
|
返回所有账户的余额、冻结、可用资金的总和
|
|
"""
|
|
accounts = await vn_service.get_accounts()
|
|
|
|
total_balance = sum(acc.get("balance", 0.0) for acc in accounts)
|
|
total_frozen = sum(acc.get("frozen", 0.0) for acc in accounts)
|
|
total_available = sum(acc.get("available", 0.0) for acc in accounts)
|
|
|
|
return {
|
|
"total_balance": total_balance,
|
|
"total_frozen": total_frozen,
|
|
"total_available": total_available,
|
|
"account_count": len(accounts),
|
|
}
|
|
|
|
|
|
__all__ = ["router"]
|