30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
"""fin_transaction 成交流水 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 FinTransaction(Base):
|
||
|
|
__tablename__ = "fin_transaction"
|
||
|
|
__table_args__ = {"comment": "成交流水表(成交后落库)"}
|
||
|
|
|
||
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||
|
|
transaction_no: Mapped[str] = mapped_column(String(32), unique=True)
|
||
|
|
order_id: Mapped[int | None] = mapped_column(BigInteger)
|
||
|
|
customer_id: Mapped[int] = mapped_column(BigInteger)
|
||
|
|
product_id: Mapped[int] = mapped_column(BigInteger)
|
||
|
|
operator_id: Mapped[int | None] = mapped_column(BigInteger)
|
||
|
|
transaction_type: Mapped[str] = mapped_column(String(16))
|
||
|
|
amount: Mapped[Decimal] = mapped_column(Numeric(18, 2))
|
||
|
|
shares: Mapped[Decimal | None] = mapped_column(Numeric(18, 4))
|
||
|
|
nav: Mapped[Decimal | None] = mapped_column(Numeric(12, 6))
|
||
|
|
fee: Mapped[Decimal] = mapped_column(Numeric(12, 2), server_default="0")
|
||
|
|
status: Mapped[str] = mapped_column(String(16), server_default="已确认")
|
||
|
|
create_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|