package confcardholder import ( "apigame/configs/confbase" "apigame/service-common/svconst" "apigame/util/util-lx/lxtime" "apigame/util/utstring" "fmt" ) // ActivityConfig 卡牌活动配置 分析后数据 type ActivityConfig struct { Raw *ActivityConfigRaw `json:"-"` Id int64 // ID OpenLevel int // 开启等级 PreviewTime int64 // 预告时间 StartTime int64 // 开始时间 EndTime int64 // 结束时间 Round int // 轮数 IconPath string // icon资源路径 Awards map[string]string // 奖励配置 AlbumConfig map[int]AlbumConfig // 卡组配置 CardConfig map[int]CardConfig // 卡牌配置 CardholderConfig map[int]OpenCardholderConfig // 卡包开卡规则 NormalCardStarConfig map[string]NormalCardStarConfig // k=ID_用户序列_用户分组 卡片星级配置 CardSequenceConfig map[string]CardSequenceConfig // k=ID_用户序列_用户分组 卡片星级对应卡牌配置 StarShopConfig map[int]StarShopConfig // 星星商店配置 Client *ActivityConfigClient GameId string // 所属游戏ID } func (c *ActivityConfig) GetUid() string { return utstring.Int64ToString(c.Id) } func (c *ActivityConfig) CheckCurrent() bool { timeNow := lxtime.NowUninx() return timeNow >= c.StartTime && timeNow <= c.EndTime && c.Raw.Status == 1 } func (c *ActivityConfig) ConfInfo(suffix string) *confbase.ConfInfo { tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG cacheKey := fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix) timeNow := lxtime.NowUninx() return &confbase.ConfInfo{ DbMysql: svconst.DbConfig, TableName: fmt.Sprintf("%s_%s", tableName, suffix), KeyName: "id", CurrentQuery: "status = ? AND start_time <= ? AND end_time >= ?", CurrentArgs: []any{1, timeNow, timeNow}, CacheKey: fmt.Sprintf("%s:%d", cacheKey, c.Id), CacheCurrent: cacheKey + ":current", CacheTime: 300, } } // ActivityConfigRaw 卡牌活动配置 原始数据 type ActivityConfigRaw struct { Id int64 `gorm:"column:id;primaryKey"` // ID OpenLevel int // 开启等级 PreviewTime int64 // 预告时间 StartTime int64 // 开始时间 EndTime int64 // 结束时间 Round int // 轮数 IconPath string // icon资源路径 Awards string // 奖励配置 AlbumConfig string // 卡组配置 CardConfig string // 卡牌配置 CardHolderConfig string // 卡包开卡规则 NormalCardStarSequence string // 卡片星级配置 CardSequenceConfig string // 卡片星级对应卡牌配置 StarShopConfig string // 星星商店配置 Ver string // 版本号 Status int // 状态 0=关闭 1=开启 UpdateTime int64 // 修改时间戳 } // ActivityConfigClient 卡牌活动配置 给客户端数据 type ActivityConfigClient struct { Id int64 `form:"id" json:"id"` // ID IconPath string `form:"icon_path" json:"icon_path"` // icon资源路径 RoundAwards map[string]string `form:"round_awards" json:"round_awards"` // 轮次奖励配置 Albums []AlbumConfig `form:"albums" json:"albums"` // 卡组配置 Cards []CardConfig `form:"cards" json:"cards"` // 卡牌配置 Holders []OpenCardholderConfig `form:"holders" json:"holders"` // 卡包开卡规则 StarShop []StarShopConfig `form:"star_shop" json:"star_shop"` // 星星商店配置 } // AlbumConfig 卡组表 type AlbumConfig struct { SetId int `json:"set_id"` // 卡组名 Name int `json:"name"` // 卡组图片 Icon string `json:"icon"` // 卡组id Rewards map[string]string `json:"rewards"` // 集齐奖励 k=轮次 StartTime int64 `json:"start_time"` // 开始时间 EndTime int64 `json:"end_time"` // 结束时间 } // CardConfig 卡牌表 type CardConfig struct { Id int `json:"id"` // ID Name int `json:"name"` // 卡牌名字 Icon string `json:"icon"` // 卡牌图标 Desc int `json:"desc"` // 卡牌描述 SetId int `json:"album_setid"` // 卡组id Star int `json:"star"` // 星级 IsGold int `json:"is_gold"` // 是否是金卡 IsSend int `json:"is_send"` // 卡片是否可赠送 } // OpenCardholderConfig 卡包开卡规则表 type OpenCardholderConfig struct { Id int `json:"id"` // ID CardPackIcon string `json:"img"` // 卡包资源名 IsGoldCardholder int `json:"is_gold_card_holder"` // 是否是金卡包 IsNew int `json:"is_new"` // 是否是新卡包 GuaranteedStarCardId int `json:"guaranteed_star_card_id"` // 保底卡星级序列ID NormalCardNumber int `json:"normal_card_number"` // 非保底卡数量 MinimumGuaranteeCardId int `json:"minimum_guarantee_card_id"` // 非保底卡牌序列ID ActivityId int `json:"activity_id"` // 对应活动ID } // NormalCardStarConfig 非保底卡星级ID type NormalCardStarConfig struct { Id int `json:"id"` // ID SequenceId int `json:"user_sequence_id"` // 用户序列组ID Cohort int `json:"cohort"` // 用户分组 NormalCardSequenceId []int `json:"normal_card_sequence_id"` // 非保底星级序列 } // CardSequenceConfig 星级ID对应的卡片 type CardSequenceConfig struct { Id int `json:"id"` // ID SequenceId int `json:"user_sequence_id"` // 用户序列组ID Cohort int `json:"cohort"` // 用户分组 CardIdList []int `json:"card_id_list"` // 卡牌抽取序列 } // StarShopConfig 星星商店配置 type StarShopConfig struct { Id int `json:"id"` // ID NeedStarNumber int `json:"need_star_number"` // 需求星星数 CardBagIds string `json:"card_bag_ids"` // 可换取的卡包ID {卡包类型,卡包ID,卡包数量} }