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

32 lines
2.4 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"
)
// Transaction 代表一筆錢包交易紀錄(例如充值、扣款、轉帳等)
// 此表記錄所有交易的詳細資訊,包括金額、對象、餘額狀態與交易型態等
type Transaction struct {
ID int64 `gorm:"column:id"` // 交易主鍵 ID,自動遞增
OrderID string `gorm:"column:order_id"` // 關聯的訂單 ID,可為空(若不是由訂單觸發)
TransactionID string `gorm:"column:transaction_id"` // 此筆交易的唯一識別碼(系統內部使用,可為 UUID)
Brand string `gorm:"column:brand"` // 所屬品牌(支援多品牌場景)
UID string `gorm:"column:uid"` // 交易發起者的 UID
ToUID string `gorm:"column:to_uid"` // 交易對象的 UID(如為轉帳場景)
TxType wallet.TxType `gorm:"column:type"` // 交易類型(如轉帳、入金、出金等,自定義列舉)
BusinessType int8 `gorm:"column:business_type"` // 業務類型(如合約、模擬、一般用途等,數字代碼)
Asset string `gorm:"column:asset"` // 幣種(如 BTC、ETH、USD、TWD 等)
Amount decimal.Decimal `gorm:"column:amount"` // 本次變動金額(正數為增加,負數為扣減)
PostTransferBalance decimal.Decimal `gorm:"column:post_transfer_balance"` // 交易完成後的錢包餘額
BeforeBalance decimal.Decimal `gorm:"column:before_balance"` // 交易前的錢包餘額(方便審計與對帳)
Status wallet.Enable `gorm:"column:status"` // 狀態(1: 有效、0: 無效/已取消)
CreateAt int64 `gorm:"column:create_time;autoCreateTime"` // 建立時間(Unix 秒數)
DueTime int64 `gorm:"column:due_time"` // 到期時間(適用於凍結或延後入帳等場景)
}
// TableName 指定 GORM 對應的資料表名稱
func (t *Transaction) TableName() string {
return "transaction"
}