"""协同机会模型。 Portfolio 内部协同匹配与效果追踪。 """ import uuid from datetime import datetime, timezone from sqlalchemy import DateTime, ForeignKey, String, Text from sqlalchemy.orm import Mapped, mapped_column from app.core.database import Base from app.core.types import JSONBType class SynergyOpportunity(Base): """协同机会。""" __tablename__ = "synergy_opportunities" id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4())) tenant_id: Mapped[str] = mapped_column(String(36), ForeignKey("tenants.id"), nullable=False, index=True) type: Mapped[str] = mapped_column(String(50), nullable=False, comment="customer/talent/funding/supply_chain/tech") company_a_id: Mapped[str] = mapped_column(String(36), ForeignKey("companies.id"), nullable=False, index=True) company_b_id: Mapped[str | None] = mapped_column(String(36), ForeignKey("companies.id"), nullable=True) title: Mapped[str] = mapped_column(String(200), nullable=False) description: Mapped[str | None] = mapped_column(Text, nullable=True) match_reason: Mapped[str | None] = mapped_column(Text, nullable=True, comment="AI 匹配理由") status: Mapped[str] = mapped_column(String(20), nullable=False, default="discovered", comment="discovered/confirmed/authorized/executing/completed/declined") authorized: Mapped[bool] = mapped_column(default=False, comment="双方是否授权") effect_result: Mapped[dict | None] = mapped_column(JSONBType, nullable=True, comment="效果评估") created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), default=lambda: datetime.now(timezone.utc) ) updated_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), default=lambda: datetime.now(timezone.utc), onupdate=lambda: datetime.now(timezone.utc), )