feat(invite): 好友列表已比价状态 + DEV 造虚拟好友接口; fix(deploy): 每日兑换定时器锁北京时区 (#104)
## 改动概述 本 PR 含两个主题(关联 7-1 邀请页 / 兑换时区工作)。 ### 1. 邀请好友列表「已比价」状态 - `get_invitees` 返回新增 `is_compared` 字段(= `compare_reward_granted`)。 客户端据此区分好友列表「去提醒 / 邀请成功」、在途列表只取未比价、算在途好友数与在途收益。 - 新增开发接口 `POST/DELETE /invite/seed-fake`(仅非生产, `is_prod` 挡 404): 造未比价 + 已比价虚拟好友, 已比价者走真实入账发 2 元邀请奖励金, 方便真机联调在途 / 好友列表 UI; 清理时原路退回, 不留脏账。 ### 2. 每日兑换定时器时区修复 - `deploy/daily-exchange.service` / `.timer` 锁定 `Asia/Shanghai`, 避免按服务器本地时区在错误时刻触发每日兑换(此前隐患: worker 已用 cn_today, 但 systemd timer 仍按服务器本地时区)。 - 新增 `test_daily_exchange_timezone` 覆盖同一北京日内幂等。 ## 测试 - 邀请 + 兑换时区相关用例全过(`28 passed`)。 - 说明: 仓库预存的 3 个 proxy 转发测试(`test_compare_proxy` / `test_coupon_proxy`)失败, 已在干净 HEAD 上复现确认与本改动无关, 不在本 PR 处理范围。 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: no_gen_mu <liujianhishen@gmail.com> Reviewed-on: #104 Co-authored-by: liujiahui <liujiahui@wonderable.ai> Co-committed-by: liujiahui <liujiahui@wonderable.ai>
This commit was merged in pull request #104.
This commit is contained in:
@@ -122,6 +122,57 @@ def my_invitees(
|
||||
)
|
||||
|
||||
|
||||
@router.post("/seed-fake", summary="[DEV] 给自己塞虚拟好友(测在途/好友列表 UI,仅非生产)")
|
||||
def seed_fake_invitees(
|
||||
user: CurrentUser, db: DbSession, pending: int = 3, compared: int = 2
|
||||
) -> dict:
|
||||
"""造 pending 个未比价 + compared 个已比价的虚拟好友。生产环境(is_prod)直接 404。
|
||||
|
||||
未比价 → 上"在途列表 / 好友列表去提醒";已比价 → 好友列表"邀请成功"、并发真实邀请奖励金
|
||||
(可提现余额/累计提现也有数)。清理见 DELETE /seed-fake。
|
||||
"""
|
||||
if settings.is_prod:
|
||||
from fastapi import HTTPException
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
n = invite_repo.seed_fake_invitees(db, user.id, pending=max(0, pending), compared=max(0, compared))
|
||||
return {"status": "ok", "created": n, "pending": pending, "compared": compared}
|
||||
|
||||
|
||||
@router.delete("/seed-fake", summary="[DEV] 清掉自己的虚拟好友(仅非生产)")
|
||||
def clear_fake_invitees(user: CurrentUser, db: DbSession) -> dict:
|
||||
if settings.is_prod:
|
||||
from fastapi import HTTPException
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
n = invite_repo.clear_fake_invitees(db, user.id)
|
||||
return {"status": "ok", "removed": n}
|
||||
|
||||
|
||||
@router.post("/dev-reset", summary="[DEV] 把固定测试号打回出厂态,便于反复当新用户测发奖(仅非生产)")
|
||||
def dev_reset(db: DbSession) -> dict:
|
||||
"""把 TEST_ACCOUNT_PHONE 这个固定测试号清成"从没被邀请/没下过单"的新用户态。
|
||||
|
||||
⚠️ 无需鉴权(它只按配置里的测试号操作,不依赖登录态,方便测试脚本第一步直接调)。
|
||||
双重门控:生产环境(is_prod)404;测试号总开关(TEST_ACCOUNT_PHONE)没配置 → 400。
|
||||
故它永远只能动那一个配置好的测试号,动不了任意真实用户。
|
||||
|
||||
清什么见 repositories/invite.dev_reset_test_account(全清 + 刷 created_at 骗过 72h 闸)。
|
||||
调完该测试号即可再次绑定 + 下单上报,重新触发一次邀请发奖。
|
||||
"""
|
||||
from fastapi import HTTPException
|
||||
|
||||
if settings.is_prod:
|
||||
raise HTTPException(status_code=404, detail="Not Found")
|
||||
phone = settings.test_account_phone
|
||||
if not phone:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="测试号未启用:请在 .env 配 TEST_ACCOUNT_PHONE=11111111111 并重启服务",
|
||||
)
|
||||
cleared = invite_repo.dev_reset_test_account(db, phone)
|
||||
logger.info("invite dev-reset phone=%s cleared=%s", phone, cleared)
|
||||
return {"status": "ok", "phone": phone, "cleared": cleared}
|
||||
|
||||
|
||||
@router.post(
|
||||
"/landing-track",
|
||||
response_model=LandingTrackOut,
|
||||
|
||||
Reference in New Issue
Block a user