42 lines
2.1 KiB
Python
42 lines
2.1 KiB
Python
"""客户主动申报投顾方案 → 投顾受理审批 的工单模型。"""
|
|||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
from decimal import Decimal
|
||
|
|
|
||
|
|
from sqlalchemy import BigInteger, DateTime, Numeric, String
|
||
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
|
|
||
|
|
from app.model.base import Base
|
||
|
|
|
||
|
|
#: 状态机(`pending --受理--> accepted` / `pending --驳回--> rejected`)。
|
||
|
|
#: 「已发送给客户」不单独存状态:它由 `result_content_id` 指向的方案是否已发布**推导**出来
|
||
|
|
#: (见 `AdvisorServiceRequestService._view`),避免两处状态各写各的而对不上。
|
||
|
|
PENDING = "pending"
|
||
|
|
ACCEPTED = "accepted"
|
||
|
|
REJECTED = "rejected"
|
||
|
|
DELIVERED = "delivered"
|
||
|
|
|
||
|
|
|
||
|
|
class AdvisorServiceRequest(Base):
|
||
|
|
"""客户在「我的投顾方案」页发起的服务申请单。"""
|
||
|
|
|
||
|
|
__tablename__ = "advisor_service_request"
|
||
|
|
|
||
|
|
#: 本表是本轮新建的,**带上 AUTO_INCREMENT** —— 既有 `fin_*` 表缺自增
|
||
|
|
#: 导致"不给 id 就插不进去"的坑,新表不再重复踩。
|
||
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||
|
|
request_no: Mapped[str] = mapped_column(String(32), unique=True, nullable=False)
|
||
|
|
customer_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
||
|
|
amount_wan: Mapped[Decimal] = mapped_column(Numeric(14, 2), nullable=False)
|
||
|
|
horizon: Mapped[str] = mapped_column(String(16), nullable=False)
|
||
|
|
risk_preference: Mapped[str] = mapped_column(String(16), nullable=False)
|
||
|
|
note: Mapped[str | None] = mapped_column(String(500))
|
||
|
|
status: Mapped[str] = mapped_column(String(24), nullable=False)
|
||
|
|
handled_by: Mapped[int | None] = mapped_column(BigInteger)
|
||
|
|
handled_at: Mapped[datetime | None] = mapped_column(DateTime)
|
||
|
|
advisor_note: Mapped[str | None] = mapped_column(String(500))
|
||
|
|
#: 受理时自动生成的方案(`client_facing_content.id`);驳回时为 None。
|
||
|
|
result_content_id: Mapped[int | None] = mapped_column(BigInteger)
|
||
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|
||
|
|
updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|