- 完善 GORM 模型规范:货币字段使用 int64(分为单位)、JSONB 字段规范、模型结构规范 - 修复所有 IoT 模型的架构违规问题 - 更新 CLAUDE.md 开发指南,补充完整的数据库设计规范和模型示例 - 添加数据库迁移脚本(000006)用于架构重构 - 归档 OpenSpec 变更文档(2026-01-12-fix-iot-models-violations) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
69 lines
3.9 KiB
Go
69 lines
3.9 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/datatypes"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// CommissionWithdrawalRequest 佣金提现申请模型
|
|
// 代理佣金提现申请、审批流程、提现记录查询
|
|
type CommissionWithdrawalRequest struct {
|
|
gorm.Model
|
|
BaseModel `gorm:"embedded"`
|
|
AgentID uint `gorm:"column:agent_id;index;not null;comment:代理用户ID" json:"agent_id"`
|
|
Amount int64 `gorm:"column:amount;type:bigint;not null;comment:提现金额(分为单位)" json:"amount"`
|
|
Fee int64 `gorm:"column:fee;type:bigint;default:0;comment:手续费(分为单位)" json:"fee"`
|
|
ActualAmount int64 `gorm:"column:actual_amount;type:bigint;comment:实际到账金额(分为单位)" json:"actual_amount"`
|
|
WithdrawalMethod string `gorm:"column:withdrawal_method;type:varchar(20);comment:提现方式 alipay-支付宝 wechat-微信 bank-银行卡" json:"withdrawal_method"`
|
|
AccountInfo datatypes.JSON `gorm:"column:account_info;type:jsonb;comment:收款账户信息(姓名、账号等)" json:"account_info"`
|
|
Status int `gorm:"column:status;type:int;default:1;comment:状态 1-待审核 2-已通过 3-已拒绝 4-已到账" json:"status"`
|
|
ApprovedBy uint `gorm:"column:approved_by;index;comment:审批人用户ID" json:"approved_by"`
|
|
ApprovedAt *time.Time `gorm:"column:approved_at;comment:审批时间" json:"approved_at"`
|
|
PaidAt *time.Time `gorm:"column:paid_at;comment:到账时间" json:"paid_at"`
|
|
RejectReason string `gorm:"column:reject_reason;type:text;comment:拒绝原因" json:"reject_reason"`
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (CommissionWithdrawalRequest) TableName() string {
|
|
return "tb_commission_withdrawal_request"
|
|
}
|
|
|
|
// CommissionWithdrawalSetting 佣金提现设置模型
|
|
// 提现参数配置(最低金额、手续费率、到账时间等)
|
|
type CommissionWithdrawalSetting struct {
|
|
gorm.Model
|
|
BaseModel `gorm:"embedded"`
|
|
MinWithdrawalAmount int64 `gorm:"column:min_withdrawal_amount;type:bigint;comment:最低提现金额(分为单位)" json:"min_withdrawal_amount"`
|
|
FeeRate int64 `gorm:"column:fee_rate;type:bigint;comment:手续费率(万分比,如100表示1%)" json:"fee_rate"`
|
|
ArrivalDays int `gorm:"column:arrival_days;type:int;comment:到账天数" json:"arrival_days"`
|
|
IsActive bool `gorm:"column:is_active;type:boolean;default:true;comment:是否生效(最新一条)" json:"is_active"`
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (CommissionWithdrawalSetting) TableName() string {
|
|
return "tb_commission_withdrawal_setting"
|
|
}
|
|
|
|
// PaymentMerchantSetting 收款商户设置模型
|
|
// 配置支付参数(支付宝、微信等收款账户)
|
|
type PaymentMerchantSetting struct {
|
|
gorm.Model
|
|
BaseModel `gorm:"embedded"`
|
|
UserID uint `gorm:"column:user_id;index;not null;comment:用户ID" json:"user_id"`
|
|
MerchantType string `gorm:"column:merchant_type;type:varchar(20);comment:商户类型 alipay-支付宝 wechat-微信 bank-银行卡" json:"merchant_type"`
|
|
AccountName string `gorm:"column:account_name;type:varchar(255);comment:账户名称" json:"account_name"`
|
|
AccountNumber string `gorm:"column:account_number;type:varchar(255);comment:账号" json:"account_number"`
|
|
BankName string `gorm:"column:bank_name;type:varchar(255);comment:银行名称(仅银行卡)" json:"bank_name"`
|
|
BankBranch string `gorm:"column:bank_branch;type:varchar(255);comment:开户行(仅银行卡)" json:"bank_branch"`
|
|
IsVerified bool `gorm:"column:is_verified;type:boolean;default:false;comment:是否已验证" json:"is_verified"`
|
|
IsDefault bool `gorm:"column:is_default;type:boolean;default:false;comment:是否默认账户" json:"is_default"`
|
|
Status int `gorm:"column:status;type:int;default:1;comment:状态 1-启用 2-禁用" json:"status"`
|
|
}
|
|
|
|
// TableName 指定表名
|
|
func (PaymentMerchantSetting) TableName() string {
|
|
return "tb_payment_merchant_setting"
|
|
}
|