- 所有 Model 添加对应的 *Cent int64 字段 - 旧的 float64 字段保留但不输出到 JSON (json:"-") - 涉及文件:user.go, listing.go, order.go, order_checkout.go, wallet.go, withdrawal.go - 目标:为后续业务逻辑切换到分存储做准备 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
41 lines
1.8 KiB
Go
41 lines
1.8 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
type WalletAccount struct {
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
UserID uint64 `gorm:"not null;uniqueIndex" json:"user_id"`
|
|
AvailableBalance float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
|
|
AvailableBalanceCent int64 `gorm:"not null;default:0" json:"-"`
|
|
FrozenBalance float64 `gorm:"type:decimal(12,2);not null;default:0" json:"-"`
|
|
FrozenBalanceCent int64 `gorm:"not null;default:0" json:"-"`
|
|
Status string `gorm:"size:32;not null;default:'active'" json:"status"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (WalletAccount) TableName() string {
|
|
return "wallet_accounts"
|
|
}
|
|
|
|
type WalletLedger struct {
|
|
ID uint64 `gorm:"primaryKey" json:"id"`
|
|
LedgerNo string `gorm:"size:64;not null;uniqueIndex" json:"ledger_no"`
|
|
UserID uint64 `gorm:"not null;index" json:"user_id"`
|
|
OrderID *uint64 `json:"order_id"`
|
|
Direction string `gorm:"size:16;not null" json:"direction"`
|
|
Amount float64 `gorm:"type:decimal(12,2);not null" json:"-"`
|
|
AmountCent int64 `gorm:"not null;default:0" json:"-"`
|
|
BalanceAfter float64 `gorm:"type:decimal(12,2);not null" json:"-"`
|
|
BalanceAfterCent int64 `gorm:"not null;default:0" json:"-"`
|
|
BalanceType string `gorm:"size:32;not null" json:"balance_type"`
|
|
BizType string `gorm:"size:32;not null" json:"biz_type"`
|
|
BizNo string `gorm:"size:64;not null" json:"biz_no"`
|
|
Remark string `gorm:"size:255;not null;default:''" json:"remark"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
func (WalletLedger) TableName() string {
|
|
return "wallet_ledger"
|
|
}
|