| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- package fixture
- import (
- "database/sql"
- "time"
- )
- // 本文件是**资金域第二批 4 张表**的数据形状(外加解析 t_expenditure_log.expenditure_id
- // 所需的字典表 t_expenditure)。
- //
- // 与上一批的关键差别:这批第一次落地 **biz_no 口径**(旧 UUID 主键 → target int64 自增
- // + `biz_no varchar(32) UNIQUE` 保留旧 UUID)。对齐键因此分三类:
- //
- // 表 legacy 主键 口径 对齐键
- // t_user_divide_into userid int(自然键) 业务键 user_id(ULID)
- // t_user_divide_into_log id int AUTO_INCREMENT D1 id 原样
- // t_user_balance_request id varchar(32) UUID biz_no biz_no = legacy id
- // t_expenditure_log id varchar(32) UUID biz_no biz_no = legacy id
- // t_expenditure(字典) id int AUTO_INCREMENT D1 id 原样(见下表说明)
- //
- // t_expenditure 为什么也做 D1:`t_expenditure_log.expenditureid` 指向它,而它既无旧 UUID
- // 也无业务唯一键(name 不唯一、树结构 parentid 自引用)。要让 expenditure_id 在双跑里可对齐,
- // 只有「字典 id 原样保留」这一条路。目标表当前 0 行、字典 id 是 1..45 连续,D1 安全。
- // ⚠ 这一条属**超出本批 4 表范围的必要补充**,已在报告中标注待拍板。
- // ---------- t_user_divide_into ----------
- // LegacyDivideInto 对应 legacy `t_user_divide_into`(PK userid int,Nested Set 树)。
- type LegacyDivideInto struct {
- UserID int64
- Type int32
- Quota sql.NullString // float(10,2)
- TotalIncome sql.NullString // float(10,2)
- TotalIncomePayed sql.NullString // float(10,2)
- RootUserID sql.NullInt64 // 根节点时 = 自己
- ParentUserID sql.NullInt64 // 根节点时 = 0
- LeftVal int32
- RightVal int32
- Layer int32
- }
- // TargetDivideInto 对应目标 `t_user_divide_into`(自然键 user_id)。
- type TargetDivideInto struct {
- UserID string // canonical ULID
- Type int8
- QuotaCents int64
- TotalIncomeCents int64
- TotalIncomePayedCents int64
- RootUserID sql.NullString // ULID;legacy 0 → NULL
- ParentUserID sql.NullString // ULID;legacy 0(根)→ NULL
- LeftVal int32
- RightVal int32
- Layer int32
- // legacy **无** created_at/updated_at 列;目标表这两列 NOT NULL 且**无默认值**
- // (DDL 文件写了 DEFAULT CURRENT_TIMESTAMP(3),实际库是 GORM AutoMigrate 建的,没有默认值
- // —— 见报告「结构漂移」一节)。因此落 epoch 哨兵,绝不用当前时间。
- CreatedAt time.Time
- UpdatedAt time.Time
- }
- // ---------- t_user_divide_into_log ----------
- // LegacyDivideIntoLog 对应 legacy `t_user_divide_into_log`(PK id int AUTO_INCREMENT → D1)。
- type LegacyDivideIntoLog struct {
- ID int64
- Type int32 // 列类型是 tinyint unsigned zerofill,读出即 1/2
- UserID int64
- StudentID int64
- OrderNo sql.NullString // orderid varchar(50)
- Money sql.NullString // float(10,2)
- CreateTime sql.NullTime
- Remark sql.NullString // text → LONGTEXT
- }
- // TargetDivideIntoLog 对应目标 `t_user_divide_into_log`。
- type TargetDivideIntoLog struct {
- ID int64 // D1:= legacy id
- Type int8
- UserID string
- StudentID string
- OrderNo sql.NullString
- MoneyCents int64
- CreateTime time.Time
- Remark sql.NullString
- }
- // ---------- t_user_balance_request ----------
- // LegacyBalanceRequest 对应 legacy `t_user_balance_request`(PK id varchar(32) UUID → biz_no)。
- type LegacyBalanceRequest struct {
- BizNo string // 旧 UUID 主键(32 位 hex)
- Type int32
- UserID int64
- SchoolID int64
- CampusID int64
- Money sql.NullString // decimal(10,3)
- TransferAccountsType int8
- TransferAccountsTime sql.NullTime
- OrderNo sql.NullString
- RequestUserID int64
- RequestTime sql.NullTime
- ResponseUserID sql.NullInt64 // 0 → NULL
- ResponseTime sql.NullTime
- ResponseMsg sql.NullString
- Aproved int8 // 旧列名错拼,target 修正为 approved
- Item sql.NullString
- Imgs sql.NullString
- Remark sql.NullString
- }
- // TargetBalanceRequest 对应目标 `t_user_balance_request`。
- type TargetBalanceRequest struct {
- ID int64 // target 自增;**与 legacy 无关**
- BizNo string
- Type int32
- UserID string
- InstitutionID int64
- CampusID int64
- ToInstitutionID sql.NullInt64 // legacy 无此列 → NULL
- ToCampusID sql.NullInt64 // legacy 无此列 → NULL
- MoneyCents int64
- TransferAccountsType int8
- TransferAccountsTime sql.NullTime
- OrderNo sql.NullString
- RequestUserID string
- RequestTime time.Time
- ResponseUserID sql.NullString
- ResponseTime sql.NullTime
- ResponseMsg sql.NullString
- Approved int8
- Item sql.NullString
- Imgs sql.NullString
- Remark sql.NullString
- // target 的 created_at/updated_at NOT NULL 且无默认值;由 legacy 真实时间派生:
- // created_at = request_time(工单产生时刻)
- // updated_at = response_time ?? request_time(最后处理时刻)
- CreatedAt time.Time
- UpdatedAt time.Time
- }
- // ---------- t_expenditure_log ----------
- // LegacyExpenditureLog 对应 legacy `t_expenditure_log`(PK id varchar(32) UUID → biz_no)。
- type LegacyExpenditureLog struct {
- BizNo string
- SchoolID int64
- CampusID int64
- ExpenditureID int64 // → t_expenditure.id
- Cost sql.NullString // float(10,3)
- CreateUserID sql.NullInt64 // 0 → NULL
- CreateTime sql.NullTime
- Year sql.NullInt64 // MySQL YEAR 类型
- Month sql.NullInt64
- Remark sql.NullString
- Imgs sql.NullString
- }
- // TargetExpenditureLog 对应目标 `t_expenditure_log`。
- type TargetExpenditureLog struct {
- ID int64
- BizNo string
- InstitutionID int64
- CampusID int64
- ExpenditureID int64
- CostCents int64
- CreateUserID sql.NullString
- CreateTime time.Time
- Year sql.NullInt64
- Month sql.NullInt64
- Remark sql.NullString
- Imgs sql.NullString
- }
- // ---------- t_expenditure(字典,D1) ----------
- // LegacyExpenditure 对应 legacy `t_expenditure`(PK id int AUTO_INCREMENT,自引用树)。
- type LegacyExpenditure struct {
- ID int64
- Type int32
- ParentID int64
- Name string
- Remark sql.NullString
- }
- // TargetExpenditure 对应目标 `t_expenditure`(D1 保留 id)。
- type TargetExpenditure struct {
- ID int64
- Type int32
- ParentID int64
- Name string
- Remark sql.NullString
- InstitutionID int64 // legacy 无此列 → 0(平台通用字典)
- }
|