2026-09-12 20:42:33 +08:00
|
|
|
"""customer_relation 客户-投顾关系表 ORM 模型。
|
|
|
|
|
|
|
|
|
|
同时服务于:
|
|
|
|
|
- 投顾工作台(advisor):签约状态 unsigned/signed/closed,工作台为唯一写入方;
|
|
|
|
|
- 记忆/client_agent 模块:读取客户与投顾的当前或历史关系。
|
|
|
|
|
"""
|
2026-09-11 22:38:15 +08:00
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
|
2026-09-12 20:42:33 +08:00
|
|
|
from sqlalchemy import BigInteger, DateTime, String, func
|
2026-09-11 22:38:15 +08:00
|
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
|
|
|
|
|
|
from model.base import Base
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CustomerRelation(Base):
|
|
|
|
|
__tablename__ = "customer_relation"
|
2026-09-12 20:42:33 +08:00
|
|
|
__table_args__ = {"comment": "客户-投顾关系表(状态驱动:签约后投顾Agent方案正式触达客户)"}
|
2026-09-11 22:38:15 +08:00
|
|
|
|
|
|
|
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
|
|
|
customer_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
|
|
|
|
advisor_id: Mapped[int] = mapped_column(BigInteger, nullable=False)
|
2026-09-12 20:42:33 +08:00
|
|
|
assign_time: Mapped[datetime] = mapped_column(
|
|
|
|
|
DateTime, nullable=False, server_default=func.now()
|
|
|
|
|
)
|
2026-09-11 22:38:15 +08:00
|
|
|
signed_time: Mapped[datetime | None] = mapped_column(DateTime)
|
|
|
|
|
end_time: Mapped[datetime | None] = mapped_column(DateTime)
|
2026-09-12 20:42:33 +08:00
|
|
|
status: Mapped[str] = mapped_column(
|
|
|
|
|
String(16), nullable=False, server_default="unsigned"
|
|
|
|
|
)
|
2026-09-11 22:38:15 +08:00
|
|
|
reason: Mapped[str | None] = mapped_column(String(128))
|