85 lines
3.3 KiB
Go
85 lines
3.3 KiB
Go
package models
|
||
|
||
import (
|
||
"time"
|
||
|
||
"gorm.io/gorm"
|
||
)
|
||
|
||
// MintCostConfig 铸造消耗配置表
|
||
type MintCostConfig struct {
|
||
ID int64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||
MintCount int32 `gorm:"uniqueIndex;not null;column:mint_count"` // 铸爱次数 1-10
|
||
CostCrystal int64 `gorm:"not null;column:cost_crystal"` // 消耗水晶数
|
||
Probability int64 `gorm:"default:0;column:probability"` // 保底触发概率 0-100
|
||
RewardType *string `gorm:"type:varchar(50);column:reward_type"` // 奖励类型
|
||
RewardValue int64 `gorm:"default:0;column:reward_value"` // 奖励值(bps)
|
||
Description *string `gorm:"type:varchar(255);column:description"` // 描述
|
||
UpdatedAt int64 `gorm:"not null;column:updated_at"`
|
||
}
|
||
|
||
// TableName 指定表名
|
||
func (MintCostConfig) TableName() string {
|
||
return "mint_cost_config"
|
||
}
|
||
|
||
// BeforeUpdate 更新前钩子
|
||
func (m *MintCostConfig) BeforeUpdate(tx *gorm.DB) error {
|
||
m.UpdatedAt = time.Now().UnixMilli()
|
||
return nil
|
||
}
|
||
|
||
// UserMintCount 用户铸爱累计表
|
||
type UserMintCount struct {
|
||
ID int64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||
UserID int64 `gorm:"uniqueIndex:uk_user_mint_star;not null;column:user_id"`
|
||
StarID int64 `gorm:"uniqueIndex:uk_user_mint_star;not null;column:star_id"`
|
||
MintCount int32 `gorm:"default:0;not null;column:mint_count"` // 累计铸造次数
|
||
RevenueBoostBps int32 `gorm:"default:0;not null;column:revenue_boost_bps"` // 永久收益提升(基点),500=+5%
|
||
UpdatedAt int64 `gorm:"not null;column:updated_at"`
|
||
}
|
||
|
||
// TableName 指定表名
|
||
func (UserMintCount) TableName() string {
|
||
return "user_mint_count"
|
||
}
|
||
|
||
// BeforeCreate 创建前钩子
|
||
func (u *UserMintCount) BeforeCreate(tx *gorm.DB) error {
|
||
u.UpdatedAt = time.Now().UnixMilli()
|
||
return nil
|
||
}
|
||
|
||
// BeforeUpdate 更新前钩子
|
||
func (u *UserMintCount) BeforeUpdate(tx *gorm.DB) error {
|
||
u.UpdatedAt = time.Now().UnixMilli()
|
||
return nil
|
||
}
|
||
|
||
// MintRewardConfig 铸造奖励配置表(预留)
|
||
type MintRewardConfig struct {
|
||
ID int64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||
StarID int64 `gorm:"uniqueIndex;not null;column:star_id"` // 偶像ID,0=全服默认
|
||
BaseReward int64 `gorm:"default:0;column:base_reward"` // 每次铸造基础返还水晶数
|
||
IsEnabled bool `gorm:"default:true;column:is_enabled"` // 功能开关
|
||
UpdatedAt int64 `gorm:"not null;column:updated_at"`
|
||
}
|
||
|
||
// TableName 指定表名
|
||
func (MintRewardConfig) TableName() string {
|
||
return "mint_reward_config"
|
||
}
|
||
|
||
// MintMilestoneConfig 铸造阶梯奖励配置表(预留)
|
||
type MintMilestoneConfig struct {
|
||
ID int64 `gorm:"primaryKey;autoIncrement;column:id"`
|
||
StarID int64 `gorm:"uniqueIndex:uk_milestone_star_count;not null;column:star_id"`
|
||
MilestoneCount int32 `gorm:"uniqueIndex:uk_milestone_star_count;not null;column:milestone_count"` // 累计次数阈值
|
||
BonusReward int64 `gorm:"not null;column:bonus_reward"` // 达到该阶梯时额外奖励水晶
|
||
CreatedAt int64 `gorm:"not null;column:created_at"`
|
||
}
|
||
|
||
// TableName 指定表名
|
||
func (MintMilestoneConfig) TableName() string {
|
||
return "mint_milestone_config"
|
||
} |