feat-cardholder.go 5.92 KB
package configs

import (
	"apigame/service-common/svconst"
	"apigame/service-common/svmysql"
	"apigame/service-common/svredis"
	"fmt"
)

// CardActivityConfig 卡牌活动配置 分析后数据
type CardActivityConfig struct {
	Raw *CardActivityConfigRaw `json:"-"`

	Id          int64 // ID
	OpenLevel   int   // 开启等级
	PreviewTime int64 // 预告时间
	StartTime   int64 // 开始时间
	EndTime     int64 // 结束时间
	Round       int   // 轮数

	Awards               map[string]string               // 奖励配置
	AlbumConfig          map[int]AlbumConfig             // 卡组配置
	CardConfig           map[int]CardConfig              // 卡牌配置
	CardholderConfig     map[string]OpenCardholderConfig // 卡包开卡规则
	NormalCardStarConfig map[string]NormalCardStarConfig // k=ID_用户序列_用户分组 卡片星级配置
	CardSequenceConfig   map[string]CardSequenceConfig   // k=ID_用户序列_用户分组 卡片星级对应卡牌配置
	StarShopConfig       map[int]StarShopConfig          // 星星商店配置

	Client *CardActivityConfigClient
	GameId string // 所属游戏ID
}

func (c *CardActivityConfig) RedisInfo(suffix string) *svredis.RedisInfo {
	tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG
	return &svredis.RedisInfo{
		CacheKey:  fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix),
		CacheTime: 300,
	}
}

// CardActivityConfigRaw 卡牌活动配置 原始数据
type CardActivityConfigRaw struct {
	Id                     int64  // ID
	OpenLevel              int    // 开启等级
	PreviewTime            int64  // 预告时间
	StartTime              int64  // 开始时间
	EndTime                int64  // 结束时间
	Round                  int    // 轮数
	Awards                 string `json:"-"` // 奖励配置
	AlbumConfig            string `json:"-"` // 卡组配置
	CardConfig             string `json:"-"` // 卡牌配置
	CardHolderConfig       string `json:"-"` // 卡包开卡规则
	NormalCardStarSequence string `json:"-"` // 卡片星级配置
	CardSequenceConfig     string `json:"-"` // 卡片星级对应卡牌配置
	StarShopConfig         string `json:"-"` // 星星商店配置
	Ver                    string // 版本号
	Status                 int    // 状态 0=关闭 1=开启
	UpdateTime             int64  // 修改时间戳
}

func (c *CardActivityConfigRaw) MysqlInfo(suffix string) *svmysql.MysqlInfo {
	tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG
	return &svmysql.MysqlInfo{
		DbMysql:   svconst.DbConfig.Where("status = ?", 1),
		TableName: tableName + suffix,
	}
}

// CardActivityConfigClient 卡牌活动配置 给客户端数据
type CardActivityConfigClient struct {
	Id          int64                  `form:"id" json:"id"`                     // ID
	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   int `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                     string `json:"id"`                        // ID
	IsGoldCardholder       int    `json:"is_gold_card_holder"`       // 是否是金卡包
	IsNew                  int    `json:"is_new"`                    // 是否是新卡包
	GuaranteedStarCardId   string `json:"guaranteed_star_card_id"`   // 保底卡星级序列ID
	NormalCardNumber       int    `json:"normal_card_number"`        // 非保底卡数量
	MinimumGuaranteeCardId string `json:"minimum_guarantee_card_id"` // 非保底卡牌序列ID
	ActivityId             int    `json:"activity_id"`               // 对应活动ID
}

// NormalCardStarConfig 非保底卡星级ID
type NormalCardStarConfig struct {
	Id                    string   `json:"id"`                       // ID
	SequenceId            string   `json:"user_sequence_id"`         // 用户序列组ID
	Cohort                string   `json:"cohort"`                   // 用户分组
	NormalCardSequenceId  string   `json:"normal_card_sequence_id"`  // 非保底星级序列
	NormalCardSequenceIds []string `json:"normal_card_sequence_ids"` // 非保底星级序列
}

// CardSequenceConfig 星级ID对应的卡片
type CardSequenceConfig struct {
	Id          string   `json:"id"`               // ID
	SequenceId  string   `json:"user_sequence_id"` // 用户序列组ID
	Cohort      string   `json:"cohort"`           // 用户分组
	CardIdList  string   `json:"card_id_list"`     // 卡牌抽取序列
	CardIdLists []string `json:"card_id_lists"`    // 卡牌抽取序列
}

// StarShopConfig 星星商店配置
type StarShopConfig struct {
	Id             int   `json:"id"`               // ID
	NeedStarNumber int   `json:"need_star_number"` // 需求星星数
	CardBagIds     []int `json:"card_bag_ids"`     // 可换取的卡包ID {卡包类型,卡包ID,卡包数量}
}