Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05f4d896a3 |
@@ -183,7 +183,15 @@ def coupon_prompt_should_show(
|
|||||||
device_id: str, db: DbSession
|
device_id: str, db: DbSession
|
||||||
) -> CouponPromptShouldShowOut:
|
) -> CouponPromptShouldShowOut:
|
||||||
"""今天这台设备已 engage(领或拒)过 → should_show=false。客户端据此决定弹不弹
|
"""今天这台设备已 engage(领或拒)过 → should_show=false。客户端据此决定弹不弹
|
||||||
(前台 SP 缓存做快速路径,这里是权威)。"""
|
(纯后台判据,客户端不再做前台 SP 缓存判断)。"""
|
||||||
return CouponPromptShouldShowOut(
|
return CouponPromptShouldShowOut(
|
||||||
should_show=not coupon_repo.has_engaged_today(db, device_id)
|
should_show=not coupon_repo.has_engaged_today(db, device_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/prompt/reset", summary="重置今日领券引导窗 engagement(开发测频控用)")
|
||||||
|
def coupon_prompt_reset(payload: CouponPromptDismissIn, db: DbSession) -> dict[str, bool]:
|
||||||
|
"""删这台设备今天的 engagement → has_engaged_today 变 false,今天又能弹。
|
||||||
|
开发设置「重置今日领券弹窗状态」按钮调。MVP 不鉴权,按 device_id。"""
|
||||||
|
coupon_repo.reset_today_engagement(db, payload.device_id)
|
||||||
|
return {"ok": True}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import logging
|
|||||||
from datetime import date, datetime
|
from datetime import date, datetime
|
||||||
from zoneinfo import ZoneInfo
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
from sqlalchemy import select
|
from sqlalchemy import delete, select
|
||||||
from sqlalchemy.exc import IntegrityError
|
from sqlalchemy.exc import IntegrityError
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
@@ -65,6 +65,19 @@ def mark_engagement(
|
|||||||
db.rollback()
|
db.rollback()
|
||||||
|
|
||||||
|
|
||||||
|
def reset_today_engagement(db: Session, device_id: str) -> int:
|
||||||
|
"""删这台设备今天的 engagement(开发设置「重置今日领券弹窗状态」调,测频控用)。
|
||||||
|
删后 has_engaged_today → false,今天又能弹。返回删除行数。"""
|
||||||
|
result = db.execute(
|
||||||
|
delete(CouponPromptEngagement).where(
|
||||||
|
CouponPromptEngagement.device_id == device_id,
|
||||||
|
CouponPromptEngagement.engage_date == today_cn(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
db.commit()
|
||||||
|
return result.rowcount or 0
|
||||||
|
|
||||||
|
|
||||||
# ===== 领券记录(coupon_claim_record)=====
|
# ===== 领券记录(coupon_claim_record)=====
|
||||||
|
|
||||||
def record_claims(
|
def record_claims(
|
||||||
|
|||||||
Reference in New Issue
Block a user