bb58fb2a29
按"一表一文件"建库表文档(协作规范第 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>
27 lines
1.2 KiB
Markdown
27 lines
1.2 KiB
Markdown
# cash_transaction — 现金流水账本(分)
|
|
|
|
> 模型 `app/models/wallet.py` | 关联接口 [wallet-cash-transactions](../api/wallet-cash-transactions.md) | [← 表索引](./README.md)
|
|
|
|
现金每次变动一笔流水(单位:分)。金币兑现金、提现、提现退款都记这里。
|
|
|
|
## 字段
|
|
| 列 | 类型 | 约束 / 默认 | 说明 |
|
|
|---|---|---|---|
|
|
| `id` | Integer | PK, autoincrement | |
|
|
| `user_id` | Integer | FK→user.id, index, NOT NULL | 归属用户 |
|
|
| `amount_cents` | Integer | NOT NULL | 正=入账(兑入),负=出账(提现) |
|
|
| `balance_after_cents` | Integer | NOT NULL | 本笔变动后现金余额(分) |
|
|
| `biz_type` | String(32) | NOT NULL | `exchange_in`(兑入)/ `withdraw`(提现出账)/ `withdraw_refund`(提现退回) |
|
|
| `ref_id` | String(64) | nullable | 关联业务 id(如提现 `out_bill_no`) |
|
|
| `remark` | String(128) | nullable | 用户可见备注(如"提现未成功,金额已退回") |
|
|
| `created_at` | DateTime(tz) | server_default now(), index | 时间 |
|
|
|
|
## 索引与约束
|
|
- PK: `id`;index: `user_id`、`created_at`
|
|
|
|
## 关系
|
|
- `user_id` → `user.id`(多对一)
|
|
|
|
## 说明
|
|
- 提现失败/取消退款写 `withdraw_refund`(+X);退款流水 `remark` 是用户可见文案,技术原因记在 `withdraw_order.fail_reason`。
|