277f9b16a2
群(sid)/活动池/转链(带sid)/美团 query_order 按 sid 对账/按群统计;
短链 /c/{code} 记点击(PV/UV)→302 跳美团,点击→下单漏斗。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
"""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<id>)。字母+数字,≤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"<CpsGroup id={self.id} sid={self.sid!r} name={self.name!r}>"
|