0890e693d7
新增 coupon_daily_completion 表:按 (device_id, 自然日) 记"今天是否已跑完 整轮领券(到 done 帧)"。客户端据此把首页「去领取」卡置灰、不可点。 口径(用户决策 A 方案):到 done 即算,不管单券成败 —— 失败/跳过常是无障碍/ 环境问题,重复点也补不回来。判断维度 device_id,与 engagement/claim 一致。 - model CouponDailyCompletion(uq device+complete_date,仿 CouponPromptEngagement) - repo has_completed_today / mark_completed_today(幂等 upsert + IntegrityError 兜底) - schema CouponCompletedTodayOut(completed: bool) - coupon_step 透传链路在 action.command=="done" 那帧 best-effort 写完成记录 (pricebot 只在整轮全跑完才保留 command=="done",故无需再判 continue) - GET /api/v1/coupon/completed-today?device_id= 供首页查询 - alembic 迁移 coupon_daily_completion(down_revision=0cf18d590b1d 当前 head) 合并后需 alembic upgrade head,否则 /completed-today 500。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: no_gen_mu <liujianhishen@gmail.com> Reviewed-on: #34 Co-authored-by: liujiahui <liujiahui@wonderable.ai> Co-committed-by: liujiahui <liujiahui@wonderable.ai>
28 lines
827 B
Python
28 lines
827 B
Python
"""领券今日状态端点的收发模型。"""
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class CouponPromptDismissIn(BaseModel):
|
|
"""客户端拒绝/关闭领券引导窗的通知体。
|
|
|
|
server 据此记一条今日 engagement(dismissed)→ 今天这台设备不再弹引导窗。
|
|
MVP 不鉴权,按 device_id 判断;user_id 登录态带上就一并记(资产),可空。
|
|
"""
|
|
|
|
device_id: str
|
|
user_id: int | None = None
|
|
|
|
|
|
class CouponPromptShouldShowOut(BaseModel):
|
|
"""切到外卖 App 时是否还应弹领券引导窗。今天已 engage(领或拒)过 → false。"""
|
|
|
|
should_show: bool
|
|
|
|
|
|
class CouponCompletedTodayOut(BaseModel):
|
|
"""这台设备今天是否已跑完整轮领券(到 done 帧)。完成 → 首页「去领取」卡置灰。"""
|
|
|
|
completed: bool
|