feat(admin): 首页门面数字保底/护栏 + 轮播种子真实化与批量 + 比价记录索引 (#42)

- ops_stat: 真实值 offset→保底(max);初始基数过只增不减护栏
- ops_marquee: 脱敏名手机尾号+中文昵称混合;金额长尾;时间随机抖动;真实+种子不足兜底补满;真实记录查询 ~30s 缓存
- comparison_record: 复合索引 (status, created_at) + 迁移(PG CONCURRENTLY);修复 alembic 多 head(merge 改挂 onboarding_completion)
- 轮播种子批量删除/启用接口 + ids 上限;docs 同步
- 附带并行会话 WIP:admin users / wallet

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: OuYingJun1024 <1034284404@qq.com>
Reviewed-on: #42
Co-authored-by: ouzhou <ouzhou@wonderable.ai>
Co-committed-by: ouzhou <ouzhou@wonderable.ai>
This commit was merged in pull request #42.
This commit is contained in:
ouzhou
2026-06-10 22:26:51 +08:00
committed by marco
parent a753843804
commit db399a40fa
20 changed files with 399 additions and 66 deletions
+31
View File
@@ -129,6 +129,37 @@ def grant_coins(
return acc, txn
def grant_cash(
db: Session,
user_id: int,
amount_cents: int,
*,
biz_type: str,
ref_id: str | None = None,
remark: str | None = None,
) -> tuple[CoinAccount, CashTransaction]:
"""现金变动入口(正数入账 / 负数出账)。更新现金余额 + 写流水,不 commit。
与 [grant_coins] 同模式(运营手动调现金 / 测试发现金用)。返回 (account, transaction),
调用方负责 commit。不在此校验扣成负——由调用方(admin router)按业务保护。
"""
acc = get_or_create_account(db, user_id, commit=False)
acc.cash_balance_cents += amount_cents
txn = CashTransaction(
user_id=user_id,
amount_cents=amount_cents,
balance_after_cents=acc.cash_balance_cents,
biz_type=biz_type,
ref_id=ref_id,
remark=remark,
created_at=datetime.now(rewards.CN_TZ).replace(tzinfo=None), # 存北京 wall-clock
)
db.add(txn)
db.flush()
return acc, txn
def list_coin_transactions(
db: Session,
user_id: int,