diff --git a/call/config.go b/call/config.go index fbc7fa5..ec56db6 100644 --- a/call/config.go +++ b/call/config.go @@ -102,6 +102,8 @@ var ( configRtpControl []*common.ConfigRtpControl configEliminateBet common.ConfigEliminateBet + + configTemplates []*common.ConfigRtpTemplate ) var ( @@ -2693,3 +2695,27 @@ func LoadConfigEliminateBet() (err error) { func GetConfigEliminateBet() common.ConfigEliminateBet { return configEliminateBet } + +func LoadConfigRtpTemplate() (err error) { + var result []*common.ConfigRtpTemplate + err = db.Mysql().C().Model(&common.ConfigRtpTemplate{}).Where("open = 1 and template_id != ''").Find(&result).Error + if err != nil { + log.Error("err:%v", err) + return err + } + configTemplates = result + return nil +} + +func GetConfigRtpTemplate() []*common.ConfigRtpTemplate { + return configTemplates +} + +func GetConfigRtpTemplateId() string { + for _, v := range configTemplates { + if v.Open == 1 && v.TemplateId != "" { + return v.TemplateId + } + } + return "" +} diff --git a/call/reload.go b/call/reload.go index 61f77d2..341f977 100644 --- a/call/reload.go +++ b/call/reload.go @@ -650,4 +650,13 @@ func CommonReload(c map[int][]func(*pb.ReloadGameConfig) error) { return nil }} } + if _, ok := c[common.ReloadConfigRtpTemplate]; !ok { + c[common.ReloadConfigRtpTemplate] = []func(*pb.ReloadGameConfig) error{func(rgc *pb.ReloadGameConfig) error { + if err := LoadConfigRtpTemplate(); err != nil { + log.Error("error : [%s]", err.Error()) + return err + } + return nil + }} + } } diff --git a/common/config.go b/common/config.go index d72c4a9..e28bd07 100644 --- a/common/config.go +++ b/common/config.go @@ -76,6 +76,7 @@ const ( ReloadConfigRtpControl ReloadConfigEliminateBet ReloadTypeExcel + ReloadConfigRtpTemplate ) // GetConfigStructByType 获取相应配置的结构 @@ -207,6 +208,8 @@ func GetConfigStructByType(t int) (interface{}, interface{}) { return &ConfigRtpControl{}, &[]ConfigRtpControl{} case ReloadConfigEliminateBet: return &ConfigEliminateBet{}, &[]ConfigEliminateBet{} + case ReloadConfigRtpTemplate: + return &ConfigRtpTemplate{}, &[]ConfigRtpTemplate{} default: return nil, nil } diff --git a/common/player.go b/common/player.go index a7945f6..0b1c7f9 100644 --- a/common/player.go +++ b/common/player.go @@ -339,3 +339,16 @@ type ConfigRtpControl struct { func (m *ConfigRtpControl) TableName() string { return "config_rtp_control" } + +type ConfigRtpTemplate struct { + ID int `gorm:"column:id;type:int(11) AUTO_INCREMENT;primary_key"` + TemplateId string `gorm:"column:template_id;type:varchar(256);default:'';comment:模板id"` + Rtp int `gorm:"column:rtp;type:int(11);comment:rtp" web:"rtp"` + MaxOdds int `gorm:"column:max_odds;type:bigint(20);comment:最大倍数" web:"max_odds"` + Open int `gorm:"column:open;type:bigint(20);comment:是否打开(1:是)" web:"open"` + UpdatedBase +} + +func (m *ConfigRtpTemplate) TableName() string { + return "config_rtp_template" +} diff --git a/modules/backend/migrate.go b/modules/backend/migrate.go index 4ad5bee..25eb2ac 100644 --- a/modules/backend/migrate.go +++ b/modules/backend/migrate.go @@ -153,6 +153,7 @@ func MigrateDB() { new(common.WeekCardData), new(common.ConfigRtpControl), new(common.ConfigEliminateBet), + new(common.ConfigRtpTemplate), ) if err != nil { panic("Migrate db fail") diff --git a/modules/backend/values/gm.go b/modules/backend/values/gm.go index 1208178..90ed234 100644 --- a/modules/backend/values/gm.go +++ b/modules/backend/values/gm.go @@ -210,6 +210,8 @@ func GetControlType(path string) int { return common.ReloadConfigRtpControl case "eliminateBet": return common.ReloadConfigEliminateBet + case "rtpTemplate": + return common.ReloadConfigRtpTemplate default: return 0 } diff --git a/modules/web/providers/sn/handler.go b/modules/web/providers/sn/handler.go index 65a869a..c94eda3 100644 --- a/modules/web/providers/sn/handler.go +++ b/modules/web/providers/sn/handler.go @@ -637,6 +637,11 @@ func Control(uid int, controlId int) error { rtp = specialControlRtp log.Debug("rtpControl special, uid:%d result:%s, rtp:%d", uid, result, specialControlRtp) } + templateId := call.GetConfigRtpTemplateId() + if templateId == "" && DefaultTemplateId != "" { + log.Debug("sn cfg templateId is nil") + templateId = DefaultTemplateId + } req := &ControlReq{ BaseReq: BaseReq{ SnAccount: SnAccount, @@ -646,7 +651,7 @@ func Control(uid int, controlId int) error { ControlId: controlId, Sn: SnId, AgentId: AgentId, - TemplateId: DefaultTemplateId, + TemplateId: templateId, Data: []struct { TargetRtp int `json:"target_rtp"` }{ @@ -682,6 +687,7 @@ func InitGameControlTemplate() error { SnAccount: SnAccount, Time: time.Now().Unix(), }, + PageSize: 100, } log.Debug("sn get control template req, %+v", *req) @@ -702,11 +708,22 @@ func InitGameControlTemplate() error { } for _, v := range resp.Data.List { - if strings.Contains(v.Desc, "90%50") { + v.Desc = strings.ReplaceAll(v.Desc, "倍", "") + descList := strings.Split(v.Desc, "%") + log.Debug("sn template desc:%s", descList) + err = db.Mysql().C().Model(&common.ConfigRtpTemplate{}).Where("rtp = ? and max_odds = ?", util.ToInt(descList[0]), util.ToInt(descList[1])). + Updates(map[string]interface{}{ + "template_id": v.TemplateId, + }).Error + if err != nil { + log.Error("update rtp template err, %s", err.Error()) + continue + } + if strings.Contains(v.Desc, "90%50倍") { DefaultTemplateId = v.TemplateId - break } } + call.LoadConfigRtpTemplate() return nil }