"""CPS 推广群(cps_group)。 每个微信群一条记录,`sid` 是美团联盟二级渠道追踪位(get_referral_link / query_order 共用):发券时塞进推广链接,订单回来按 sid 归群对账。美团限制 sid 仅字母+数字 ≤64。 """ from __future__ import annotations from datetime import datetime from sqlalchemy import DateTime, Integer, String, func from sqlalchemy.orm import Mapped, mapped_column from app.db.base import Base class CpsGroup(Base): __tablename__ = "cps_group" id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True) # 每群唯一的渠道标识,建群时分配(留空则自动生成 g)。字母+数字,≤64。 sid: Mapped[str] = mapped_column(String(64), unique=True, index=True, nullable=False) name: Mapped[str] = mapped_column(String(128), nullable=False) # 群人数,运营填,作转化率分母(可空)。 member_count: Mapped[int | None] = mapped_column(Integer, nullable=True) status: Mapped[str] = mapped_column(String(20), nullable=False, default="active") # active | archived remark: Mapped[str | None] = mapped_column(String(256), nullable=True) created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), server_default=func.now(), nullable=False ) def __repr__(self) -> str: # pragma: no cover return f""