feat(ad): eCPM 上报接口 + 冷却策略解耦纯函数 + savings JSONB 跨库修复 #8

Merged
marco merged 5 commits from feat/ad-ecpm-and-cooldown into main 2026-06-01 22:23:16 +08:00

5 Commits

Author SHA1 Message Date
OuYingJun1024 9cfe5fc6e6 Merge branch 'main' of https://gitea.shaguabijia.com/WonderableAI/shaguabijia-app-server into feat/ad-ecpm-and-cooldown 2026-06-01 21:42:47 +08:00
OuYingJun1024 8106899bfa chore(ad): 激励视频单次发奖金币 100→666 + 同步测试期望值 2026-06-01 21:11:31 +08:00
OuYingJun1024 bb58fb2a29 docs(database): 新建 docs/database 表文档 — 13 张表全量 + 索引
按"一表一文件"建库表文档(协作规范第 11 条):字段(类型/约束/默认)+
索引与约束 + 关系 + 说明,从 model 的 Mapped 定义扒准。

- README 索引:13 张表总览 + 通用约定(主键/外键/金额分/北京时间日期串/JSONB variant)
- 覆盖 user / coin_account / coin_transaction / cash_transaction / withdraw_order /
  signin_record / user_task / savings_record / ad_reward_record / ad_ecpm_record /
  feedback / comparison_record / comparison_milestone_claim
- savings_record 文档强调"成交省钱"≠"比价行为",与 comparison_record 互不喂数据

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 20:44:54 +08:00
OuYingJun1024 15dcfa604b feat(compare): 比价记录落库 + 战绩里程碑(真发金币)
- comparison_record 表 + 上报(幂等 user+trace)/列表/详情 接口;服务端派生
  best/saved/is_source_best/status + information(done 帧文案/失败具体原因)
- 战绩里程碑:comparison_milestone_claim 表 + 进度/领取接口,按成功比价次数
  解锁,复用 grant_coins 真发金币(RECORD_MILESTONES 120/180/300/500/800/1200)
- 迁移 record/information/milestone 三个,单 head;rewards.py 集中档位配置
- 测试 test_compare_record(8)+test_compare_milestone(7) 全绿;docs/api 12a-12e + 索引

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 19:56:47 +08:00
OuYingJun1024 eb5f0dc460 feat(ad): eCPM 上报接口 + 冷却策略解耦纯函数 + savings JSONB 跨库修复
- 新增 POST /api/v1/ad/ecpm-report:激励视频展示后客户端上报本次 eCPM,落 ad_ecpm_record 做内部收益统计(model/repository/schema/alembic 迁移 + 接口文档)
- 看广告冷却策略抽到 app/core/ad_cooldown.py 纯函数;ad_reward.today_status 只取数据,换策略只改这一处
- savings.dishes 改 JSON().with_variant(JSONB,"postgresql"):SQLite 无 visit_JSONB 会让 create_all 编译崩,修复后测试套件恢复

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-31 14:52:01 +08:00