35 lines
1.6 KiB
Go
35 lines
1.6 KiB
Go
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"` // 錢包類型
|
||
CreateAt int64 `gorm:"column:create_at"` // 建立時間(UnixNano timestamp)
|
||
UpdateAt int64 `gorm:"column:update_at"` // 更新時間(UnixNano timestamp)
|
||
}
|
||
|
||
func (c *Wallet) TableName() string {
|
||
return "wallet" // 對應的資料表名稱
|
||
}
|