Files
Mutual_Fund/model/fin_account.py
T

34 lines
1.3 KiB
Python
Raw Normal View History

2026-09-10 23:21:30 +08:00
"""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()
)