基本功能复刻完成
This commit is contained in:
71
internal/model/gift_card.go
Normal file
71
internal/model/gift_card.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package model
|
||||
|
||||
// GiftCardTemplate represents a template for generating gift cards with specific rewards and conditions.
|
||||
type GiftCardTemplate struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
Name string `gorm:"size:255;not null" json:"name"`
|
||||
Description string `gorm:"type:text" json:"description"`
|
||||
Type int `gorm:"not null;default:1" json:"type"` // 1: General, 2: Plan, 3: Mystery
|
||||
Status bool `gorm:"not null;default:true" json:"status"`
|
||||
Conditions string `gorm:"type:text" json:"conditions"` // JSON: New user only, allowed plans, etc.
|
||||
Rewards string `gorm:"type:text" json:"rewards"` // JSON: Balance, data, time, etc.
|
||||
Limits string `gorm:"type:text" json:"limits"` // JSON: Max usage per user, cooldown, etc.
|
||||
SpecialConfig string `gorm:"type:text" json:"special_config"` // JSON: Festival bonuses, etc.
|
||||
Icon string `gorm:"size:255" json:"icon"`
|
||||
BackgroundImage string `gorm:"size:255" json:"background_image"`
|
||||
ThemeColor string `gorm:"size:50;default:'#6366f1'" json:"theme_color"`
|
||||
Sort int `gorm:"not null;default:0" json:"sort"`
|
||||
AdminID int `gorm:"not null" json:"admin_id"`
|
||||
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (GiftCardTemplate) TableName() string {
|
||||
return "v2_gift_card_template"
|
||||
}
|
||||
|
||||
// GiftCardCode represents an individual exchangeable code generated from a template.
|
||||
type GiftCardCode struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
TemplateID int `gorm:"not null;index" json:"template_id"`
|
||||
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
|
||||
BatchID string `gorm:"size:64;index" json:"batch_id"`
|
||||
Status int `gorm:"not null;default:0" json:"status"` // 0: Unused, 1: Used, 2: Expired, 3: Disabled
|
||||
UserID *int `gorm:"index" json:"user_id"` // The user who used it
|
||||
UsedAt *int64 `json:"used_at"`
|
||||
ExpiresAt *int64 `gorm:"index" json:"expires_at"`
|
||||
ActualRewards string `gorm:"type:text" json:"actual_rewards"` // JSON: Rewards actually given (can differ from template)
|
||||
UsageCount int `gorm:"not null;default:0" json:"usage_count"`
|
||||
MaxUsage int `gorm:"not null;default:1" json:"max_usage"`
|
||||
Metadata string `gorm:"type:text" json:"metadata"` // JSON: Extra data
|
||||
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
|
||||
Template *GiftCardTemplate `gorm:"foreignKey:TemplateID" json:"template"`
|
||||
}
|
||||
|
||||
func (GiftCardCode) TableName() string {
|
||||
return "v2_gift_card_code"
|
||||
}
|
||||
|
||||
// GiftCardUsage tracks every instance of a gift card being redeemed.
|
||||
type GiftCardUsage struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
CodeID int `gorm:"not null;index" json:"code_id"`
|
||||
TemplateID int `gorm:"not null;index" json:"template_id"`
|
||||
UserID int `gorm:"not null;index" json:"user_id"`
|
||||
InviteUserID *int `gorm:"index" json:"invite_user_id"`
|
||||
RewardsGiven string `gorm:"type:text" json:"rewards_given"` // JSON
|
||||
InviteRewards string `gorm:"type:text" json:"invite_rewards"` // JSON
|
||||
UserLevelAtUse *int `json:"user_level_at_use"`
|
||||
PlanIDAtUse *int `json:"plan_id_at_use"`
|
||||
MultiplierApplied float64 `gorm:"not null;default:1.0" json:"multiplier_applied"`
|
||||
IPAddress string `gorm:"size:45" json:"ip_address"`
|
||||
UserAgent string `gorm:"type:text" json:"user_agent"`
|
||||
Notes string `gorm:"type:text" json:"notes"`
|
||||
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
|
||||
}
|
||||
|
||||
func (GiftCardUsage) TableName() string {
|
||||
return "v2_gift_card_usage"
|
||||
}
|
||||
22
internal/model/stat.go
Normal file
22
internal/model/stat.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package model
|
||||
|
||||
type Stat struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
OrderCount int `gorm:"not null;default:0" json:"order_count"`
|
||||
OrderTotal int64 `gorm:"not null;default:0" json:"order_total"`
|
||||
PaidCount int `gorm:"not null;default:0" json:"paid_count"`
|
||||
PaidTotal int64 `gorm:"not null;default:0" json:"paid_total"`
|
||||
CommissionCount int `gorm:"not null;default:0" json:"commission_count"`
|
||||
CommissionTotal int64 `gorm:"not null;default:0" json:"commission_total"`
|
||||
RegisterCount int `gorm:"not null;default:0" json:"register_count"`
|
||||
InviteCount int `gorm:"not null;default:0" json:"invite_count"`
|
||||
TransferUsedTotal int64 `gorm:"not null;default:0" json:"transfer_used_total"`
|
||||
RecordAt int64 `gorm:"not null;index" json:"record_at"`
|
||||
RecordType string `gorm:"size:2;not null;index" json:"record_type"` // 'd' for daily, 'm' for monthly
|
||||
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (Stat) TableName() string {
|
||||
return "v2_stat"
|
||||
}
|
||||
15
internal/model/stat_server.go
Normal file
15
internal/model/stat_server.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
type StatServer struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
ServerID int `gorm:"not null;index" json:"server_id"`
|
||||
U int64 `gorm:"not null;default:0" json:"u"`
|
||||
D int64 `gorm:"not null;default:0" json:"d"`
|
||||
RecordAt int64 `gorm:"not null;index" json:"record_at"`
|
||||
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (StatServer) TableName() string {
|
||||
return "v2_stat_server"
|
||||
}
|
||||
25
internal/model/traffic_reset_log.go
Normal file
25
internal/model/traffic_reset_log.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package model
|
||||
|
||||
// TrafficResetLog records every instance where a user's traffic usage was reset.
|
||||
type TrafficResetLog struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
UserID int `gorm:"not null;index" json:"user_id"`
|
||||
ResetType string `gorm:"size:50;not null" json:"reset_type"` // monthly, yearly, manual, purchase
|
||||
ResetTime int64 `gorm:"not null;index" json:"reset_time"` // The actual time it was reset
|
||||
OldUpload int64 `gorm:"not null;default:0" json:"old_upload"` // pre-reset
|
||||
OldDownload int64 `gorm:"not null;default:0" json:"old_download"` // pre-reset
|
||||
OldTotal int64 `gorm:"not null;default:0" json:"old_total"` // pre-reset
|
||||
NewUpload int64 `gorm:"not null;default:0" json:"new_upload"` // post-reset
|
||||
NewDownload int64 `gorm:"not null;default:0" json:"new_download"` // post-reset
|
||||
NewTotal int64 `gorm:"not null;default:0" json:"new_total"` // post-reset
|
||||
TriggerSource string `gorm:"size:50;not null;default:'auto'" json:"trigger_source"` // auto, manual, cron, order, gift_card
|
||||
Metadata string `gorm:"type:text" json:"metadata"` // JSON extra data
|
||||
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"`
|
||||
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"`
|
||||
|
||||
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
||||
}
|
||||
|
||||
func (TrafficResetLog) TableName() string {
|
||||
return "v2_traffic_reset_logs"
|
||||
}
|
||||
Reference in New Issue
Block a user