feat(platform): 增加履约分类映射管理并锁定迁移

This commit is contained in:
yml
2026-11-21 14:41:36 +08:00
parent 8580f9738d
commit 7396126c73
20 changed files with 3093 additions and 115 deletions
+49 -2
View File
@@ -1934,7 +1934,7 @@ class PlatformFulfillmentSetting(Base):
class PlatformCommodityMapping(Base):
"""order_site 内部 SKU 到斗鱼商品的显式映射。"""
"""order_site 内部 SKU 到斗鱼商品的活动批次映射。"""
__tablename__ = "platform_commodity_mappings"
@@ -1943,6 +1943,12 @@ class PlatformCommodityMapping(Base):
String(16), nullable=False, default="douyu", server_default="douyu"
)
internal_sku_key: Mapped[str] = mapped_column(String(255), nullable=False)
campaign_key: Mapped[str] = mapped_column(
String(128), nullable=False, default="douyu-current", server_default="douyu-current"
)
campaign_name: Mapped[str] = mapped_column(
String(255), nullable=False, default="", server_default=""
)
commodity_id: Mapped[str] = mapped_column(String(64), nullable=False)
goods_name: Mapped[str] = mapped_column(
String(255), nullable=False, default="", server_default=""
@@ -1951,9 +1957,31 @@ class PlatformCommodityMapping(Base):
scope: Mapped[str] = mapped_column(
String(16), nullable=False, default="elite", server_default="elite"
)
# presale / direct / manual / unknown
sale_mode: Mapped[str] = mapped_column(
String(16), nullable=False, default="unknown", server_default="unknown"
)
available_from: Mapped[datetime | None] = mapped_column(UTCDateTime, nullable=True)
available_until: Mapped[datetime | None] = mapped_column(UTCDateTime, nullable=True)
released_at: Mapped[datetime | None] = mapped_column(UTCDateTime, nullable=True)
goods_status: Mapped[str] = mapped_column(
String(32), nullable=False, default="", server_default=""
)
enabled: Mapped[bool] = mapped_column(
Boolean, nullable=False, default=True, server_default="1"
)
version: Mapped[int] = mapped_column(
Integer, nullable=False, default=1, server_default="1"
)
archived_at: Mapped[datetime | None] = mapped_column(UTCDateTime, nullable=True)
archived_by: Mapped[int | None] = mapped_column(
ForeignKey(
"users.id",
ondelete="SET NULL",
name="fk_platform_mapping_archived_by",
),
nullable=True,
)
created_by: Mapped[int | None] = mapped_column(
ForeignKey("users.id"), nullable=True
)
@@ -1966,7 +1994,8 @@ class PlatformCommodityMapping(Base):
UniqueConstraint(
"target_platform",
"internal_sku_key",
name="uq_platform_commodity_mapping_sku",
"campaign_key",
name="uq_platform_commodity_mapping_campaign",
),
Index(
"ix_platform_commodity_mapping_enabled",
@@ -2031,6 +2060,24 @@ class PlatformFulfillmentTask(Base):
String(64), nullable=False, default="", server_default=""
)
required_points: Mapped[int | None] = mapped_column(Integer, nullable=True)
sale_mode: Mapped[str] = mapped_column(
String(16), nullable=False, default="unknown", server_default="unknown"
)
campaign_key: Mapped[str] = mapped_column(
String(128), nullable=False, default="", server_default=""
)
campaign_name: Mapped[str] = mapped_column(
String(255), nullable=False, default="", server_default=""
)
offer_available_from: Mapped[datetime | None] = mapped_column(
UTCDateTime, nullable=True
)
offer_available_until: Mapped[datetime | None] = mapped_column(
UTCDateTime, nullable=True
)
classification_source: Mapped[str] = mapped_column(
String(24), nullable=False, default="unknown", server_default="unknown"
)
account_id: Mapped[int | None] = mapped_column(
ForeignKey("accounts.id", ondelete="SET NULL"), nullable=True, index=True
)