app-cloudep-wallet-service/pkg/domain/entity/wallet.go

35 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package entity
import (
"code.30cm.net/digimon/app-cloudep-wallet-service/pkg/domain/wallet"
"github.com/shopspring/decimal"
)
// 🔐 重點設計理念:
// 避免競爭與資金衝突
// 將錢包用途拆分成不同 type避免一個錢包同時處理可用資金與凍結資金降低邏輯錯誤風險。
//
// 資金安全性與追蹤性強
// 分別記錄「凍結」「未確認」「可用」等不同狀態,方便核對資產總額與可提資金。
//
// 合約與模擬隔離
// 保留合約交易與模擬交易專屬錢包,實現清楚的邊界控制與風險隔離。
//
// 多品牌支援
// Brand 欄位讓平台可以支援多租戶架構(不同品牌有不同的錢包群組)。
type Wallet struct {
ID int64 `gorm:"column:id"` // 主鍵 ID錢包的唯一識別
Brand string `gorm:"column:brand"` // 品牌/平台(區分多租戶、多品牌情境)
UID string `gorm:"column:uid"` // 使用者 UID
Asset string `gorm:"column:asset"` // 資產代號,可為 BTC、ETH、GEM_RED、GEM_BLUE、POINTS ,USD, TWD 等....
Balance decimal.Decimal `gorm:"column:balance"` // 餘額(使用高精度 decimal 避免浮點誤差)
Type wallet.Types `gorm:"column:type"` // 錢包類型
CreateTime int64 `gorm:"column:create_time;autoCreateTime"` // 建立時間UnixNano timestamp
UpdateTime int64 `gorm:"column:update_time;autoUpdateTime"` // 更新時間UnixNano timestamp
}
func (c *Wallet) TableName() string {
return "wallet" // 對應的資料表名稱
}