Files
shaguabijia-app-server/docs/database/signin_record.md
T
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

27 lines
1.3 KiB
Markdown

# signin_record — 签到记录(7 天循环)
> 模型 `app/models/signin.py` | 关联接口 [signin-status](../api/signin-status.md) / [signin-do](../api/signin-do.md) | [← 表索引](./README.md)
每次签到一行,`(user_id, signin_date)` 唯一,天然防一天签两次。`cycle_day`(1..7)决定发多少金币(`rewards.SIGNIN_REWARDS`),断签重置回 1;`streak` 是连续签到天数(不封顶)用于展示。
## 字段
| 列 | 类型 | 约束 / 默认 | 说明 |
|---|---|---|---|
| `id` | Integer | PK, autoincrement | |
| `user_id` | Integer | FK→user.id, index, NOT NULL | 归属用户 |
| `signin_date` | Date | NOT NULL | 签到日期(北京时间 date) |
| `cycle_day` | Integer | NOT NULL | 7 天循环里今天第几档(1..7),决定发币 |
| `streak` | Integer | NOT NULL | 连续签到天数(不封顶) |
| `coin_awarded` | Integer | NOT NULL | 本次发放金币 |
| `created_at` | DateTime(tz) | server_default now() | 时间 |
## 索引与约束
- PK: `id`;index: `user_id`
- UNIQUE(`user_id`, `signin_date`) = `uq_signin_user_date`(防一天签两次)
## 关系
- `user_id``user.id`(多对一)
## 说明
- 签到"今天"按北京时间 `cn_today()`(`CN_TZ=UTC+8`);发币与写本表记录同事务(`grant_coins(biz_type='signin', ref_id=日期)`)。