32d04d7008
代码 review(本分支未提交 WIP)发现并修复: - 高: enable_notification 可重复领取的发放是无锁读-算-写,并发/连点会算出同一序号 双倍发钱。给 coin_transaction 加 (user_id,biz_type,ref_id) 部分唯一索引(仅 task_*), claim 撞唯一约束→IntegrityError 回滚兜底成 AlreadyClaimedError(409),不双发。 配套 alembic 迁移 coin_txn_task_ref_uq(挂 head=drop_force_onboarding)。 - 中: 加领取封顶 rewards.notification_max_claims(减半到底=1 后不再可领),挡通知一直关着 时无限刷 1 金币;列表领满后 claimed 置 True 供客户端隐藏。 - 中: _notification_grant_times 改只数 amount>0 流水,避免日后冲正/负向流水把次数算大。 - 低: 合并 ops_marquee._nickname 两个一字不差的重复分支。 - 文档: tasks-list / tasks-claim 补可重复领取/逐次减半/409 语义。 - 测试: 新增「领满到底→409 + claimed=True」用例;test_welfare 全绿(3 个 proxy 失败 为 pre-existing httpx mock 问题,与本次无关)。 注: review 标的「do_signin 未归一化老 cycle_day」经验算为非 bug(x%LEN+1 对越界值 本就周期正确,且与 get_status 预览公式恒等),未改。 含本分支签到7天改制/任务文案/膨胀金币等 WIP。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
69 lines
3.3 KiB
Python
69 lines
3.3 KiB
Python
"""运营可配置项注册表:默认值(= 原 rewards 常量)+ 元信息(label/group/type)。
|
|
|
|
配置项的 single source of truth:
|
|
- 业务读配置时 fallback 到这里的 default(空 DB = 原行为不变)。
|
|
- admin 配置页用它展示"有哪些可配项 + 当前值 + 默认值 + 说明"。
|
|
新增可配项 = 这里加一条 + 业务处改用 app_config.get_value(db, key) 读。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from app.core import rewards as r
|
|
|
|
# type 约定(给前端渲染编辑控件用):int / int_list / dict_str_int
|
|
CONFIG_DEFS: dict[str, dict[str, Any]] = {
|
|
"signin_rewards": {
|
|
"default": list(r.SIGNIN_REWARDS), "label": "签到 7 天金币档位",
|
|
"group": "签到", "type": "int_list",
|
|
"help": "第 1~7 天每天签到发的金币;断签重置回第 1 天。长度需为 7。",
|
|
},
|
|
"min_exchange_coin": {
|
|
"default": r.MIN_EXCHANGE_COIN, "label": "最低兑换金币",
|
|
"group": "钱包", "type": "int", "help": "金币兑现金的单次最低金币(10000 金币=1 元)。",
|
|
},
|
|
"withdraw_min_cents": {
|
|
"default": r.WITHDRAW_MIN_CENTS, "label": "提现最低额(分)",
|
|
"group": "钱包", "type": "int", "help": "单次提现最低;微信商家转账最低 10 分(0.1 元)。",
|
|
},
|
|
"withdraw_max_cents": {
|
|
"default": r.WITHDRAW_MAX_CENTS, "label": "提现最高额(分)",
|
|
"group": "钱包", "type": "int",
|
|
},
|
|
"task_rewards": {
|
|
"default": dict(r.TASK_REWARDS), "label": "一次性任务奖励",
|
|
"group": "任务", "type": "dict_str_int", "help": "task_key → 金币。",
|
|
},
|
|
"record_milestones": {
|
|
"default": list(r.RECORD_MILESTONES), "label": "比价里程碑金币档位",
|
|
"group": "里程碑", "type": "int_list",
|
|
"help": "累计成功比价第 1~N 档解锁发的金币。",
|
|
},
|
|
"ad_reward_coin": {
|
|
"default": r.AD_REWARD_COIN, "label": "看广告单次金币",
|
|
"group": "看广告", "type": "int",
|
|
"help": "历史兼容/测试展示值;正式发放按 eCPM 公式计算。",
|
|
},
|
|
"ad_daily_limit": {
|
|
"default": r.DAILY_AD_REWARD_LIMIT, "label": "看广告每日上限(次)",
|
|
"group": "看广告", "type": "int", "help": "福利页激励视频每日可发奖次数上限,默认 500。",
|
|
},
|
|
"ad_max_coin": {
|
|
"default": r.MAX_AD_REWARD_COIN, "label": "看广告单次金币上限",
|
|
"group": "看广告", "type": "int", "help": "历史 reward_amount 口径保留项;正式发放按 eCPM 公式计算。",
|
|
},
|
|
"ad_round_count": {
|
|
"default": r.VIDEO_ROUND_REQUIRED_COUNT, "label": "每轮看广告次数",
|
|
"group": "看广告", "type": "int", "help": "当前为 1,表示每次广告关闭后触发短冷却。",
|
|
},
|
|
"ad_cooldown_sec": {
|
|
"default": r.VIDEO_ROUND_COOLDOWN_SECONDS, "label": "广告关闭后冷却(秒)",
|
|
"group": "看广告", "type": "int", "help": "点击退出广告后,下次点击观看前的冷却时间,默认 3 秒。",
|
|
},
|
|
"signin_boost_coin": {
|
|
"default": r.SIGNIN_BOOST_COIN, "label": "签到膨胀固定金币",
|
|
"group": "签到", "type": "int",
|
|
"help": "Day1-Day6 签到后看完激励视频额外发放的固定金币;Day7 不展示也不允许膨胀。",
|
|
},
|
|
}
|