feat:新增接口

This commit is contained in:
2026-09-11 11:05:52 +08:00
parent 2004b8fcf4
commit 78e326db59
18 changed files with 766 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
"""fin_account 客户资金账户表 ORM 模型(现金余额,一人一户)。
balance 为账户总余额(含冻结部分),可用余额 = balance - frozen_amount,不落库。
"""
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from sqlalchemy import BigInteger, DateTime, Integer, Numeric, String, func
from sqlalchemy.orm import Mapped, mapped_column
from model.base import Base
class FinAccount(Base):
__tablename__ = "fin_account"
__table_args__ = {"comment": "客户资金账户表(现金余额,申购扣款/赎回入账的账务载体)"}
customer_id: Mapped[int] = mapped_column(
BigInteger, primary_key=True, autoincrement=False
)
balance: Mapped[Decimal] = mapped_column(Numeric(18, 2), server_default="0")
frozen_amount: Mapped[Decimal] = mapped_column(Numeric(18, 2), server_default="0")
currency: Mapped[str] = mapped_column(String(8), server_default="CNY")
status: Mapped[str] = mapped_column(String(16), server_default="正常")
version: Mapped[int] = mapped_column(Integer, server_default="0")
create_time: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now()
)
update_time: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), onupdate=func.now()
)
+29
View File
@@ -0,0 +1,29 @@
"""fin_holdings 持仓表 ORM 模型(当前/历史持仓快照)。"""
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from sqlalchemy import BigInteger, DateTime, Numeric, String, func
from sqlalchemy.orm import Mapped, mapped_column
from model.base import Base
class FinHoldings(Base):
__tablename__ = "fin_holdings"
__table_args__ = {"comment": "持仓表(当前/历史持仓快照)"}
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
customer_id: Mapped[int] = mapped_column(BigInteger)
product_id: Mapped[int] = mapped_column(BigInteger)
shares: Mapped[Decimal] = mapped_column(Numeric(18, 4), server_default="0")
cost_amount: Mapped[Decimal] = mapped_column(Numeric(18, 2), server_default="0")
current_value: Mapped[Decimal] = mapped_column(Numeric(18, 2), server_default="0")
profit_loss: Mapped[Decimal] = mapped_column(Numeric(18, 2), server_default="0")
profit_ratio: Mapped[Decimal] = mapped_column(Numeric(8, 4), server_default="0")
status: Mapped[str] = mapped_column(String(16), server_default="持有中")
create_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
update_time: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), onupdate=func.now()
)