c9578f5ba2
轮播 feed(marquee_seed,全新): - 新增 marquee_seed 表 + admin CRUD/批量生成/预览;真实比价记录(success 且 0<省额≤300元、按 user 去重)优先,种子兜底混播 - 种子为「生成规则」:用户名可空(空则按脱敏格式随机合成、避开同屏撞名),金额改 [min,max] 区间随机,feed 公平随机抽取(不看 sort_order) - 新增 GET /api/v1/platform/savings-feed(无鉴权);展示时间统一刷新为相对当前的最近时刻 三统计配置(platform_stat_display)增强: - 自增长新增「绝对增量」方式(random_kind=add,每周期 +[step_min,step_max]) - 真实值模式加基数偏移(real_offset,展示=真实+偏移) - 只增不减护栏(allow_decrease 默认关,real/manual 不回退防门面缩水) - 累计节省 real 口径只计 0<单条≤300元防虚高;倍率上限 5.0→1.5;PATCH 支持 apply_now 立即更新 迁移:marquee_seed_table / marquee_seed_range / platform_stat_growth_offset(均可逆,已验证) 文档:API/DB 对应文档同步更新 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49 lines
1.9 KiB
Python
49 lines
1.9 KiB
Python
"""admin 首页三统计展示配置 schemas。
|
|
|
|
倍率用千分比整数(1.000→1000);total_saved 的 manual_value / random_current 单位是分。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class PlatformStatItemOut(BaseModel):
|
|
metric: str # help_users / total_compares / total_saved
|
|
label: str # 帮助用户 / 完成比价 / 累计节省
|
|
unit: str # 人 / 次 / 分
|
|
mode: str # real / manual / random
|
|
manual_value: int | None = None
|
|
random_mult_min: int
|
|
random_mult_max: int
|
|
random_tick_seconds: int
|
|
random_anchor_minutes: int
|
|
random_kind: str # mult(×倍率) / add(+绝对增量)
|
|
random_step_min: int # 绝对增量区间(基础单位;total_saved 为分)
|
|
random_step_max: int
|
|
real_offset: int # 真实值模式基数偏移(基础单位)
|
|
allow_decrease: bool # 是否允许展示值下降(默认 false = 只增不减)
|
|
random_current: int | None = None
|
|
random_last_tick_at: str | None = None
|
|
real_value: int # 当前真实值(纯真实、不含偏移;给运营对比参考)
|
|
updated_at: str | None = None
|
|
|
|
|
|
class PlatformStatUpdateRequest(BaseModel):
|
|
"""改某指标配置(均可选,只改传了的字段)。"""
|
|
|
|
mode: str | None = None
|
|
manual_value: int | None = None
|
|
random_mult_min: int | None = None
|
|
random_mult_max: int | None = None
|
|
random_tick_seconds: int | None = None
|
|
random_anchor_minutes: int | None = None
|
|
random_kind: str | None = None # mult / add
|
|
random_step_min: int | None = None
|
|
random_step_max: int | None = None
|
|
real_offset: int | None = None
|
|
allow_decrease: bool | None = None
|
|
# 切 random 时的初始基数;不传则用当前真实值播种
|
|
random_initial: int | None = None
|
|
# 立即更新:不等更新钟点,保存后马上把展示值刷新一次(real 快照/manual 生效/random 走一档)
|
|
apply_now: bool = False
|