45 lines
2.4 KiB
Go
45 lines
2.4 KiB
Go
|
|
package model
|
||
|
|
|
||
|
|
import "time"
|
||
|
|
|
||
|
|
type UserBalance struct {
|
||
|
|
UserID string `gorm:"column:user_id;primaryKey;size:50" json:"userId"`
|
||
|
|
Balance float64 `gorm:"column:balance;type:decimal(10,2);default:0" json:"balance"`
|
||
|
|
TotalRecharged float64 `gorm:"column:total_recharged;type:decimal(10,2);default:0" json:"totalRecharged"`
|
||
|
|
TotalGifted float64 `gorm:"column:total_gifted;type:decimal(10,2);default:0" json:"totalGifted"`
|
||
|
|
TotalRefunded float64 `gorm:"column:total_refunded;type:decimal(10,2);default:0" json:"totalRefunded"`
|
||
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func (UserBalance) TableName() string { return "user_balances" }
|
||
|
|
|
||
|
|
type BalanceTransaction struct {
|
||
|
|
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||
|
|
UserID string `gorm:"column:user_id;size:50;index" json:"userId"`
|
||
|
|
Type string `gorm:"column:type;size:20" json:"type"`
|
||
|
|
Amount float64 `gorm:"column:amount;type:decimal(10,2)" json:"amount"`
|
||
|
|
BalanceAfter float64 `gorm:"column:balance_after;type:decimal(10,2)" json:"balanceAfter"`
|
||
|
|
RelatedOrder *string `gorm:"column:related_order;size:50" json:"relatedOrder,omitempty"`
|
||
|
|
TargetUserID *string `gorm:"column:target_user_id;size:50" json:"targetUserId,omitempty"`
|
||
|
|
SectionID *string `gorm:"column:section_id;size:50" json:"sectionId,omitempty"`
|
||
|
|
Description string `gorm:"column:description;size:200" json:"description"`
|
||
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func (BalanceTransaction) TableName() string { return "balance_transactions" }
|
||
|
|
|
||
|
|
type GiftUnlock struct {
|
||
|
|
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||
|
|
GiftCode string `gorm:"column:gift_code;uniqueIndex;size:32" json:"giftCode"`
|
||
|
|
GiverID string `gorm:"column:giver_id;size:50;index" json:"giverId"`
|
||
|
|
SectionID string `gorm:"column:section_id;size:50" json:"sectionId"`
|
||
|
|
ReceiverID *string `gorm:"column:receiver_id;size:50" json:"receiverId,omitempty"`
|
||
|
|
Amount float64 `gorm:"column:amount;type:decimal(10,2)" json:"amount"`
|
||
|
|
Status string `gorm:"column:status;size:20;default:pending" json:"status"`
|
||
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||
|
|
RedeemedAt *time.Time `gorm:"column:redeemed_at" json:"redeemedAt,omitempty"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func (GiftUnlock) TableName() string { return "gift_unlocks" }
|