From 9a9c62c1da42dfa12f5c56157a95574faae764ed Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Sat, 20 Apr 2024 09:32:20 +0800 Subject: [PATCH] =?UTF-8?q?etcd=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/base/etcd.go | 6 +- gamesrv/base/scene.go | 8 +- gamesrv/tienlen/scenedata_tienlen.go | 4 +- model/config.go | 164 ++- worldsrv/action_server.go | 2 - worldsrv/action_shop.go | 5 +- worldsrv/etcd.go | 141 ++- worldsrv/etcdmgr.go | 1662 +------------------------- worldsrv/petmgr.go | 3 +- worldsrv/platform.go | 42 +- worldsrv/platformmgr.go | 405 +------ worldsrv/player.go | 16 +- worldsrv/scene.go | 2 - worldsrv/shopmgr.go | 146 +-- worldsrv/trascate_webapi.go | 10 +- worldsrv/welfmgr.go | 46 +- 16 files changed, 414 insertions(+), 2248 deletions(-) diff --git a/gamesrv/base/etcd.go b/gamesrv/base/etcd.go index be7944e..6b3e3e7 100644 --- a/gamesrv/base/etcd.go +++ b/gamesrv/base/etcd.go @@ -28,11 +28,11 @@ func platformConfigEtcd(ctx context.Context, completeKey string, isInit bool, ev } switch d := data.(type) { case *webapi.PlayerPool: - ConfigMgrInst.GetAllConfig(d.Platform).PlayerPool = d + ConfigMgrInst.GetConfig(d.Platform).PlayerPool = d case *webapi.GameConfig: - ConfigMgrInst.GetAllConfig(d.Platform).GameConfig = d + ConfigMgrInst.GetConfig(d.Platform).GameConfig = d case *webapi.WelfareCollectConfig: - ConfigMgrInst.GetAllConfig(d.Platform).WelfareCollectConfig = d + ConfigMgrInst.GetConfig(d.Platform).WelfareCollectConfig = d default: logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey) } diff --git a/gamesrv/base/scene.go b/gamesrv/base/scene.go index 957fc94..040c2e1 100644 --- a/gamesrv/base/scene.go +++ b/gamesrv/base/scene.go @@ -2376,7 +2376,7 @@ func (this *Scene) TryBillExGameDrop(p *Player) { // DropCollectBox 掉落集卡礼盒 func (this *Scene) DropCollectBox(p *Player) { - if p == nil || p.IsRob || ConfigMgrInst.GetAllConfig(p.Platform).WelfareCollectConfig.Switch != model.WelfareOpen { + if p == nil || p.IsRob || ConfigMgrInst.GetConfig(p.Platform).WelfareCollectConfig.Switch != model.WelfareOpen { return } @@ -2436,7 +2436,7 @@ func (this *Scene) GetBaseScore() int32 { } func (this *Scene) PlayerPoolOdds(p *Player) int32 { - config := ConfigMgrInst.GetAllConfig(p.Platform).PlayerPool + config := ConfigMgrInst.GetConfig(p.Platform).PlayerPool if config == nil { return 0 } @@ -2490,7 +2490,7 @@ func (this *Scene) GetPlayerOdds(p *Player, gameId int, hasRobot bool) int32 { // 场次水池概率 f = CoinPoolMgr.GetCoinPoolOdds(this.Platform, this.GetGameFreeId(), this.GroupId) - cfg := ConfigMgrInst.GetAllConfig(p.Platform).PlayerPool + cfg := ConfigMgrInst.GetConfig(p.Platform).PlayerPool if cfg != nil && cfg.PlayerPoolSwitch { if g > 0 { t = f + (1000-f)*g/1000 @@ -2707,7 +2707,7 @@ func (this *Scene) Statistics(param *StaticParam) { // 个人输赢统计条件(个人水池) // 黑白名单和新手调控,溢出金币统计到个人水池 - cfg := ConfigMgrInst.GetAllConfig(p.Platform).PlayerPool + cfg := ConfigMgrInst.GetConfig(p.Platform).PlayerPool isPlayerPool := cfg != nil && cfg.PlayerPoolSwitch && isControl && ((wbLevel == 0 && !isNovice) || addGain > 0) if isPlayerPool { keyGameType := common.GetKeyGameType(int(this.GetDBGameFree().GetGameType())) diff --git a/gamesrv/tienlen/scenedata_tienlen.go b/gamesrv/tienlen/scenedata_tienlen.go index 03648e7..6cf5dcb 100644 --- a/gamesrv/tienlen/scenedata_tienlen.go +++ b/gamesrv/tienlen/scenedata_tienlen.go @@ -1184,7 +1184,7 @@ func (this *TienLenSceneData) SendHandCardOdds() { } } - gameConfig := base.ConfigMgrInst.GetAllConfig(this.Platform).GameConfig + gameConfig := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig // testPokers 用于测试 isTestPoker := false @@ -1228,7 +1228,7 @@ func (this *TienLenSceneData) SendHandCardOdds() { logger.Logger.Tracef("TienLen SendHandCardOdds Good:%v G:%v Bad:%v B:%v", isGood, G, isBad, B) if isBad && !isTestPoker && len(robotPlayers) > 0 && !noviceCtrl && !noviceTianHu { - gf := base.ConfigMgrInst.GetAllConfig(this.Platform).GameConfig + gf := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig items := []int32{gf.GetTianHu(), gf.GetPaiKu(), gf.GetFenCha()} score := this.RandInt(int(gf.GetTianHu() + gf.GetPaiKu() + gf.GetFenCha())) sum := int32(0) diff --git a/model/config.go b/model/config.go index 9a7b346..5ea194f 100644 --- a/model/config.go +++ b/model/config.go @@ -1,6 +1,9 @@ package model -import webapiproto "mongo.games.com/game/protocol/webapi" +import ( + "mongo.games.com/game/protocol/shop" + "mongo.games.com/game/protocol/webapi" +) /* 通用模型定义在这里,如果需要自定义可以内嵌在新结构体中 @@ -22,57 +25,170 @@ const ( WelfareClose = 2 // 关闭 ) -func NewConfigMgr() *ConfigMgr { - return &ConfigMgr{ - Platform: make(map[string]*AllConfig), - Global: new(GlobalConfig), - } +type ShopInfo struct { + Id int32 // 商品ID + Page int32 // 页面 1,金币页面 2,钻石页面 3,道具页面 + Order int32 // 排序 页面内商品的位置排序 + Location []int32 // 显示位置 第1位,竖版大厅 第2位,Tienlen1级选场 第3位,捕鱼1级选场 + Picture string // 图片id + Name string // 名称 + Label []int32 // 标签 + Ad int32 // 是否观看广告 0不看 + AdTime int32 // 观看几次广告 + RepeatTimes int32 // 领取次数 + CoolingTime []int32 // 观看冷却时间 + Type int32 // 获得类型 1,金币 2,钻石 3,道具类型 + Amount int64 // 获得数量 + AddArea []int32 // 加送百分比(比如加送10%,就配置110) + ItemId int32 // 获得道具ID + AddItemInfo []*shop.ItemInfo // 获得道具 + ConstType int32 // 购买消耗类型 1,金币 2,钻石 3,美金 4,柬埔寨币 + CostArea []int32 // 消耗数量区间 + VipLevel int32 //Vip等级限制 + Ratio int32 //权重 + EndTime int32 //新手礼包结束时间间隔 + //缓存数据 + AdLookedNum int32 //已经观看的次数 + AdReceiveNum int32 //已经领取的次数 + RemainingTime int32 + LastLookTime int32 + RoleAdded int32 + PetAdded int32 + RoleAddedId int32 //加成人物ID + PetAddedId int32 //加成宠物ID + FirstSwitch bool // 首冲翻倍 + AmountFinal int64 // 实际获得数量 } type AllConfig struct { + // 平台配置 + Platform *webapi.Platform + // 客户端游戏入口开关 + EntrySwitch *webapi.EntrySwitch + // 公告 + CommonNotices *webapi.CommonNoticeList // 七日签到 - *webapiproto.Welfare7SignDateList + *webapi.Welfare7SignDateList // 转盘 - *webapiproto.WelfareTurnplateDateList + *webapi.WelfareTurnplateDateList // 盲盒 - *webapiproto.WelfareBlindBoxDataList + *webapi.WelfareBlindBoxDataList BlindBoxCycle int32 // 首充 - *webapiproto.WelfareFirstPayDataList + *webapi.WelfareFirstPayDataList FirstPayCycle int32 // 连续充值 - *webapiproto.WelfareContinuousPayDataList + *webapi.WelfareContinuousPayDataList ContinuousPayCycle int32 // 积分换手机 - *webapiproto.WelfarePhoneLotteryStatus + *webapi.WelfarePhoneLotteryStatus // 集卡活动 - *webapiproto.WelfareCollectConfig + *webapi.WelfareCollectConfig // 个人水池 - *webapiproto.PlayerPool + *webapi.PlayerPool // 游戏调控全局配置 - *webapiproto.GameConfig + *webapi.GameConfig + // 兑换商品 + *webapi.ExchangeShopList + // 商店 + ShopInfos map[int32]*ShopInfo // 商品id:商品信息 } type GlobalConfig struct { + // 包对应的平台,包标识 + PackageList map[string]*webapi.AppInfo + // 超管平台游戏开关,游戏id + GameStatus map[int32]bool } type ConfigMgr struct { - Platform map[string]*AllConfig - Global *GlobalConfig + platform map[string]*AllConfig + global *GlobalConfig } -func (cm *ConfigMgr) GetAllConfig(platform string) *AllConfig { - c, ok := cm.Platform[platform] +func NewConfigMgr() *ConfigMgr { + return &ConfigMgr{ + platform: make(map[string]*AllConfig), + } +} + +func (cm *ConfigMgr) GetConfig(platform string) *AllConfig { + c, ok := cm.platform[platform] if !ok { - c = &AllConfig{} - cm.Platform[platform] = c + c = &AllConfig{ + // todo 初始化默认值 + ShopInfos: make(map[int32]*ShopInfo), + } + cm.platform[platform] = c } return c } func (cm *ConfigMgr) GetGlobalConfig() *GlobalConfig { - if cm.Global == nil { - cm.Global = new(GlobalConfig) + if cm.global == nil { + cm.global = &GlobalConfig{ + // todo 初始化默认值 + PackageList: make(map[string]*webapi.AppInfo), + GameStatus: make(map[int32]bool), + } } - return cm.Global + return cm.global +} + +func (cm *ConfigMgr) GetConfigs() map[string]*AllConfig { + return cm.platform +} + +// UpdateItemShop 更新商品信息 +func (cm *ConfigMgr) UpdateItemShop(list *webapi.ItemShopList) { + if list == nil { + return + } + + shopInfos := make(map[int32]*ShopInfo) + for _, itemShop := range list.List { + var itemInfo []*shop.ItemInfo + for key, value := range itemShop.Award { + itemInfo = append(itemInfo, &shop.ItemInfo{ + ItemId: int32(key), + ItemNum: value, + }) + } + + shopInfos[itemShop.Id] = &ShopInfo{ + Id: itemShop.Id, + ItemId: itemShop.ItemId, + Page: itemShop.Page, + Order: itemShop.Order, + Type: itemShop.Type, + Location: itemShop.Location, + Picture: itemShop.Picture, + Name: itemShop.Name, + Ad: itemShop.Ad, + AdTime: itemShop.AdTime, + RepeatTimes: itemShop.RepeatTimes, + CoolingTime: itemShop.CoolingTime, + Label: itemShop.Label, + AddArea: itemShop.AddArea, + Amount: int64(itemShop.Amount), + ConstType: itemShop.ConstType, + CostArea: itemShop.CostArea, + AddItemInfo: itemInfo, + VipLevel: itemShop.VipLevel, + Ratio: itemShop.Ratio, + EndTime: itemShop.EndTime, + FirstSwitch: itemShop.FirstSwitch, + } + } + cm.GetConfig(list.Platform).ShopInfos = shopInfos +} + +// GetShopInfo 获取商品信息 +func (cm *ConfigMgr) GetShopInfo(plt string, shopId int32) *ShopInfo { + if shops := cm.GetConfig(plt).ShopInfos; shops != nil { + if info, ok1 := shops[shopId]; ok1 { + return info + } + } + return nil } diff --git a/worldsrv/action_server.go b/worldsrv/action_server.go index 1c7d713..4f4214c 100644 --- a/worldsrv/action_server.go +++ b/worldsrv/action_server.go @@ -264,7 +264,6 @@ func init() { } else { logger.Logger.Trace("游戏结束------", scene.gameId, scene.sceneId, scene.replayCode, scene.currRound) } - PlatformMgrSingleton.OnChangeSceneState(scene, scene.starting) } } return nil @@ -282,7 +281,6 @@ func init() { if scene != nil { scene.state = msg.GetCurrState() scene.fishing = msg.GetFishing() - PlatformMgrSingleton.OnChangeSceneState(scene, scene.starting) } } return nil diff --git a/worldsrv/action_shop.go b/worldsrv/action_shop.go index 45551f9..e4c310b 100644 --- a/worldsrv/action_shop.go +++ b/worldsrv/action_shop.go @@ -578,7 +578,10 @@ func (this *CSUpdateVipShopHandler) Process(s *netlib.Session, packetid int, dat RefreshCount: p.VipShopRefreshCount, //玩家当前刷新次数 } for i, info := range p.VipShopData { - si := ShopMgrSington.ShopInfos[p.Platform][info.Id] + si := ShopMgrSington.GetConfig(p.Platform).ShopInfos[info.Id] + if si == nil { + continue + } data := &shop.ShopInfo{ Id: info.Id, AdLookedNum: si.AdLookedNum, diff --git a/worldsrv/etcd.go b/worldsrv/etcd.go index 1a2edb9..5c8c0ea 100644 --- a/worldsrv/etcd.go +++ b/worldsrv/etcd.go @@ -2,66 +2,131 @@ package main import ( "context" + "strings" "go.etcd.io/etcd/client/v3" "mongo.games.com/goserver/core/logger" "mongo.games.com/game/etcd" + hallproto "mongo.games.com/game/protocol/gamehall" "mongo.games.com/game/protocol/webapi" ) func init() { + // 平台配置 + etcd.Register(etcd.ETCDKEY_PLATFORM_PREFIX, webapi.Platform{}, platformConfigEvent) + // 游戏场次配置 + etcd.Register(etcd.ETCDKEY_GAMECONFIG_PREFIX, webapi.GameFree{}, platformConfigEvent) + // 超管平台游戏开关 + etcd.Register(etcd.ETCDKEY_GAME_CONFIG_GLOBAL, webapi.GameConfigGlobal{}, platformConfigEvent) + // 平台包数据 + etcd.Register(etcd.ETCDKEY_PACKAGE_PREFIX, webapi.AppInfo{}, platformConfigEvent) + // 客户端游戏入口开关 + etcd.Register(etcd.ETCDKEY_PACKAGE_ENTRYSWITCH, webapi.EntrySwitch{}, platformConfigEvent) + // 公告 + etcd.Register(etcd.ETCDKEY_GAME_NOTICE, webapi.CommonNoticeList{}, platformConfigEvent) + // 比赛配置 + etcd.Register(etcd.ETCDKEY_GAME_MATCH, webapi.GameMatchDateList{}, platformConfigEvent) // 个人水池配置 - etcd.Register(etcd.ETCDKEY_PLAYERPOOL, webapi.PlayerPool{}, PlatformConfigEtcd) + etcd.Register(etcd.ETCDKEY_PLAYERPOOL, webapi.PlayerPool{}, platformConfigEvent) // 商品兑换 - etcd.Register(etcd.ETCDKEY_SHOP_EXCHANGE, webapi.ExchangeShopList{}, ExchangeShopList) + etcd.Register(etcd.ETCDKEY_SHOP_EXCHANGE, webapi.ExchangeShopList{}, platformConfigEvent) // 商城商品 - etcd.Register(etcd.ETCDKEY_SHOP_ITEM, webapi.ItemShopList{}, ItemShopList) + etcd.Register(etcd.ETCDKEY_SHOP_ITEM, webapi.ItemShopList{}, platformConfigEvent) // 集卡活动 - etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, WelfareCollectConfig) + etcd.Register(etcd.ETCDKEY_ACT_Collect, webapi.WelfareCollectConfig{}, platformConfigEvent) } -//func ExchangeShopList(completeKey string, isInit bool, event *clientv3.Event, data interface{}) {} - -func WelfareCollectConfig(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) { +func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) { if event.Type == clientv3.EventTypeDelete { return } - config, ok := data.(*webapi.WelfareCollectConfig) - if !ok { - logger.Logger.Errorf("etcd completeKey:%s, data type error", completeKey) - return - } - WelfareMgrSington.UpdateCollectConfig(config) -} -func ItemShopList(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) { - if event.Type == clientv3.EventTypeDelete { + if data == nil { return } - config, ok := data.(*webapi.ItemShopList) - if !ok { - logger.Logger.Errorf("etcd completeKey:%s, data type error", completeKey) - return - } - ShopMgrSington.UpdateItemShop(config) -} -func PlatformConfigEtcd(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) { - if event.Type == clientv3.EventTypeDelete { - return - } - PlatformMgrSingleton.UpdateConfig(data) -} + switch config := data.(type) { + case *webapi.WelfareCollectConfig: + WelfareMgrSington.UpdateCollectConfig(config) + case *webapi.ItemShopList: + ShopMgrSington.UpdateItemShop(config) + case *webapi.ExchangeShopList: + ShopMgrSington.UpExShop(config) + case *webapi.PlayerPool: + PlatformMgrSingleton.GetConfig(config.Platform).PlayerPool = config + case *webapi.EntrySwitch: + PlatformMgrSingleton.GetConfig(config.Platform).EntrySwitch = config + PlatformMgrSingleton.ChangeEntrySwitch(config.Platform, config) + case *webapi.CommonNoticeList: + PlatformMgrSingleton.GetConfig(config.Platform).CommonNotices = config + if !isInit { + // 通知公共变更 + for _, v := range PlayerMgrSington.playerOfPlatform[config.Platform] { + if v != nil && v.IsOnLine() { + v.SendToClient(int(hallproto.GameHallPacketID_PACKET_SC_NoticeChange), &hallproto.SCNoticeChange{}) + } + } + } + case *webapi.GameConfigGlobal: + if isInit { + for _, v := range config.GetGameStatus() { + gameId := v.GetGameId() + status := v.GetStatus() + PlatformMgrSingleton.GetGlobalConfig().GameStatus[gameId] = status + } + } else { + cfgs := make([]*hallproto.GameConfig1, 0) + for _, v := range config.GetGameStatus() { + gameId := v.GetGameId() // gamefreeid + status := v.GetStatus() + if PlatformMgrSingleton.GetGlobalConfig().GameStatus[gameId] != status { + cfgs = append(cfgs, &hallproto.GameConfig1{ + LogicId: gameId, + Status: status, + }) + } + PlatformMgrSingleton.GetGlobalConfig().GameStatus[gameId] = status + } + PlatformMgrSingleton.ChangeGameStatus(cfgs) + } + case *webapi.Platform: + if isInit { + PlatformMgrSingleton.CreateDefaultPlatform() + } + PlatformMgrSingleton.UpsertPlatform(config.PlatformName, config.Isolated, config.Disabled, config.Id, + config.CustomService, config.BindOption, config.ServiceFlag, config.UpgradeAccountGiveCoin, + config.NewAccountGiveCoin, config.PerBankNoLimitAccount, config.ExchangeMin, config.ExchangeLimit, + config.ExchangeTax, config.ExchangeFlow, config.ExchangeFlag, config.SpreadConfig, config.VipRange, "", + nil, config.VerifyCodeType, nil /*config.ThirdGameMerchant,*/, config.CustomType, + false, config.NeedSameName, config.ExchangeForceTax, config.ExchangeGiveFlow, config.ExchangeVer, + config.ExchangeBankMax, config.ExchangeAlipayMax, 0, config.PerBankNoLimitName, config.IsCanUserBindPromoter, + config.UserBindPromoterPrize, false, config.ExchangeMultiple, false, config.MerchantKey, + config.BindTelReward) + case *webapi.GameFree: + var err error + s := strings.TrimPrefix(completeKey, etcd.ETCDKEY_GAMECONFIG_PREFIX) + arr := strings.Split(s, "/") + if len(arr) > 1 { + pltId := arr[0] + if err == nil { + PlatformMgrSingleton.UpsertGameFree(pltId, config) + } + } + case *webapi.AppInfo: + if config.PlatformId == 0 { + config.PlatformId = int32(DefaultPlatformInt) + } + PlatformMgrSingleton.GetGlobalConfig().PackageList[config.PackageName] = config + PlatformMgrSingleton.GetGlobalConfig().PackageList[config.BundleId] = config + case *webapi.GameMatchDateList: + if isInit { + TournamentMgr.UpdateData(true, config) + } else { + TournamentMgr.UpdateData(false, config) + } -func ExchangeShopList(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) { - if event.Type == clientv3.EventTypeDelete { - return + default: + logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey) } - config, ok := data.(*webapi.ExchangeShopList) - if !ok { - logger.Logger.Errorf("etcd completeKey:%s, data type error", completeKey) - return - } - ShopMgrSington.UpExShop(config) } diff --git a/worldsrv/etcdmgr.go b/worldsrv/etcdmgr.go index 6827742..f34094f 100644 --- a/worldsrv/etcdmgr.go +++ b/worldsrv/etcdmgr.go @@ -12,9 +12,8 @@ import ( "mongo.games.com/game/etcd" "mongo.games.com/game/model" "mongo.games.com/game/proto" - hall_proto "mongo.games.com/game/protocol/gamehall" - login_proto "mongo.games.com/game/protocol/login" - webapi_proto "mongo.games.com/game/protocol/webapi" + loginproto "mongo.games.com/game/protocol/login" + webapiproto "mongo.games.com/game/protocol/webapi" "mongo.games.com/goserver/core/logger" ) @@ -30,268 +29,6 @@ type EtcdMgr struct { *etcd.Client } -// 初始化平台数据 -func (this *EtcdMgr) InitPlatform() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_PLATFORM_PREFIX) - res, err := this.GetValueWithPrefix(etcd.ETCDKEY_PLATFORM_PREFIX) - if err == nil { - for i := int64(0); i < res.Count; i++ { - var value webapi_proto.Platform - err = proto.Unmarshal(res.Kvs[i].Value, &value) - if err == nil { - PlatformMgrSingleton.UpsertPlatform(value.PlatformName, value.Isolated, value.Disabled, value.Id, - value.CustomService, value.BindOption, value.ServiceFlag, value.UpgradeAccountGiveCoin, - value.NewAccountGiveCoin, value.PerBankNoLimitAccount, value.ExchangeMin, value.ExchangeLimit, - value.ExchangeTax, value.ExchangeFlow, value.ExchangeFlag, value.SpreadConfig, value.VipRange, "", - nil, value.VerifyCodeType, nil /*value.ThirdGameMerchant,*/, value.CustomType, - false, value.NeedSameName, value.ExchangeForceTax, value.ExchangeGiveFlow, value.ExchangeVer, - value.ExchangeBankMax, value.ExchangeAlipayMax, 0, value.PerBankNoLimitName, value.IsCanUserBindPromoter, - value.UserBindPromoterPrize, false, value.ExchangeMultiple, false, value.MerchantKey, - value.BindTelReward) - } else { - logger.Logger.Errorf("etcd read(%v) proto.Unmarshal err:%v", string(res.Kvs[i].Key), err) - } - } - if res.Header != nil { - return res.Header.Revision - } - } else { - logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_PLATFORM_PREFIX, err) - } - } - return -1 - } - - watchFunc := func(ctx context.Context, revision int64) { - // 监控数据变动 - this.GoWatch(ctx, revision, etcd.ETCDKEY_PLATFORM_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - var value webapi_proto.Platform - err := proto.Unmarshal(ev.Kv.Value, &value) - if err == nil { - platform := PlatformMgrSingleton.UpsertPlatform(value.PlatformName, value.Isolated, - value.Disabled, value.Id, value.CustomService, value.BindOption, - value.ServiceFlag, value.UpgradeAccountGiveCoin, value.NewAccountGiveCoin, - value.PerBankNoLimitAccount, value.ExchangeMin, value.ExchangeLimit, - value.ExchangeTax, value.ExchangeFlow, value.ExchangeFlag, value.SpreadConfig, - value.VipRange, "", nil, value.VerifyCodeType, - nil, value.CustomType, true, value.NeedSameName, - value.ExchangeForceTax, value.ExchangeGiveFlow, value.ExchangeVer, - value.ExchangeBankMax, value.ExchangeAlipayMax, 0, value.PerBankNoLimitName, - value.IsCanUserBindPromoter, value.UserBindPromoterPrize, false, value.ExchangeMultiple, - false, value.MerchantKey, value.BindTelReward) - if platform != nil { - //通知客户端平台配置发生改变 - scPlatForm := &login_proto.SCPlatFormConfig{ - Platform: proto.String(platform.IdStr), - OpRetCode: login_proto.OpResultCode_OPRC_Sucess, - UpgradeAccountGiveCoin: proto.Int32(platform.UpgradeAccountGiveCoin), - ExchangeMin: proto.Int32(platform.ExchangeMin), - ExchangeLimit: proto.Int32(platform.ExchangeLimit), - VipRange: platform.VipRange, - OtherParams: proto.String(platform.OtherParams), - SpreadConfig: proto.Int32(platform.SpreadConfig), - ExchangeTax: proto.Int32(platform.ExchangeTax), - ExchangeFlow: proto.Int32(platform.ExchangeFlow), - ExchangeBankMax: proto.Int32(platform.ExchangeBankMax), - ExchangeAlipayMax: proto.Int32(platform.ExchangeAlipayMax), - ExchangeMultiple: proto.Int32(platform.ExchangeMultiple), - } - rebateTask := RebateInfoMgrSington.rebateTask[platform.IdStr] - if rebateTask != nil { - scPlatForm.Rebate = &login_proto.RebateCfg{ - RebateSwitch: proto.Bool(rebateTask.RebateSwitch), - ReceiveMode: proto.Int32(int32(rebateTask.ReceiveMode)), - NotGiveOverdue: proto.Int32(int32(rebateTask.NotGiveOverdue)), - } - } - if platform.ClubConfig != nil { //俱乐部配置 - scPlatForm.Club = &login_proto.ClubCfg{ - IsOpenClub: proto.Bool(platform.ClubConfig.IsOpenClub), - CreationCoin: proto.Int64(platform.ClubConfig.CreationCoin), - IncreaseCoin: proto.Int64(platform.ClubConfig.IncreaseCoin), - ClubInitPlayerNum: proto.Int32(platform.ClubConfig.ClubInitPlayerNum), - CreateClubCheckByManual: proto.Bool(platform.ClubConfig.CreateClubCheckByManual), - EditClubNoticeByManual: proto.Bool(platform.ClubConfig.EditClubNoticeByManual), - CreateRoomAmount: proto.Int64(platform.ClubConfig.CreateRoomAmount), - GiveCoinRate: platform.ClubConfig.GiveCoinRate, - } - } - proto.SetDefaults(scPlatForm) - PlayerMgrSington.BroadcastMessageToPlatform(platform.IdStr, int(login_proto.LoginPacketID_PACKET_SC_PLATFORMCFG), scPlatForm) - } - } else { - logger.Logger.Errorf("etcd read(%v) proto.Unmarshal err:%v", string(ev.Kv.Key), err) - } - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// InitPlatformGameConfig 初始化平台游戏配置 -func (this *EtcdMgr) InitPlatformGameConfig() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_GAMECONFIG_PREFIX) - res, err := this.GetValueWithPrefix(etcd.ETCDKEY_GAMECONFIG_PREFIX) - if err == nil { - for i := int64(0); i < res.Count; i++ { - var config webapi_proto.GameFree - err = proto.Unmarshal(res.Kvs[i].Value, &config) - if err == nil { - s := strings.TrimPrefix(string(res.Kvs[i].Key), etcd.ETCDKEY_GAMECONFIG_PREFIX) - arr := strings.Split(s, "/") - if len(arr) > 1 { - pltId := arr[0] - if err == nil { - PlatformMgrSingleton.UpsertGameFree(pltId, &config) - } - } - } else { - logger.Logger.Errorf("etcd read(%v) proto.Unmarshal err:%v", string(res.Kvs[i].Key), err) - } - } - if res.Header != nil { - return res.Header.Revision - } - } else { - logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_GAMECONFIG_PREFIX, err) - } - } - return -1 - } - - watchFunc := func(ctx context.Context, revision int64) { - // 监控数据变动 - this.GoWatch(ctx, revision, etcd.ETCDKEY_GAMECONFIG_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - var config webapi_proto.GameFree - err := proto.Unmarshal(ev.Kv.Value, &config) - if err == nil { - s := strings.TrimPrefix(string(ev.Kv.Key), etcd.ETCDKEY_GAMECONFIG_PREFIX) - arr := strings.Split(s, "/") - if len(arr) > 1 { - pltId := arr[0] - if err == nil { - PlatformMgrSingleton.UpsertGameFree(pltId, &config) - } - } - } else { - logger.Logger.Errorf("etcd read(%v) proto.Unmarshal err:%v", string(ev.Kv.Key), err) - } - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// 初始化平台包数据 -func (this *EtcdMgr) InitPlatformPackage() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_PACKAGE_PREFIX) - res, err := this.GetValueWithPrefix(etcd.ETCDKEY_PACKAGE_PREFIX) - if err == nil { - for i := int64(0); i < res.Count; i++ { - var value webapi_proto.AppInfo - err = proto.Unmarshal(res.Kvs[i].Value, &value) - if err == nil { - if value.PlatformId == 0 { - value.PlatformId = int32(DefaultPlatformInt) - } - - PlatformMgrSingleton.PackageList[value.PackageName] = &value - PlatformMgrSingleton.PackageList[value.BundleId] = &value - //if _, ok := PlatformMgrSingleton.PromoterList[strconv.Itoa(int(value.PromoterId))]; !ok { - // PlatformMgrSingleton.PromoterList[strconv.Itoa(int(value.PromoterId))] = PlatformPromoter{ - // Platform: strconv.Itoa(int(value.Platform)), - // Promoter: strconv.Itoa(int(value.PromoterId)), - // Tag: value.Tag, - // } - //} - } else { - logger.Logger.Errorf("etcd read(%v) proto.Unmarshal err:%v", string(res.Kvs[i].Key), err) - } - } - if res.Header != nil { - return res.Header.Revision - } - } else { - logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_PACKAGE_PREFIX, err) - } - } - return -1 - } - - watchFunc := func(ctx context.Context, revision int64) { - // 监控数据变动 - this.GoWatch(ctx, revision, etcd.ETCDKEY_PACKAGE_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - var value webapi_proto.AppInfo - err := proto.Unmarshal(ev.Kv.Value, &value) - if err == nil { - if value.PlatformId == 0 { - value.PlatformId = int32(DefaultPlatformInt) - } - - PlatformMgrSingleton.PackageList[value.PackageName] = &value - PlatformMgrSingleton.PackageList[value.BundleId] = &value - //if _, ok := PlatformMgrSingleton.PromoterList[strconv.Itoa(int(value.PromoterId))]; !ok { - // PlatformMgrSingleton.PromoterList[strconv.Itoa(int(value.PromoterId))] = PlatformPromoter{ - // Platform: strconv.Itoa(int(value.Platform)), - // Promoter: strconv.Itoa(int(value.PromoterId)), - // Tag: value.Tag, - // } - //} - // - //var strPlatorm string - //var strChannel string - //var strPromoter string - //if value.Platform != 0 { - // strPlatorm = strconv.Itoa(int(value.Platform)) - //} - //if value.ChannelId != 0 { - // strChannel = strconv.Itoa(int(value.ChannelId)) - //} - //if value.PromoterId != 0 { - // strPromoter = strconv.Itoa(int(value.PromoterId)) - //} - //if value.AppStore != 1 { - // uptCnt := PlayerMgrSington.UpdateAllPlayerPackageTag(value.Tag, strPlatorm, strChannel, strPromoter, int32(value.PromoterTree), value.TagKey) - // logger.Logger.Infof("/api/game/UpsertPackageTag update(tag:%v, platform:%v, channel:%v, promoter:%v), updated cnt=%v", value.Tag, strPlatorm, strChannel, strPromoter, uptCnt) - // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - // return model.UpdateAllPlayerPackageTag(value.Tag, strPlatorm, strChannel, strPromoter, int32(value.PromoterTree), value.TagKey) - // }), nil, "UpdateAllPlayerPackageTag").Start() - //} - } else { - logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_PACKAGE_PREFIX, err) - } - } - } - return nil - }) - } - this.InitAndWatch(initFunc, watchFunc) -} - // 加载组配置 func (this *EtcdMgr) InitGameGroup() { initFunc := func() int64 { @@ -300,7 +37,7 @@ func (this *EtcdMgr) InitGameGroup() { res, err := this.GetValueWithPrefix(etcd.ETCDKEY_GROUPCONFIG_PREFIX) if err == nil { for i := int64(0); i < res.Count; i++ { - var value webapi_proto.GameConfigGroup + var value webapiproto.GameConfigGroup err = proto.Unmarshal(res.Kvs[i].Value, &value) if err == nil { PlatformGameGroupMgrSington.UpsertGameGroup(&value) @@ -325,7 +62,7 @@ func (this *EtcdMgr) InitGameGroup() { switch ev.Type { case clientv3.EventTypeDelete: case clientv3.EventTypePut: - var value webapi_proto.GameConfigGroup + var value webapiproto.GameConfigGroup err := proto.Unmarshal(ev.Kv.Value, &value) if err == nil { PlatformGameGroupMgrSington.UpsertGameGroup(&value) @@ -429,7 +166,7 @@ func (this *EtcdMgr) InitBlackList() { } for _, p := range targetPlayer { if p.sid != 0 { - p.Kickout(int32(login_proto.SSDisconnectTypeCode_SSDTC_BlackList)) + p.Kickout(int32(loginproto.SSDisconnectTypeCode_SSDTC_BlackList)) } else { LoginStateMgrSington.LogoutByAccount(p.AccountId) } @@ -447,617 +184,6 @@ func (this *EtcdMgr) InitBlackList() { this.InitAndWatch(initFunc, watchFunc) } -// -//// 加载平台公告配置 -//func (this *EtcdMgr) InitPlatformBulletin() { -// initFunc := func() int64 { -// if model.GameParamData.UseEtcd { -// logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_BULLETIN_PREFIX) -// res, err := this.GetValueWithPrefix(etcd.ETCDKEY_BULLETIN_PREFIX) -// if err == nil { -// for i := int64(0); i < res.Count; i++ { -// var info Bullet -// err = json.Unmarshal(res.Kvs[i].Value, &info) -// if err == nil { -// BulletMgrSington.BulletMsgList[info.Id] = &info -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_BULLETIN_PREFIX, err) -// } -// } -// if res.Header != nil { -// return res.Header.Revision -// } -// } else { -// logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_BULLETIN_PREFIX, err) -// } -// } -// return -1 -// } -// -// // 监控数据变动 -// watchFunc := func(ctx context.Context, revision int64) { -// this.GoWatch(ctx, revision, etcd.ETCDKEY_BULLETIN_PREFIX, func(res clientv3.WatchResponse) error { -// for _, ev := range res.Events { -// switch ev.Type { -// case clientv3.EventTypeDelete: -// dirs := strings.Split(string(ev.Kv.Key), "/") -// n := len(dirs) -// if n > 0 { -// last := dirs[n-1] -// id, err := strconv.Atoi(last) -// if err == nil { -// delete(BulletMgrSington.BulletMsgList, int32(id)) -// } -// } -// case clientv3.EventTypePut: -// var value Bullet -// err := json.Unmarshal(ev.Kv.Value, &value) -// if err == nil { -// BulletMgrSington.BulletMsgList[value.Id] = &value -// var bulletList []*login_proto.Bulletion -// bulletList = append(bulletList, &login_proto.Bulletion{ -// Id: proto.Int32(value.Id), -// NoticeTitle: proto.String(value.NoticeTitle), -// NoticeContent: proto.String(value.NoticeContent), -// UpdateTime: proto.String(value.UpdateTime), -// Sort: proto.Int32(value.Sort), -// }) -// var rawpack = &login_proto.SCBulletionInfo{ -// Id: proto.Int32(value.Id), -// BulletionList: bulletList, -// } -// proto.SetDefaults(rawpack) -// PlayerMgrSington.BroadcastMessageToPlatform(value.Platform, int(login_proto.LoginPacketID_PACKET_SC_BULLETIONINFO), rawpack) -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_BULLETIN_PREFIX, err) -// } -// } -// } -// return nil -// }) -// } -// -// this.InitAndWatch(initFunc, watchFunc) -//} -// -//// 加载平台招商代理配置 -//func (this *EtcdMgr) InitPlatformAgent() { -// initFunc := func() int64 { -// if model.GameParamData.UseEtcd { -// logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_AGENTCUSTOMER_PREFIX) -// res, err := this.GetValueWithPrefix(etcd.ETCDKEY_AGENTCUSTOMER_PREFIX) -// if err == nil { -// for i := int64(0); i < res.Count; i++ { -// var info Customer -// err = json.Unmarshal(res.Kvs[i].Value, &info) -// if err == nil { -// CustomerMgrSington.CustomerMsgList[info.Id] = &info -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_AGENTCUSTOMER_PREFIX, err) -// } -// } -// if res.Header != nil { -// return res.Header.Revision -// } -// } else { -// logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_AGENTCUSTOMER_PREFIX, err) -// } -// } -// return -1 -// } -// -// // 监控数据变动 -// watchFunc := func(ctx context.Context, revision int64) { -// this.GoWatch(ctx, revision, etcd.ETCDKEY_AGENTCUSTOMER_PREFIX, func(res clientv3.WatchResponse) error { -// for _, ev := range res.Events { -// switch ev.Type { -// case clientv3.EventTypeDelete: -// dirs := strings.Split(string(ev.Kv.Key), "/") -// n := len(dirs) -// if n > 0 { -// last := dirs[n-1] -// id, err := strconv.Atoi(last) -// if err == nil { -// delete(CustomerMgrSington.CustomerMsgList, int32(id)) -// } -// } -// case clientv3.EventTypePut: -// var value Customer -// err := json.Unmarshal(ev.Kv.Value, &value) -// if err == nil { -// CustomerMgrSington.CustomerMsgList[value.Id] = &value -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_AGENTCUSTOMER_PREFIX, err) -// } -// } -// } -// return nil -// }) -// } -// -// this.InitAndWatch(initFunc, watchFunc) -//} - -// 加载平台签到活动配置 -func (this *EtcdMgr) InitPlatformActSignin() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_SIGNIN_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_SIGNIN_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var value SignConfig - // err = json.Unmarshal(res.Kvs[i].Value, &value) - // if err == nil { - // if value.StartAct > 0 { - // ActSignMgrSington.SignConfigs[value.Platform] = value - // //logger.Logger.Trace("value:", value) - // } - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_SIGNIN_PREFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_SIGNIN_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_SIGNIN_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - dirs := strings.Split(string(ev.Kv.Key), "/") - n := len(dirs) - if n > 0 { - //platform := dirs[n-1] - //delete(ActSignMgrSington.SignConfigs, platform) - } - case clientv3.EventTypePut: - //var value SignConfig - //err := json.Unmarshal(ev.Kv.Value, &value) - //if err == nil { - // ActSignMgrSington.ModifyConfig(value) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_SIGNIN_PREFIX, err) - //} - } - } - return nil - }) - } - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载平台任务活动配置 -func (this *EtcdMgr) InitPlatformActTask() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_TASK_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_TASK_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var taskConfig APITaskConfigs - // err = json.Unmarshal(res.Kvs[i].Value, &taskConfig) - // if err == nil { - // gtpf := &PlatformTaskConfig{ - // ConfigByTaskId: make(map[int32]TaskConfig), - // StartAct: taskConfig.StartAct, - // Platform: taskConfig.Platform, - // ConfigVer: taskConfig.ConfigVer, - // } - // ActTaskMgrSington.ConfigByPlatform[gtpf.Platform] = gtpf - // for _, config := range taskConfig.Datas { - // if config.StartAct > 0 { - // gtpf.ConfigByTaskId[config.Id] = config - // } - // } - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_TASK_PREFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_TASK_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_TASK_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var taskConfig APITaskConfigs - //err := json.Unmarshal(ev.Kv.Value, &taskConfig) - //if err == nil { - // gtpf := PlatformTaskConfig{ - // ConfigByTaskId: make(map[int32]TaskConfig), - // StartAct: taskConfig.StartAct, - // Platform: taskConfig.Platform, - // ConfigVer: taskConfig.ConfigVer, - // } - // gtpf.ConfigByTaskId = make(map[int32]TaskConfig) - // for _, v := range taskConfig.Datas { - // gtpf.ConfigByTaskId[v.Id] = v - // } - // ActTaskMgrSington.ModifyConfig(gtpf) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_TASK_PREFIX, err) - //} - } - } - return nil - }) - } - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载平台财神任务活动配置 -func (this *EtcdMgr) InitPlatformActGoldTask() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_GOLDTASK_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_GOLDTASK_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var taskConfig APIGoldTaskConfigs - // err = json.Unmarshal(res.Kvs[i].Value, &taskConfig) - // if err == nil { - // gtpf := &GoldTaskPlateformConfig{ - // ConfigByTaskId: make(map[int32]GoldTaskConfig), - // StartAct: taskConfig.StartAct, - // Platform: taskConfig.Platform, - // ConfigVer: taskConfig.ConfigVer, - // } - // ActGoldTaskMgrSington.ConfigByPlateform[gtpf.Platform] = gtpf - // for _, config := range taskConfig.Datas { - // if config.StartAct > 0 { - // ActGoldTaskMgrSington.AddConfig(config, taskConfig.Platform, false) - // } - // } - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GOLDTASK_PREFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GOLDTASK_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_GOLDTASK_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var taskConfig APIGoldTaskConfigs - //err := json.Unmarshal(ev.Kv.Value, &taskConfig) - //if err == nil { - // gtpf := GoldTaskPlateformConfig{ - // ConfigByTaskId: make(map[int32]GoldTaskConfig), - // StartAct: taskConfig.StartAct, - // Platform: taskConfig.Platform, - // ConfigVer: taskConfig.ConfigVer, - // } - // gtpf.ConfigByTaskId = make(map[int32]GoldTaskConfig) - // for _, v := range taskConfig.Datas { - // gtpf.ConfigByTaskId[v.TaskId] = v - // } - // ActGoldTaskMgrSington.ModifyConfig(gtpf) - // if curPlateformConfig, exist := ActGoldTaskMgrSington.ConfigByPlateform[gtpf.Platform]; exist { - // //移除task - // for curTaskId, curTaskConfig := range curPlateformConfig.ConfigByTaskId { - // bFindTask := false - // if _, exist := gtpf.ConfigByTaskId[curTaskId]; exist { - // bFindTask = true - // } - // if !bFindTask { - // ActGoldTaskMgrSington.RemoveConfig(curTaskConfig.TaskId, gtpf.Platform, true) - // } - // } - // } - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GOLDTASK_PREFIX, err) - //} - } - } - return nil - }) - } - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载平台财神降临活动配置 -func (this *EtcdMgr) InitPlatformActGoldCome() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_GOLDCOME_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_GOLDCOME_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var taskConfig APIGoldComeConfig - // err = json.Unmarshal(res.Kvs[i].Value, &taskConfig) - // if err == nil { - // gcpf := &GoldComePlateformConfig{ - // ConfigByTaskId: make(map[int32]GoldComeConfig), - // StartAct: taskConfig.StartAct, - // Platform: taskConfig.Platform, - // ConfigVer: taskConfig.ConfigVer, - // RobotType: taskConfig.RobotType, - // MinPlayerCount: taskConfig.MinPlayerCount, - // } - // ActGoldComeMgrSington.ConfigByPlateform[gcpf.Platform] = gcpf - // for _, config := range taskConfig.Datas { - // if config.StartAct > 0 { - // ActGoldComeMgrSington.AddConfig(config, taskConfig.Platform, false) - // } - // } - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GOLDCOME_PREFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GOLDCOME_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_GOLDCOME_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var taskConfig APIGoldComeConfig - //err := json.Unmarshal(ev.Kv.Value, &taskConfig) - //if err == nil { - // //1, 修改成最新配置 - // var config GoldComePlateformConfig - // config.Platform = taskConfig.Platform - // config.ConfigVer = taskConfig.ConfigVer - // config.StartAct = taskConfig.StartAct - // config.RobotType = taskConfig.RobotType - // config.MinPlayerCount = taskConfig.MinPlayerCount - // config.ConfigByTaskId = make(map[int32]GoldComeConfig) - // for _, v := range taskConfig.Datas { - // config.ConfigByTaskId[v.TaskId] = v - // } - // ActGoldComeMgrSington.ModifyConfig(config) - // - // if curPlateformConfig, exist := ActGoldTaskMgrSington.ConfigByPlateform[taskConfig.Platform]; exist { - // //移除task - // for curTaskId, curTaskConfig := range curPlateformConfig.ConfigByTaskId { - // bFindTask := false - // if _, exist := config.ConfigByTaskId[curTaskId]; exist { - // bFindTask = true - // } - // if !bFindTask { - // ActGoldComeMgrSington.RemoveConfig(curTaskConfig.TaskId, config.Platform, true) - // } - // } - // } - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GOLDCOME_PREFIX, err) - //} - } - } - return nil - }) - } - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载平台在线奖励活动配置 -func (this *EtcdMgr) InitPlatformActOnlineReward() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_ONLINEREWARD_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_ONLINEREWARD_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var value PlatformOnlineRewardConfig - // err = json.Unmarshal(res.Kvs[i].Value, &value) - // if err == nil { - // ActOnlineRewardMgrSington.Configs[value.Platform] = value - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_ONLINEREWARD_PREFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_ONLINEREWARD_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_ONLINEREWARD_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var value PlatformOnlineRewardConfig - //err := json.Unmarshal(ev.Kv.Value, &value) - //if err == nil { - // ActOnlineRewardMgrSington.ModifyConfig(value) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_ONLINEREWARD_PREFIX, err) - //} - } - } - return nil - }) - } - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载平台转盘活动配置 -func (this *EtcdMgr) InitPlatformActLuckyTurntable() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_LUCKLYTURNTABLE_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_LUCKLYTURNTABLE_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var value PlatformLuckyTurntableConfig - // err = json.Unmarshal(res.Kvs[i].Value, &value) - // if err == nil { - // ActLuckyTurntableMgrSington.AdjustForBackgroundConfig(value) - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_LUCKLYTURNTABLE_PREFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_LUCKLYTURNTABLE_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_LUCKLYTURNTABLE_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var value PlatformLuckyTurntableConfig - //err := json.Unmarshal(ev.Kv.Value, &value) - //if err == nil { - // ActLuckyTurntableMgrSington.ModifyConfig(value) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_LUCKLYTURNTABLE_PREFIX, err) - //} - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载余额宝配置 -func (this *EtcdMgr) InitPlatformActYeb() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_YEB_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_YEB_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var value YebConfig - // err = json.Unmarshal(res.Kvs[i].Value, &value) - // if err == nil { - // ActYebMgrSington.AdjustForBackgroundConfig(value, true, nil) - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_YEB_PREFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_YEB_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_YEB_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var cfg YebConfig - //err := json.Unmarshal(ev.Kv.Value, &cfg) - //if err == nil { - // ActYebMgrSington.ModifyConfig(cfg) - // if cfg.StartAct <= 0 { - // type tempObject struct { - // newMsgs []*model.Message - // playerDatas []model.PlayerData - // } - // - // task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - // tmpObj := &tempObject{ - // newMsgs: make([]*model.Message, 0), - // playerDatas: make([]model.PlayerData, 0), - // } - // - // players := model.GetYebPlayersDatas(cfg.Platform) - // for _, p := range players { - // pp := PlayerMgrSington.GetPlayerBySnId(p.SnId) - // if pp == nil { - // // 计算离线用户利息 - // ActYebMgrSington.CalcYebInterest(nil, &p) - // } - // - // var otherParams []int32 - // strTitle := i18n.Tr("cn", "YebTurnOffTitle") - // strContent := i18n.Tr("cn", "YebTurnOffContent", float64(p.YebData.Balance)/100) - // newMsg := model.NewMessage("", int32(0), p.SnId, int32(model.MSGTYPE_YEB), strTitle, strContent, p.YebData.Balance, - // model.MSGSTATE_UNREAD, time.Now().Unix(), model.MSGATTACHSTATE_DEFAULT, "", otherParams, cfg.Platform) - // err := model.InsertMessage(newMsg) - // if err != nil { - // logger.Logger.Errorf("UpdateYebConfig model.InsertMessage snid %v err %v", p.SnId, err) - // continue - // } - // - // tmpObj.newMsgs = append(tmpObj.newMsgs, newMsg) - // tmpObj.playerDatas = append(tmpObj.playerDatas, p) - // - // err = model.ResetYeb(p.SnId, "") - // if err != nil { - // logger.Logger.Errorf("UpdateYebConfig err %v", err) - // continue - // } - // - // if pp != nil { - // pp.YebData.TotalIncome = 0 - // pp.YebData.PrevIncome = 0 - // pp.YebData.Balance = 0 - // pp.YebData.InterestTs = 0 - // } - // } - // - // model.RemoveActYebLog(cfg.Platform) - // return tmpObj - // }), task.CompleteNotifyWrapper(func(data interface{}, t *task.Task) { - // if obj, ok := data.(*tempObject); ok { - // for i, p := range obj.playerDatas { - // pp := PlayerMgrSington.GetPlayerBySnId(p.SnId) - // if pp != nil { - // pp.AddMessage(obj.newMsgs[i]) - // } - // } - // } else { - // logger.Logger.Error("UpdateYebConfig task result data covert failed.") - // } - // }), "UpdateYebConfig").Start() - // } - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_YEB_PREFIX, err) - //} - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - // 初始化返利数据 func (this *EtcdMgr) InitRebateConfig() { initFunc := func() int64 { @@ -1170,104 +296,6 @@ func (this *EtcdMgr) InitPromoterConfig() { this.InitAndWatch(initFunc, watchFunc) } -// 初始化微信分享彩金配置 -func (this *EtcdMgr) InitWeiXinShare() { - initFunc := func() int64 { - if !model.GameParamData.UseEtcd { - return 0 - } - logger.Logger.Info("ETCD 初始化分享彩金配置 拉取数据:", etcd.ETCDKEY_ACT_WEIXIN_SHARE_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_WEIXIN_SHARE_PREFIX) - //if err != nil { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_WEIXIN_SHARE_PREFIX, err) - // return - //} - //for i := int64(0); i < res.Count; i++ { - // var cfg ShareConfig - // if err = json.Unmarshal(res.Kvs[i].Value, &cfg); err != nil { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_WEIXIN_SHARE_PREFIX, err) - // continue - // } - // weiXinShareMgr.AddConfig(&cfg) - //} - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_WEIXIN_SHARE_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - //dirs := strings.Split(string(ev.Kv.Key), "/") - //if len(dirs) > 1 { - // weiXinShareMgr.RemoveConfig(dirs[len(dirs)-1]) - //} - - case clientv3.EventTypePut: - //var cfg ShareConfig - //err := json.Unmarshal(ev.Kv.Value, &cfg) - //if err == nil { - // weiXinShareMgr.AddConfig(&cfg) - // weiXinShareMgr.BroadcastMessageToPlatform(cfg.Platform, cfg.Status) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_WEIXIN_SHARE_PREFIX, err) - //} - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载vip活动配置 -func (this *EtcdMgr) InitPlatformActVip() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_VIP_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_VIP_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var vipConfig ActVipPlateformConfig - // err = json.Unmarshal(res.Kvs[i].Value, &vipConfig) - // if err == nil { - // ActVipMgrSington.AddConfig(&vipConfig, vipConfig.Platform) - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_VIP_PREFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_VIP_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_VIP_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var vipConfig ActVipPlateformConfig - //err := json.Unmarshal(ev.Kv.Value, &vipConfig) - //if err == nil { - // ActVipMgrSington.AddConfig(&vipConfig, vipConfig.Platform) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_GOLDCOME_PREFIX, err) - //} - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - // 加载活动give配置 func (this *EtcdMgr) InitPlatformAct() { initFunc := func() int64 { @@ -1317,654 +345,6 @@ func (this *EtcdMgr) InitPlatformAct() { this.InitAndWatch(initFunc, watchFunc) } -//加载活动give配置 -//func (this *EtcdMgr) InitPlatformPayAct() { -// if model.GameParamData.UseEtcd { -// logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_PAY_PREFIX) -// res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_PAY_PREFIX) -// if err == nil { -// for i := int64(0); i < res.Count; i++ { -// var vipConfig PayActPlateformConfig -// err = json.Unmarshal(res.Kvs[i].Value, &vipConfig) -// if err == nil { -// PayActMgrSington.AddPayConfig(&vipConfig, vipConfig.Platform) -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_PAY_PREFIX, err) -// } -// } -// } else { -// logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_PAY_PREFIX, err) -// } -// } -// -// // 监控数据变动 -// this.GoWatch(etcd.ETCDKEY_ACT_PAY_PREFIX, func(res clientv3.WatchResponse) error { -// for _, ev := range res.Events { -// switch ev.Type { -// case clientv3.EventTypeDelete: -// case clientv3.EventTypePut: -// var vipConfig PayActPlateformConfig -// err := json.Unmarshal(ev.Kv.Value, &vipConfig) -// if err == nil { -// PayActMgrSington.AddPayConfig(&vipConfig, vipConfig.Platform) -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_PAY_PREFIX, err) -// } -// } -// } -// return nil -// }) -//} - -func (this *EtcdMgr) InitActLoginRandCoinConfig() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 红包数据 拉取数据:", etcd.ETCDKEY_ACT_RANDCOIN_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_RANDCOIN_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var actConfig = &ActConfig{} - // err = json.Unmarshal(res.Kvs[i].Value, actConfig) - // if err != nil { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_RANDCOIN_PREFIX, err) - // continue - // } - // actRandCoinMgr.SetConfig(actConfig) - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_RANDCOIN_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_RANDCOIN_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypePut: - //var actConfig = &ActConfig{} - //err := json.Unmarshal(ev.Kv.Value, &actConfig) - //if err == nil { - // actRandCoinMgr.SetConfig(actConfig) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_RANDCOIN_PREFIX, err) - //} - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载活动fpay配置 -func (this *EtcdMgr) InitPlatformActFPay() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_FPAY_PREFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_FPAY_PREFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var vipConfig ActFPayPlateformConfig - // err = json.Unmarshal(res.Kvs[i].Value, &vipConfig) - // if err == nil { - // ActFPayMgrSington.AddConfig(&vipConfig, vipConfig.Platform) - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_FPAY_PREFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_FPAY_PREFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_FPAY_PREFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var vipConfig ActFPayPlateformConfig - //err := json.Unmarshal(ev.Kv.Value, &vipConfig) - //if err == nil { - // ActFPayMgrSington.AddConfig(&vipConfig, vipConfig.Platform) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_FPAY_PREFIX, err) - //} - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -////加载杀率配置 -//func (this *EtcdMgr) InitPlatformProfitControl() { -// if model.GameParamData.UseEtcd { -// logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_PLATFORM_PROFITCONTROL) -// res, err := this.GetValueWithPrefix(etcd.ETCDKEY_PLATFORM_PROFITCONTROL) -// if err == nil { -// for i := int64(0); i < res.Count; i++ { -// var cfg ProfitControlConfig -// err = json.Unmarshal(res.Kvs[i].Value, &cfg) -// if err == nil { -// ProfitControlMgrSington.UpdateConfig(&cfg, true) -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_PLATFORM_PROFITCONTROL, err) -// } -// } -// } else { -// logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_PLATFORM_PROFITCONTROL, err) -// } -// } -// -// // 监控数据变动 -// this.GoWatch(etcd.ETCDKEY_PLATFORM_PROFITCONTROL, func(res clientv3.WatchResponse) error { -// for _, ev := range res.Events { -// switch ev.Type { -// case clientv3.EventTypeDelete: -// case clientv3.EventTypePut: -// var cfg ProfitControlConfig -// err := json.Unmarshal(ev.Kv.Value, &cfg) -// if err == nil { -// ProfitControlMgrSington.UpdateConfig(&cfg, false) -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_PLATFORM_PROFITCONTROL, err) -// } -// } -// } -// return nil -// }) -//} - -// 加载比赛配置 -//func (this *EtcdMgr) InitMatchConfig() { -// initFunc := func() int64 { -// if model.GameParamData.UseEtcd { -// logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_MATCH_PROFIX) -// //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_MATCH_PROFIX) -// //if err == nil { -// // for i := int64(0); i < res.Count; i++ { -// // var cfg MatchConfig -// // err = json.Unmarshal(res.Kvs[i].Value, &cfg) -// // if err == nil { -// // MatchMgrSington.UpdateConfig(&cfg, true) -// // } else { -// // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_MATCH_PROFIX, err) -// // } -// // } -// //} else { -// // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_MATCH_PROFIX, err) -// //} -// } -// return -1 -// } -// -// // 监控数据变动 -// watchFunc := func(ctx context.Context, revision int64) { -// this.GoWatch(ctx, revision, etcd.ETCDKEY_MATCH_PROFIX, func(res clientv3.WatchResponse) error { -// for _, ev := range res.Events { -// switch ev.Type { -// case clientv3.EventTypeDelete: -// case clientv3.EventTypePut: -// //var cfg MatchConfig -// //err := json.Unmarshal(ev.Kv.Value, &cfg) -// //if err == nil { -// // MatchMgrSington.UpdateConfig(&cfg, false) -// //} else { -// // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_MATCH_PROFIX, err) -// //} -// } -// } -// return nil -// }) -// } -// -// this.InitAndWatch(initFunc, watchFunc) -//} - -// 加载比赛券活动配置 -func (this *EtcdMgr) InitActTicketConfig() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_ACT_TICKET_PROFIX) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_TICKET_PROFIX) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var cfg ActTicketConfig - // err = json.Unmarshal(res.Kvs[i].Value, &cfg) - // if err == nil { - // ActTicketMgrSington.UpdateConfig(&cfg, true) - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_TICKET_PROFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_TICKET_PROFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_ACT_TICKET_PROFIX, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var cfg ActTicketConfig - //err := json.Unmarshal(ev.Kv.Value, &cfg) - //if err == nil { - // ActTicketMgrSington.UpdateConfig(&cfg, false) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_ACT_TICKET_PROFIX, err) - //} - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载积分商城配置 -func (this *EtcdMgr) InitGradeShopConfig() { - initFunc := func() int64 { - - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_MATCH_GRADESHOP) - //res, err := this.GetValueWithPrefix(etcd.ETCDKEY_MATCH_GRADESHOP) - //if err == nil { - // for i := int64(0); i < res.Count; i++ { - // var cfg GradeShopConfig - // err = json.Unmarshal(res.Kvs[i].Value, &cfg) - // if err == nil { - // GradeShopMgrSington.UpdateConfig(&cfg, true) - // } else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_MATCH_PROFIX, err) - // } - // } - //} else { - // logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_MATCH_PROFIX, err) - //} - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_MATCH_GRADESHOP, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - //var cfg GradeShopConfig - //err := json.Unmarshal(ev.Kv.Value, &cfg) - //if err == nil { - // GradeShopMgrSington.UpdateConfig(&cfg, false) - //} else { - // logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_MATCH_PROFIX, err) - //} - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -//// 加载用户分层配置 -//func (this *EtcdMgr) InitLogicLevelConfig() { -// -// initFunc := func() int64 { -// if model.GameParamData.UseEtcd { -// logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_CONFIG_LOGICLEVEL) -// res, err := this.GetValueWithPrefix(etcd.ETCDKEY_CONFIG_LOGICLEVEL) -// if err == nil { -// for i := int64(0); i < res.Count; i++ { -// var cfg LogicLevelConfig -// err = json.Unmarshal(res.Kvs[i].Value, &cfg) -// if err == nil { -// LogicLevelMgrSington.UpdateConfig(&cfg) -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_CONFIG_LOGICLEVEL, err) -// } -// } -// if res.Header != nil { -// return res.Header.Revision -// } -// } else { -// logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_CONFIG_LOGICLEVEL, err) -// } -// } -// return -1 -// } -// -// // 监控数据变动 -// watchFunc := func(ctx context.Context, revision int64) { -// this.GoWatch(ctx, revision, etcd.ETCDKEY_CONFIG_LOGICLEVEL, func(res clientv3.WatchResponse) error { -// for _, ev := range res.Events { -// switch ev.Type { -// case clientv3.EventTypeDelete: -// case clientv3.EventTypePut: -// var cfg LogicLevelConfig -// err := json.Unmarshal(ev.Kv.Value, &cfg) -// if err == nil { -// LogicLevelMgrSington.UpdateConfig(&cfg) -// } else { -// logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_CONFIG_LOGICLEVEL, err) -// } -// } -// } -// return nil -// }) -// } -// -// this.InitAndWatch(initFunc, watchFunc) -//} - -// 加载全局游戏开关 -func (this *EtcdMgr) InitGameGlobalStatus() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_GAME_CONFIG_GLOBAL) - res, err := this.GetValueWithPrefix(etcd.ETCDKEY_GAME_CONFIG_GLOBAL) - if err == nil { - for i := int64(0); i < res.Count; i++ { - var cfg webapi_proto.GameConfigGlobal - err = proto.Unmarshal(res.Kvs[i].Value, &cfg) - if err == nil { - for _, v := range cfg.GetGameStatus() { - gameId := v.GetGameId() - status := v.GetStatus() - PlatformMgrSingleton.GameStatus[gameId] = status - } - } else { - logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_GAME_CONFIG_GLOBAL, err) - } - } - if res.Header != nil { - return res.Header.Revision - } - } else { - logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_GAME_CONFIG_GLOBAL, err) - } - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_GAME_CONFIG_GLOBAL, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - var cfg webapi_proto.GameConfigGlobal - err := proto.Unmarshal(ev.Kv.Value, &cfg) - if err == nil { - cfgs := make([]*hall_proto.GameConfig1, 0) - for _, v := range cfg.GetGameStatus() { - gameId := v.GetGameId() // gamefreeid - status := v.GetStatus() - - if PlatformMgrSingleton.GameStatus[gameId] != status { - cfgs = append(cfgs, &hall_proto.GameConfig1{ - LogicId: gameId, - Status: status, - }) - } - PlatformMgrSingleton.GameStatus[gameId] = status - } - PlatformMgrSingleton.ChangeGameStatus(cfgs) - } else { - logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_GAME_CONFIG_GLOBAL, err) - } - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// 界面入口开关 -func (this *EtcdMgr) InitEntrySwitch() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_PACKAGE_ENTRYSWITCH) - res, err := this.GetValueWithPrefix(etcd.ETCDKEY_PACKAGE_ENTRYSWITCH) - if err == nil { - for i := int64(0); i < res.Count; i++ { - var cfg webapi_proto.EntrySwitch - err = proto.Unmarshal(res.Kvs[i].Value, &cfg) - if err == nil { - PlatformMgrSingleton.UpdateEntrySwitch(&cfg) - } else { - logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_PACKAGE_ENTRYSWITCH, err) - } - } - if res.Header != nil { - return res.Header.Revision - } - } else { - logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_PACKAGE_ENTRYSWITCH, err) - } - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_PACKAGE_ENTRYSWITCH, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - var config webapi_proto.EntrySwitch - err := proto.Unmarshal(ev.Kv.Value, &config) - if err == nil { - PlatformMgrSingleton.UpdateEntrySwitch(&config) - PlatformMgrSingleton.ChangeEntrySwitch(config.Platform, &config) - } else { - logger.Logger.Errorf("etcd read(%v) proto.Unmarshal err:%v", string(ev.Kv.Key), err) - } - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载兑换 -func (this *EtcdMgr) InitExchangeShop() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_SHOP_EXCHANGE) - res, err := this.GetValueWithPrefix(etcd.ETCDKEY_SHOP_EXCHANGE) - if err == nil { - for i := int64(0); i < res.Count; i++ { - cfg := &webapi_proto.ExchangeShopList{} - //msg := &webapi.ASSrvCtrlClose{} - err = proto.Unmarshal(res.Kvs[i].Value, cfg) - if err == nil { - ShopMgrSington.UpExShop(cfg) - } else { - logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_SHOP_EXCHANGE, err) - } - } - if res.Header != nil { - return res.Header.Revision - } - } else { - logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_SHOP_EXCHANGE, err) - } - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_SHOP_EXCHANGE, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - cfg := &webapi_proto.ExchangeShopList{} - err := proto.Unmarshal(ev.Kv.Value, cfg) - if err == nil { - ShopMgrSington.UpExShop(cfg) - } else { - logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_SHOP_EXCHANGE, err) - } - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// 加载公告 -func (this *EtcdMgr) InitCommonNotice() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_GAME_NOTICE) - res, err := this.GetValueWithPrefix(etcd.ETCDKEY_GAME_NOTICE) - if err == nil { - for i := int64(0); i < res.Count; i++ { - - var cfgs webapi_proto.CommonNoticeList - err = proto.Unmarshal(res.Kvs[i].Value, &cfgs) - - if err == nil && len(cfgs.List) != 0 { - //now := time.Now().Unix() - //for i := 0; i < len(cfgs.List); { - // if cfgs.List[i].GetEndTime() < now || cfgs.List[i].GetStartTime() > now { - // cfgs.List = append(cfgs.List[:i], cfgs.List[i+1:]...) - // } else { - // i++ - // } - //} - - PlatformMgrSingleton.UpdateCommonNotices(&cfgs) - - } - } - if res.Header != nil { - return res.Header.Revision - } - } else { - logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_GAME_NOTICE, err) - } - - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_GAME_NOTICE, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - var cfgs webapi_proto.CommonNoticeList - err := proto.Unmarshal(ev.Kv.Value, &cfgs) - - if err == nil { - - //now := time.Now().Unix() - //for i := 0; i < len(cfgs.List); { - // if cfgs.List[i].GetEndTime() < now || cfgs.List[i].GetStartTime() > now { - // cfgs.List = append(cfgs.List[:i], cfgs.List[i+1:]...) - // } else { - // i++ - // } - //} - - PlatformMgrSingleton.UpdateCommonNotices(&cfgs) - // 通知公共变更 - for _, v := range PlayerMgrSington.playerOfPlatform[cfgs.Platform] { - if v != nil && v.IsOnLine() { - v.SendToClient(int(hall_proto.GameHallPacketID_PACKET_SC_NoticeChange), &hall_proto.SCNoticeChange{}) - } - } - } else { - logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_GAME_NOTICE, err) - } - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - -// InitGameMatchDate 加载比赛配置 -func (this *EtcdMgr) InitGameMatchDate() { - initFunc := func() int64 { - if model.GameParamData.UseEtcd { - logger.Logger.Info("ETCD 拉取数据:", etcd.ETCDKEY_GAME_MATCH) - res, err := this.GetValueWithPrefix(etcd.ETCDKEY_GAME_MATCH) - if err == nil { - for i := int64(0); i < res.Count; i++ { - var cfgs webapi_proto.GameMatchDateList - err = proto.Unmarshal(res.Kvs[i].Value, &cfgs) - if err == nil && len(cfgs.List) != 0 { - TournamentMgr.UpdateData(true, &cfgs) - } - } - if res.Header != nil { - return res.Header.Revision - } - } else { - logger.Logger.Errorf("etcd get WithPrefix(%v) panic:%v", etcd.ETCDKEY_GAME_MATCH, err) - } - - } - return -1 - } - - // 监控数据变动 - watchFunc := func(ctx context.Context, revision int64) { - this.GoWatch(ctx, revision, etcd.ETCDKEY_GAME_MATCH, func(res clientv3.WatchResponse) error { - for _, ev := range res.Events { - switch ev.Type { - case clientv3.EventTypeDelete: - case clientv3.EventTypePut: - var cfgs webapi_proto.GameMatchDateList - err := proto.Unmarshal(ev.Kv.Value, &cfgs) - if err == nil && len(cfgs.List) != 0 { - TournamentMgr.UpdateData(false, &cfgs) - } else { - logger.Logger.Errorf("etcd desc WithPrefix(%v) panic:%v", etcd.ETCDKEY_GAME_MATCH, err) - } - } - } - return nil - }) - } - - this.InitAndWatch(initFunc, watchFunc) -} - // 加载七日签到 func (this *EtcdMgr) InitSign7() { initFunc := func() int64 { @@ -1973,7 +353,7 @@ func (this *EtcdMgr) InitSign7() { res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_7SIGN) if err == nil { for i := int64(0); i < res.Count; i++ { - cfg := &webapi_proto.Welfare7SignDateList{} + cfg := &webapiproto.Welfare7SignDateList{} //msg := &webapi.ASSrvCtrlClose{} err = proto.Unmarshal(res.Kvs[i].Value, cfg) if err == nil && cfg.Platform != "" { @@ -1999,7 +379,7 @@ func (this *EtcdMgr) InitSign7() { switch ev.Type { case clientv3.EventTypeDelete: case clientv3.EventTypePut: - cfg := &webapi_proto.Welfare7SignDateList{} + cfg := &webapiproto.Welfare7SignDateList{} err := proto.Unmarshal(ev.Kv.Value, cfg) if err == nil && cfg.Platform != "" { WelfareMgrSington.UpdateSign7(cfg) @@ -2023,7 +403,7 @@ func (this *EtcdMgr) InitTurnplate() { res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_TURNPLATE) if err == nil { for i := int64(0); i < res.Count; i++ { - cfg := &webapi_proto.WelfareTurnplateDateList{} + cfg := &webapiproto.WelfareTurnplateDateList{} //msg := &webapi.ASSrvCtrlClose{} err = proto.Unmarshal(res.Kvs[i].Value, cfg) if err == nil && cfg.Platform != "" { @@ -2049,7 +429,7 @@ func (this *EtcdMgr) InitTurnplate() { switch ev.Type { case clientv3.EventTypeDelete: case clientv3.EventTypePut: - cfg := &webapi_proto.WelfareTurnplateDateList{} + cfg := &webapiproto.WelfareTurnplateDateList{} err := proto.Unmarshal(ev.Kv.Value, cfg) if err == nil && cfg.Platform != "" { WelfareMgrSington.UpdateTurnplate(cfg) @@ -2073,7 +453,7 @@ func (this *EtcdMgr) InitBlindBox() { res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_BLINDBOX) if err == nil { for i := int64(0); i < res.Count; i++ { - cfg := &webapi_proto.WelfareBlindBoxDataList{} + cfg := &webapiproto.WelfareBlindBoxDataList{} //msg := &webapi.ASSrvCtrlClose{} err = proto.Unmarshal(res.Kvs[i].Value, cfg) if err == nil && cfg.Platform != "" { @@ -2099,7 +479,7 @@ func (this *EtcdMgr) InitBlindBox() { switch ev.Type { case clientv3.EventTypeDelete: case clientv3.EventTypePut: - cfg := &webapi_proto.WelfareBlindBoxDataList{} + cfg := &webapiproto.WelfareBlindBoxDataList{} err := proto.Unmarshal(ev.Kv.Value, cfg) if err == nil && cfg.Platform != "" { WelfareMgrSington.UpdateBlindBox(cfg) @@ -2123,7 +503,7 @@ func (this *EtcdMgr) InitFirstPay() { res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_FIRSTPAY) if err == nil { for i := int64(0); i < res.Count; i++ { - cfg := &webapi_proto.WelfareFirstPayDataList{} + cfg := &webapiproto.WelfareFirstPayDataList{} //msg := &webapi.ASSrvCtrlClose{} err = proto.Unmarshal(res.Kvs[i].Value, cfg) if err == nil && cfg.Platform != "" { @@ -2149,7 +529,7 @@ func (this *EtcdMgr) InitFirstPay() { switch ev.Type { case clientv3.EventTypeDelete: case clientv3.EventTypePut: - cfg := &webapi_proto.WelfareFirstPayDataList{} + cfg := &webapiproto.WelfareFirstPayDataList{} err := proto.Unmarshal(ev.Kv.Value, cfg) if err == nil && cfg.Platform != "" { WelfareMgrSington.UpdateFirstPay(cfg) @@ -2173,7 +553,7 @@ func (this *EtcdMgr) InitContinuousPay() { res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_CONTINUOUSPAY) if err == nil { for i := int64(0); i < res.Count; i++ { - cfg := &webapi_proto.WelfareContinuousPayDataList{} + cfg := &webapiproto.WelfareContinuousPayDataList{} //msg := &webapi.ASSrvCtrlClose{} err = proto.Unmarshal(res.Kvs[i].Value, cfg) if err == nil && cfg.Platform != "" { @@ -2199,7 +579,7 @@ func (this *EtcdMgr) InitContinuousPay() { switch ev.Type { case clientv3.EventTypeDelete: case clientv3.EventTypePut: - cfg := &webapi_proto.WelfareContinuousPayDataList{} + cfg := &webapiproto.WelfareContinuousPayDataList{} err := proto.Unmarshal(ev.Kv.Value, cfg) if err == nil && cfg.Platform != "" { WelfareMgrSington.UpdateContinuousPay(cfg) @@ -2223,7 +603,7 @@ func (this *EtcdMgr) InitUpdateVIPcfg() { res, err := this.GetValueWithPrefix(etcd.ETCDKEY_VIP_CFG) if err == nil { for i := int64(0); i < res.Count; i++ { - cfg := &webapi_proto.VIPcfgDataList{} + cfg := &webapiproto.VIPcfgDataList{} //msg := &webapi.ASSrvCtrlClose{} err = proto.Unmarshal(res.Kvs[i].Value, cfg) if err == nil && cfg.Platform != "" { @@ -2249,7 +629,7 @@ func (this *EtcdMgr) InitUpdateVIPcfg() { switch ev.Type { case clientv3.EventTypeDelete: case clientv3.EventTypePut: - cfg := &webapi_proto.VIPcfgDataList{} + cfg := &webapiproto.VIPcfgDataList{} err := proto.Unmarshal(ev.Kv.Value, cfg) if err == nil && cfg.Platform != "" { VipMgrSington.UpdateVIPcfg(cfg) @@ -2273,7 +653,7 @@ func (this *EtcdMgr) InitUpdateChessRankcfg() { res, err := this.GetValueWithPrefix(etcd.ETCDKEY_CHESSRANK_CFG) if err == nil { for i := int64(0); i < res.Count; i++ { - cfg := &webapi_proto.ChessRankcfgData{} + cfg := &webapiproto.ChessRankcfgData{} err = proto.Unmarshal(res.Kvs[i].Value, cfg) if err == nil && cfg.Platform != "" { ChessRankMgrSington.UpdateChessRankConfig(cfg) @@ -2299,7 +679,7 @@ func (this *EtcdMgr) InitUpdateChessRankcfg() { switch ev.Type { case clientv3.EventTypeDelete: case clientv3.EventTypePut: - cfg := &webapi_proto.ChessRankcfgData{} + cfg := &webapiproto.ChessRankcfgData{} err := proto.Unmarshal(ev.Kv.Value, cfg) if err == nil && cfg.Platform != "" { ChessRankMgrSington.UpdateChessRankConfig(cfg) @@ -2323,7 +703,7 @@ func (this *EtcdMgr) InitPhoneLottery() { res, err := this.GetValueWithPrefix(etcd.ETCDKEY_ACT_PHONELOTTERY) if err == nil { for i := int64(0); i < res.Count; i++ { - cfg := &webapi_proto.WelfarePhoneLotteryStatus{} + cfg := &webapiproto.WelfarePhoneLotteryStatus{} //msg := &webapi.ASSrvCtrlClose{} err = proto.Unmarshal(res.Kvs[i].Value, cfg) if err == nil && cfg.Platform != "" { @@ -2349,7 +729,7 @@ func (this *EtcdMgr) InitPhoneLottery() { switch ev.Type { case clientv3.EventTypeDelete: case clientv3.EventTypePut: - cfg := &webapi_proto.WelfarePhoneLotteryStatus{} + cfg := &webapiproto.WelfarePhoneLotteryStatus{} err := proto.Unmarshal(ev.Kv.Value, cfg) if err == nil && cfg.Platform != "" { WelfareMgrSington.UpdatePhoneLotteryStatus(cfg) diff --git a/worldsrv/petmgr.go b/worldsrv/petmgr.go index b35fe3d..ba02339 100644 --- a/worldsrv/petmgr.go +++ b/worldsrv/petmgr.go @@ -6,6 +6,7 @@ import ( "mongo.games.com/goserver/core/module" "mongo.games.com/game/common" + "mongo.games.com/game/model" hall_proto "mongo.games.com/game/protocol/gamehall" "mongo.games.com/game/protocol/pets" "mongo.games.com/game/srvdata" @@ -233,7 +234,7 @@ func (this *PetMgr) GetPetInfo(p *Player, modId int32) *pets.PetInfo { } // 商品人物总加成 人物功能变动需要修改 -func (this *PetMgr) GetShopAward(shopInfo *ShopInfo, p *Player) (award, roleId int32) { +func (this *PetMgr) GetShopAward(shopInfo *model.ShopInfo, p *Player) (award, roleId int32) { if shopInfo.Ad > 0 && shopInfo.Type == ShopTypeCoin { id, add := srvdata.RolePetMgrSington.GetRoleAdd(p.PlayerData, common.RoleAddADV) award += add diff --git a/worldsrv/platform.go b/worldsrv/platform.go index c573fb8..a173e6a 100644 --- a/worldsrv/platform.go +++ b/worldsrv/platform.go @@ -89,28 +89,28 @@ type Platform struct { IsCanUserBindPromoter bool //是否允许用户手动绑定推广员 UserBindPromoterPrize int32 //手动绑定奖励 SpreadWinLose bool //是否打开客损开关 - PltGameCfg *PlatformGameConfig //平台游戏配置 + GameConfig *GameList //平台游戏配置 MerchantKey string //商户秘钥 BindTelReward map[int32]int64 // 绑定手机号奖励 } -type PlatformGameConfig struct { - games map[int32]*webapiproto.GameFree //以gamefreeid为key - cache map[int32][]*webapiproto.GameFree //以gameid为key +type GameList struct { + gameFreeId map[int32]*webapiproto.GameFree // 以gamefreeid为key + gameId map[int32][]*webapiproto.GameFree // 以gameid为key } -func (cfg *PlatformGameConfig) RecreateCache() { - if cfg.cache == nil { - cfg.cache = make(map[int32][]*webapiproto.GameFree) +func (cfg *GameList) Init() { + if cfg.gameId == nil { + cfg.gameId = make(map[int32][]*webapiproto.GameFree) } - for _, val := range cfg.games { - cfg.cache[val.DbGameFree.GetGameId()] = append(cfg.cache[val.DbGameFree.GetGameId()], val) + for _, val := range cfg.gameFreeId { + cfg.gameId[val.DbGameFree.GetGameId()] = append(cfg.gameId[val.DbGameFree.GetGameId()], val) } } -func (cfg *PlatformGameConfig) GetGameCfg(gamefreeId int32) *webapiproto.GameFree { - if cfg.games != nil { - if c, exist := cfg.games[gamefreeId]; exist { +func (cfg *GameList) GetGameConfig(gameFreeId int32) *webapiproto.GameFree { + if cfg.gameFreeId != nil { + if c, exist := cfg.gameFreeId[gameFreeId]; exist { if c.GroupId == 0 { return c } else { @@ -123,7 +123,7 @@ func (cfg *PlatformGameConfig) GetGameCfg(gamefreeId int32) *webapiproto.GameFre return temp } } else { - //logger.Logger.Errorf("PlatformGameConfig GetGameCfg Can't Find GameCfg[%v]", gamefreeId) + //logger.Logger.Errorf("GameList GetGameConfig Can't Find GameCfg[%v]", gameFreeId) } } return nil @@ -185,10 +185,12 @@ func NewPlatform(id int32, isolated bool) *Platform { Halls: make(map[int32]*PlatformGameHall), GamePlayerNum: make(map[int32]*PlatformGamePlayerNum), ClubConfig: &ClubConfig{}, - PltGameCfg: &PlatformGameConfig{ - games: make(map[int32]*webapiproto.GameFree), - cache: make(map[int32][]*webapiproto.GameFree), + GameConfig: &GameList{ + gameFreeId: make(map[int32]*webapiproto.GameFree), + gameId: make(map[int32][]*webapiproto.GameFree), }, + ThirdGameMerchant: make(map[int32]int32), + BindTelReward: make(map[int32]int64), } return p @@ -230,14 +232,6 @@ func (p *Platform) ChangeDisabled(disable bool) bool { return true } -func (p *Platform) PlayerLogin(player *Player) { - -} - -func (p *Platform) PlayerLogout(player *Player) { - -} - func (p *Platform) IsMarkFlag(flag int32) bool { if (p.BindOption & flag) != 0 { return true diff --git a/worldsrv/platformmgr.go b/worldsrv/platformmgr.go index 53b9343..2142300 100644 --- a/worldsrv/platformmgr.go +++ b/worldsrv/platformmgr.go @@ -24,14 +24,6 @@ const ( DefaultPlatformInt = 0 ) -// PlatformConfig 所有跟平台相关的配置,不要再定义map数据结构了 -type PlatformConfig struct { - Platform *Platform // 平台配置 - EntrySwitch *webapiproto.EntrySwitch // 客户端游戏入口开关 - CommonNotices *webapiproto.CommonNoticeList // 公告 - PlayerPool *webapiproto.PlayerPool // 个人水池配置 -} - type PlatformObserver interface { OnPlatformCreate(p *Platform) OnPlatformDestroy(p *Platform) @@ -41,81 +33,75 @@ type PlatformObserver interface { } var PlatformMgrSingleton = &PlatformMgr{ - configs: make(map[string]*PlatformConfig), - PackageList: make(map[string]*webapiproto.AppInfo), - GameStatus: make(map[int32]bool), //全局游戏开关 + platforms: make(map[string]*Platform), + ConfigMgr: model.NewConfigMgr(), } type PlatformMgr struct { BaseClockSinker - - //todo 所有跟平台相关的配置,不要再定义map数据结构了 - configs map[string]*PlatformConfig - - PackageList map[string]*webapiproto.AppInfo // 包对应的平台,包标识 - GameStatus map[int32]bool // 超管平台游戏开关,游戏id - - Observers []PlatformObserver + *model.ConfigMgr + platforms map[string]*Platform + observers []PlatformObserver } func (pm *PlatformMgr) RegisterObserver(observer PlatformObserver) { - for _, ob := range pm.Observers { + for _, ob := range pm.observers { if ob == observer { return } } - pm.Observers = append(pm.Observers, observer) + pm.observers = append(pm.observers, observer) } func (pm *PlatformMgr) UnregisterObserver(observer PlatformObserver) { - for i, ob := range pm.Observers { + for i, ob := range pm.observers { if ob == observer { - pm.Observers = append(pm.Observers[:i], pm.Observers[i+1:]...) + pm.observers = append(pm.observers[:i], pm.observers[i+1:]...) break } } } +// GetPlatforms 获取所有平台 func (pm *PlatformMgr) GetPlatforms() []*Platform { var ret []*Platform - for _, v := range pm.configs { - if v != nil && v.Platform != nil { - ret = append(ret, v.Platform) + for _, v := range pm.platforms { + if v != nil { + ret = append(ret, v) } } return ret } -func (pm *PlatformMgr) CreatePlatform(id int32, isolated bool) *Platform { - pltId := strconv.Itoa(int(id)) - p := NewPlatform(id, isolated) - pm.Get(pltId).Platform = p - if p != nil { - pm.OnPlatformCreate(p) - } - return p -} - // CreateDefaultPlatform 创建默认平台 func (pm *PlatformMgr) CreateDefaultPlatform() { //默认平台数据 defaultPlatform := pm.CreatePlatform(DefaultPlatformInt, false) defaultPlatform.Disable = false //默认平台配置 - pgc := defaultPlatform.PltGameCfg - if pgc != nil { + list := defaultPlatform.GameConfig + if list != nil { for _, value := range srvdata.PBDB_GameFreeMgr.Datas.Arr { if value.GetGameId() > 0 { - pgc.games[value.GetId()] = &webapiproto.GameFree{ + list.gameFreeId[value.GetId()] = &webapiproto.GameFree{ Status: true, DbGameFree: value, } } } - pgc.RecreateCache() + list.Init() } } +// CreatePlatform 创建平台 +func (pm *PlatformMgr) CreatePlatform(id int32, isolated bool) *Platform { + pltId := strconv.Itoa(int(id)) + p := NewPlatform(id, isolated) + pm.platforms[pltId] = p + pm.OnPlatformCreate(p) + return p +} + // UpsertPlatform 更新或新增平台 func (pm *PlatformMgr) UpsertPlatform(name string, isolated, disable bool, id int32, url string, bindOption int32, serviceFlag bool, upgradeAccountGiveCoin, newAccountGiveCoin, perBankNoLimitAccount, exchangeMin, @@ -126,7 +112,7 @@ func (pm *PlatformMgr) UpsertPlatform(name string, isolated, disable bool, id in userBindPromoterPrize int32, spreadWinLose bool, exchangeMultiple int32, registerVerifyCodeSwitch bool, merchantKey string, bindTelReward map[int32]int64) *Platform { pltId := strconv.Itoa(int(id)) - p := pm.Get(pltId).Platform + p := pm.platforms[pltId] if p == nil { p = pm.CreatePlatform(id, isolated) } @@ -188,50 +174,17 @@ func (pm *PlatformMgr) UpsertPlatform(name string, isolated, disable bool, id in return p } -// Get 获取平台相关配置,不会返回nil -func (pm *PlatformMgr) Get(plt string) *PlatformConfig { - cfg, ok := pm.configs[plt] - if !ok { - cfg = new(PlatformConfig) - pm.configs[plt] = cfg - } - return cfg -} - -func (this *PlatformMgr) UpdateConfig(config any) { - if config == nil { - return - } - switch v := config.(type) { - case *webapiproto.PlayerPool: - this.Get(v.GetPlatform()).PlayerPool = v - default: - logger.Logger.Errorf("unknown config type:%v", config) - } -} - -func (pm *PlatformMgr) UpdateEntrySwitch(config *webapiproto.EntrySwitch) { - if config == nil { - return - } - pm.Get(config.Platform).EntrySwitch = config -} - +// GetEntrySwitch 获取入口开关 func (pm *PlatformMgr) GetEntrySwitch(plt string) *webapiproto.EntrySwitch { - return pm.Get(plt).EntrySwitch -} - -func (pm *PlatformMgr) UpdateCommonNotices(config *webapiproto.CommonNoticeList) { - if config == nil { - return - } - pm.Get(config.Platform).CommonNotices = config + return pm.GetConfig(plt).EntrySwitch } +// GetCommonNotices 获取公告 func (pm *PlatformMgr) GetCommonNotices(plt string) *webapiproto.CommonNoticeList { - return pm.Get(plt).CommonNotices + return pm.GetConfig(plt).CommonNotices } +// SyncGameFree 通知游戏配置更新 func (pm *PlatformMgr) SyncGameFree(platform string, data *webapiproto.GameFree) { packSgf := &loginproto.SCSyncGameFree{} gc := &loginproto.GameConfig{ @@ -260,7 +213,7 @@ func (pm *PlatformMgr) SyncGameFree(platform string, data *webapiproto.GameFree) func (pm *PlatformMgr) UpsertGameFree(platform string, data *webapiproto.GameFree) { p := pm.GetPlatform(platform) if p != nil { - pgc := p.PltGameCfg + pgc := p.GameConfig if pgc != nil { dbGameFree := srvdata.PBDB_GameFreeMgr.GetData(data.DbGameFree.Id) if dbGameFree == nil { @@ -272,11 +225,11 @@ func (pm *PlatformMgr) UpsertGameFree(platform string, data *webapiproto.GameFre CopyDBGameFreeField(dbGameFree, data.DbGameFree) } - old, ok := pgc.games[data.DbGameFree.Id] - pgc.games[data.DbGameFree.Id] = data + old, ok := pgc.gameFreeId[data.DbGameFree.Id] + pgc.gameFreeId[data.DbGameFree.Id] = data found := false if ok && old != nil { - if c, ok := pgc.cache[data.DbGameFree.Id]; ok { + if c, ok := pgc.gameId[data.DbGameFree.Id]; ok { for i := 0; i < len(c); i++ { if c[i].DbGameFree.Id == data.DbGameFree.Id { c[i] = data @@ -287,8 +240,9 @@ func (pm *PlatformMgr) UpsertGameFree(platform string, data *webapiproto.GameFre } } if !found { - pgc.cache[data.DbGameFree.Id] = append(pgc.cache[data.DbGameFree.Id], data) + pgc.gameId[data.DbGameFree.Id] = append(pgc.gameId[data.DbGameFree.Id], data) } + // 新增的场次不会通知 if ok && old != nil && !CompareGameFreeConfigChged(old, data) { pm.OnPlatformGameFreeUpdate(p, old, data) pm.SyncGameFree(p.IdStr, data) @@ -298,29 +252,30 @@ func (pm *PlatformMgr) UpsertGameFree(platform string, data *webapiproto.GameFre } func (pm *PlatformMgr) OnPlatformCreate(p *Platform) { - for _, observer := range pm.Observers { + for _, observer := range pm.observers { observer.OnPlatformCreate(p) } } func (pm *PlatformMgr) OnPlatformGameFreeUpdate(p *Platform, oldCfg, newCfg *webapiproto.GameFree) { - for _, observer := range pm.Observers { + for _, observer := range pm.observers { observer.OnPlatformGameFreeUpdate(p, oldCfg, newCfg) } } func (pm *PlatformMgr) OnPlatformDestroyByGameFreeId(p *Platform, gameFreeId int32) { - for _, observer := range pm.Observers { + for _, observer := range pm.observers { observer.OnPlatformDestroyByGameFreeId(p, gameFreeId) } } func (pm *PlatformMgr) OnPlatformChangeDisabled(p *Platform, disable bool) { - for _, observer := range pm.Observers { + for _, observer := range pm.observers { observer.OnPlatformChangeDisabled(p, disable) } } +// ChangeDisabled 平台开关状态切换 func (pm *PlatformMgr) ChangeDisabled(name string, disable bool) { if p := pm.GetPlatform(name); p != nil { if p.ChangeDisabled(disable) { @@ -330,22 +285,10 @@ func (pm *PlatformMgr) ChangeDisabled(name string, disable bool) { } func (pm *PlatformMgr) GetPlatform(platform string) *Platform { - return pm.Get(platform).Platform -} - -func (pm *PlatformMgr) OnChangeSceneState(scene *Scene, startclose bool) { - -} -func (pm *PlatformMgr) PlayerLogin(p *Player) { - if p.IsRob { - return - } - platform := pm.GetPlatform(p.Platform) - if platform != nil { - platform.PlayerLogin(p) - } + return pm.platforms[platform] } +// Broadcast 给玩家发消息 func (pm *PlatformMgr) Broadcast(packetid int, packet interface{}, players map[int32]*Player, exclude int32) { mgs := make(map[*netlib.Session][]*srvlibproto.MCSessionUnion) for _, p := range players { @@ -367,18 +310,9 @@ func (pm *PlatformMgr) Broadcast(packetid int, packet interface{}, players map[i } } -func (pm *PlatformMgr) PlayerLogout(p *Player) { - platform := pm.GetPlatform(p.Platform) - if platform != nil && platform.Isolated { - platform.PlayerLogout(p) - } else { - - } -} - func (this *PlatformMgr) GetPackageTag(tag string) *webapiproto.AppInfo { logger.Logger.Tracef("Get %v platform.", tag) - if pt, ok := this.PackageList[tag]; ok { + if pt, ok := this.GetGlobalConfig().PackageList[tag]; ok { return pt } return nil @@ -386,7 +320,7 @@ func (this *PlatformMgr) GetPackageTag(tag string) *webapiproto.AppInfo { func (this *PlatformMgr) GetPlatformByPackageTag(tag string) (int32, int32, int32, int32, int32) { logger.Logger.Tracef("Get %v platform.", tag) - if pt, ok := this.PackageList[tag]; ok { + if pt, ok := this.GetGlobalConfig().PackageList[tag]; ok { return pt.PlatformId, 0, 0, 0, 0 } else { return int32(DefaultPlatformInt), 0, 0, 0, 0 @@ -395,25 +329,13 @@ func (this *PlatformMgr) GetPlatformByPackageTag(tag string) (int32, int32, int3 func (this *PlatformMgr) GetCurrencyByPackageTag(tag string) (string, int32) { logger.Logger.Tracef("Get %v CurrencyRatio.", tag) - if pt, ok := this.PackageList[tag]; ok && pt.CurrencyType != "" && pt.CurrencyRatio != 0 { + if pt, ok := this.GetGlobalConfig().PackageList[tag]; ok && pt.CurrencyType != "" && pt.CurrencyRatio != 0 { return pt.CurrencyType, pt.CurrencyRatio } return "USD", 1 } -func (this *PlatformMgr) GetPlatformUpgradeAccountGiveCoinByPackageTag(tag string) int32 { - platform, _, _, _, _ := this.GetPlatformByPackageTag(tag) - return this.GetPlatformUpgradeAccountGiveCoinByPlatform(strconv.Itoa(int(platform))) -} - -func (this *PlatformMgr) GetPlatformUpgradeAccountGiveCoinByPlatform(platform string) int32 { - platformData := this.GetPlatform(platform) - if platformData == nil { - return 0 - } - return platformData.UpgradeAccountGiveCoin -} - +// GetGameFrees 获取平台游戏配置 func (this *PlatformMgr) GetGameFrees(platform string) map[int32]*webapiproto.GameFree { p := this.GetPlatform(platform) if p == nil { @@ -421,8 +343,8 @@ func (this *PlatformMgr) GetGameFrees(platform string) map[int32]*webapiproto.Ga } data := make(map[int32]*webapiproto.GameFree) - for id, val := range p.PltGameCfg.games { - if !val.Status || !this.GameStatus[id] { + for id, val := range p.GameConfig.gameFreeId { + if !val.Status || !this.GetGlobalConfig().GameStatus[id] { continue } @@ -443,18 +365,19 @@ func (this *PlatformMgr) GetGameFrees(platform string) map[int32]*webapiproto.Ga return data } +// GetGameFree 获取平台游戏配置 func (this *PlatformMgr) GetGameFree(platform string, gameFreeId int32) *webapiproto.GameFree { p := this.GetPlatform(platform) if p == nil { return nil } - gf := p.PltGameCfg.GetGameCfg(gameFreeId) + gf := p.GameConfig.GetGameConfig(gameFreeId) if gf == nil { return nil } - if !this.GameStatus[gameFreeId] || !gf.GetStatus() { + if !this.GetGlobalConfig().GameStatus[gameFreeId] || !gf.GetStatus() { return nil } @@ -504,7 +427,7 @@ func (this *PlatformMgr) ChangeGameStatus(cfgs []*hallproto.GameConfig1) { for _, p := range this.GetPlatforms() { for _, cfg := range cfgs { gameFreeId := cfg.LogicId - data, ok := p.PltGameCfg.games[gameFreeId] + data, ok := p.GameConfig.gameFreeId[gameFreeId] if data != nil && ok && data.Status { //自身有这个游戏,且处于开启状态 if !cfg.Status { //全局关,销毁游戏 pack.GameCfg = append(pack.GameCfg, cfg) @@ -562,187 +485,6 @@ func (this *PlatformMgr) Init() { } -func (this *PlatformMgr) LoadPlatform() { - //构建默认的平台数据 - this.CreateDefaultPlatform() - //获取平台数据 platform_list - - //不使用etcd的情况下走api获取 - if !model.GameParamData.UseEtcd { - //buf, err := webapi.API_GetPlatformData(common.GetAppId()) - //if err == nil { - // ar := webapi_proto.ASPlatformInfo{} - // err = proto.Unmarshal(buf, &ar) - // if err == nil && ar.Tag == webapi_proto.TagCode_SUCCESS { - // for _, value := range ar.Platforms { - // platform := this.CreatePlatform(value.Id, value.Isolated) - // platform.Name = value.PlatformName - // //platform.ConfigId = value.ConfigId - // platform.Disable = value.Disabled - // platform.ServiceUrl = value.CustomService - // platform.CustomType = value.CustomType - // platform.BindOption = value.BindOption - // //platform.ServiceFlag = value.ServiceFlag - // platform.UpgradeAccountGiveCoin = value.UpgradeAccountGiveCoin - // platform.NewAccountGiveCoin = value.NewAccountGiveCoin //新账号奖励金币 - // platform.PerBankNoLimitAccount = value.PerBankNoLimitAccount //同一银行卡号绑定用户数量限制 - // platform.ExchangeMin = value.ExchangeMin - // platform.ExchangeLimit = value.ExchangeLimit - // platform.ExchangeTax = value.ExchangeTax - // platform.ExchangeFlow = value.ExchangeFlow - // platform.ExchangeVer = value.ExchangeVer - // platform.ExchangeFlag = value.ExchangeFlag - // platform.ExchangeForceTax = value.ExchangeForceTax - // platform.ExchangeGiveFlow = value.ExchangeGiveFlow - // platform.VipRange = value.VipRange - // //platform.OtherParams = value.OtherParams - // platform.SpreadConfig = value.SpreadConfig - // //platform.RankSwitch = value.Leaderboard - // //platform.ClubConfig = value.ClubConfig - // platform.VerifyCodeType = value.VerifyCodeType - // //platform.RegisterVerifyCodeSwitch = value.RegisterVerifyCodeSwitch - // for _, v := range value.ThirdGameMerchant { - // platform.ThirdGameMerchant[v.Id] = v.Merchant - // } - // //platform.NeedDeviceInfo = value.NeedDeviceInfo - // platform.NeedSameName = value.NeedSameName - // platform.PerBankNoLimitName = value.PerBankNoLimitName - // platform.ExchangeAlipayMax = value.ExchangeAlipayMax - // platform.ExchangeBankMax = value.ExchangeBankMax - // //platform.DgHboConfig = value.DgHboConfig - // platform.IsCanUserBindPromoter = value.IsCanUserBindPromoter - // platform.UserBindPromoterPrize = value.UserBindPromoterPrize - // //platform.SpreadWinLose = value.SpreadWinLose - // platform.ExchangeMultiple = value.ExchangeMultiple - // if platform.ExchangeFlag&ExchangeFlag_Flow == 0 { //修正下 - // platform.ExchangeFlow = 0 - // } - // platform.MerchantKey = value.MerchantKey - // } - // logger.Logger.Trace("Create platform") - // } else { - // logger.Logger.Error("Unmarshal platform data error:", err) - // } - //} else { - // logger.Logger.Error("Get platfrom data error:", err) - //} - } else { - EtcdMgrSington.InitPlatform() - } -} - -func (this *PlatformMgr) LoadPlatformGameFree() { - //不使用etcd的情况下走api获取 - - //获取平台详细信息 game_config_list - if !model.GameParamData.UseEtcd { - //logger.Logger.Trace("API_GetPlatformConfigData") - //buf, err := webapi.API_GetPlatformConfigData(common.GetAppId()) - //if err == nil { - // pcdr := &webapi_proto.ASGameConfig{} - // err = proto.Unmarshal(buf, pcdr) - // if err == nil && pcdr.Tag == webapi_proto.TagCode_SUCCESS { - // platGameCfgs := pcdr.GetConfigs() - // - // //遍历所有平台配置 - // for _, pgc := range platGameCfgs { - // platormId := pgc.GetPlatformId() - // platform := this.GetPlatform(strconv.Itoa(int(platormId))) - // if platform == nil { - // continue - // } - // - // for _, config := range pgc.GetDbGameFrees() { - // dbGameFree := srvdata.PBDB_GameFreeMgr.GetData(config.DbGameFree.Id) - // if dbGameFree == nil { - // logger.Logger.Error("Platform config data error logic id:", config) - // continue - // } - // platform.PltGameCfg.games[config.DbGameFree.Id] = config - // if config.GetDbGameFree() == nil { //数据容错 - // config.DbGameFree = dbGameFree - // } else { - // CopyDBGameFreeField(dbGameFree, config.DbGameFree) - // } - // logger.Logger.Info("PlatformGameConfig data:", config.DbGameFree.Id) - // } - // platform.PltGameCfg.RecreateCache() - // } - // } else { - // logger.Logger.Error("Unmarshal platform config data error:", err, string(buf)) - // } - //} else { - // logger.Logger.Error("Get platfrom config data error:", err) - //} - } else { - EtcdMgrSington.InitPlatformGameConfig() - } -} - -func (this *PlatformMgr) LoadPlatformPackage() { - if !model.GameParamData.UseEtcd { - - } else { - EtcdMgrSington.InitPlatformPackage() - } -} - -func (this *PlatformMgr) LoadCommonNotice() { - if !model.GameParamData.UseEtcd { - - } else { - EtcdMgrSington.InitCommonNotice() - } -} - -func (this *PlatformMgr) LoadGameMatch() { - if !model.GameParamData.UseEtcd { - - } else { - EtcdMgrSington.InitGameMatchDate() - } -} - -// LoadGlobalGameStatus 加载超管平台游戏开关 -func (this *PlatformMgr) LoadGlobalGameStatus() { - //不使用etcd的情况下走api获取 - if !model.GameParamData.UseEtcd { - ////获取全局游戏开关 - //logger.Logger.Trace("API_GetGlobalGameStatus") - //buf, err := webapi.API_GetGlobalGameStatus(common.GetAppId()) - //if err == nil { - // as := webapi_proto.ASGameConfigGlobal{} - // err = proto.Unmarshal(buf, &as) - // if err == nil && as.Tag == webapi_proto.TagCode_SUCCESS { - // if as.GetGameStatus() != nil { - // status := as.GetGameStatus().GetGameStatus() - // for _, v := range status { - // gameId := v.GetGameId() - // status := v.GetStatus() - // PlatformMgrSingleton.GameStatus[gameId] = status - // } - // } - // } else { - // logger.Logger.Error("Unmarshal GlobalGameStatus data error:", err) - // } - //} else { - // logger.Logger.Error("Get GlobalGameStatus data error:", err) - //} - } else { - EtcdMgrSington.InitGameGlobalStatus() - } -} - -// LoadEntrySwitch 拉取界面入口开关 -func (this *PlatformMgr) LoadEntrySwitch() { - //不使用etcd的情况下走api获取 - if model.GameParamData.UseEtcd { - EtcdMgrSington.InitEntrySwitch() - } else { - - } -} - func (this *PlatformMgr) Update() { } @@ -852,40 +594,5 @@ func CopyDBGameFreeField(src, dst *serverproto.DB_GameFree) { func init() { ClockMgrSington.RegisteSinker(PlatformMgrSingleton) - module.RegisteModule(PlatformMgrSingleton, time.Second*2, 0) - - RegisterParallelLoadFunc("拉取平台数据", func() error { - PlatformMgrSingleton.LoadPlatform() - return nil - }) - - RegisterParallelLoadFunc("拉取平台游戏开关", func() error { - PlatformMgrSingleton.LoadGlobalGameStatus() - return nil - }) - - RegisterParallelLoadFunc("拉取游戏入口开关", func() error { - PlatformMgrSingleton.LoadEntrySwitch() - return nil - }) - - RegisterParallelLoadFunc("拉取平台游戏详细配置", func() error { - PlatformMgrSingleton.LoadPlatformGameFree() - return nil - }) - - RegisterParallelLoadFunc("平台包数据", func() error { - PlatformMgrSingleton.LoadPlatformPackage() - return nil - }) - - RegisterParallelLoadFunc("平台公告", func() error { - PlatformMgrSingleton.LoadCommonNotice() - return nil - }) - - RegisterParallelLoadFunc("平台比赛", func() error { - PlatformMgrSingleton.LoadGameMatch() - return nil - }) + module.RegisteModule(PlatformMgrSingleton, time.Hour, 0) } diff --git a/worldsrv/player.go b/worldsrv/player.go index 90e326a..d6eb489 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -321,8 +321,6 @@ func (this *Player) OnLogined() { this.BindGroupTag([]string{this.Platform}) - PlatformMgrSingleton.PlayerLogin(this) - gameStateMgr.PlayerClear(this) //玩家登录事件 @@ -416,8 +414,6 @@ func (this *Player) OnRehold() { //登录事件 this.ReportLoginEvent() - PlatformMgrSingleton.PlayerLogin(this) - gameStateMgr.PlayerClear(this) //玩家重连事件 @@ -527,7 +523,7 @@ func (this *Player) SendGameConfig(gameId int32, plf, chl string) { gps := PlatformMgrSingleton.GetGameFrees(this.Platform) for _, v := range gps { - if v.Status && PlatformMgrSingleton.GameStatus[v.DbGameFree.Id] { + if v.Status && PlatformMgrSingleton.GetGlobalConfig().GameStatus[v.DbGameFree.Id] { if v.DbGameFree.GetGameRule() != 0 && v.DbGameFree.GetGameId() == gameId { // 场次配置 lgc := &hall_proto.GameConfig1{ @@ -1524,7 +1520,6 @@ func (this *Player) DropLine() { this.SendToGame(int(server_proto.SSPacketID_PACKET_WG_PLAYERDROPLINE), pack) } PlayerMgrSington.DroplinePlayer(this) - PlatformMgrSingleton.PlayerLogout(this) this.sid = 0 this.gateSess = nil //统计在线时长日志 @@ -1554,7 +1549,6 @@ func (this *Player) Logout() { FriendMgrSington.UpdateLogoutTime(this.Platform, this.SnId) //clubManager.DropLinePlayer(this.SnId) PlayerMgrSington.DroplinePlayer(this) - PlatformMgrSingleton.PlayerLogout(this) if !this.IsRobot() { PlayerOnlineSington.Check = true } @@ -1620,7 +1614,6 @@ func (this *Player) OnLogouted() { MatchSeasonMgrSington.SaveMatchSeasonData(this.SnId, true) } //平台数据 - PlatformMgrSingleton.PlayerLogout(this) //PlayerSingleAdjustMgr.DelPlayerData(this.Platform, this.SnId) //离线玩家清空俱乐部信息 @@ -4373,12 +4366,7 @@ func (this *Player) BindTelReward() { } func (this *Player) UpdateShopID(shopId int32) { - var shopInfo *ShopInfo - if shops, ok := ShopMgrSington.ShopInfos[this.Platform]; ok { - if shopInf, ok := shops[shopId]; ok { - shopInfo = shopInf - } - } + var shopInfo = ShopMgrSington.ConfigMgr.GetShopInfo(this.Platform, shopId) if shopInfo != nil && shopInfo.FirstSwitch { if !slices.Contains(this.ShopID, int(shopInfo.Id)) { this.ShopID = append(this.ShopID, int(shopInfo.Id)) diff --git a/worldsrv/scene.go b/worldsrv/scene.go index e35aa4e..bac8e2f 100644 --- a/worldsrv/scene.go +++ b/worldsrv/scene.go @@ -906,7 +906,6 @@ func (this *Scene) OnClose() { this.Broadcast(int(hallproto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0) this.closed = true - PlatformMgrSingleton.OnChangeSceneState(this, this.closed) this.sp.OnStop(this) //NpcServerAgentSington.OnSceneClose(this) for _, p := range this.players { @@ -954,7 +953,6 @@ func (this *Scene) ForceDelete(isManual bool) { this.manualDelete = isManual this.deleting = true this.force = true - PlatformMgrSingleton.OnChangeSceneState(this, this.force) pack := &serverproto.WGDestroyScene{ SceneId: proto.Int(this.sceneId), } diff --git a/worldsrv/shopmgr.go b/worldsrv/shopmgr.go index 50cee37..4e6f7bc 100644 --- a/worldsrv/shopmgr.go +++ b/worldsrv/shopmgr.go @@ -86,48 +86,11 @@ const ( ) var ShopMgrSington = &ShopMgr{ - ShopInfos: make(map[string]map[int32]*ShopInfo), - ExShops: make(map[string]*webapi_proto.ExchangeShopList), + ConfigMgr: model.NewConfigMgr(), } type ShopMgr struct { - ShopInfos map[string]map[int32]*ShopInfo // Platform:商品id:商品信息 - ExShops map[string]*webapi_proto.ExchangeShopList //兑换商品 消耗v卡 -} - -type ShopInfo struct { - Id int32 // 商品ID - Page int32 // 页面 1,金币页面 2,钻石页面 3,道具页面 - Order int32 // 排序 页面内商品的位置排序 - Location []int32 // 显示位置 第1位,竖版大厅 第2位,Tienlen1级选场 第3位,捕鱼1级选场 - Picture string // 图片id - Name string // 名称 - Label []int32 // 标签 - Ad int32 // 是否观看广告 0不看 - AdTime int32 // 观看几次广告 - RepeatTimes int32 // 领取次数 - CoolingTime []int32 // 观看冷却时间 - Type int32 // 获得类型 1,金币 2,钻石 3,道具类型 - Amount int64 // 获得数量 - AddArea []int32 // 加送百分比(比如加送10%,就配置110) - ItemId int32 // 获得道具ID - AddItemInfo []*shop.ItemInfo // 获得道具 - ConstType int32 // 购买消耗类型 1,金币 2,钻石 3,美金 4,柬埔寨币 - CostArea []int32 // 消耗数量区间 - VipLevel int32 //Vip等级限制 - Ratio int32 //权重 - EndTime int32 //新手礼包结束时间间隔 - //缓存数据 - AdLookedNum int32 //已经观看的次数 - AdReceiveNum int32 //已经领取的次数 - RemainingTime int32 - LastLookTime int32 - RoleAdded int32 - PetAdded int32 - RoleAddedId int32 //加成人物ID - PetAddedId int32 //加成宠物ID - FirstSwitch bool // 首冲翻倍 - AmountFinal int64 // 实际获得数量 + *model.ConfigMgr } type ExchangeShopInfo struct { @@ -150,55 +113,12 @@ func (this *ShopMgr) ModuleName() string { func (this *ShopMgr) Init() { } -// UpdateItemShop 更新商品信息 -func (this *ShopMgr) UpdateItemShop(cfgs *webapi_proto.ItemShopList) { - if cfgs == nil { - return - } - shopInfos := make(map[int32]*ShopInfo) - for _, itemShop := range cfgs.List { - var itemInfo []*shop.ItemInfo - for key, value := range itemShop.Award { - itemInfo = append(itemInfo, &shop.ItemInfo{ - ItemId: int32(key), - ItemNum: value, - }) - } - - shopInfos[itemShop.Id] = &ShopInfo{ - Id: itemShop.Id, - ItemId: itemShop.ItemId, - Page: itemShop.Page, - Order: itemShop.Order, - Type: itemShop.Type, - Location: itemShop.Location, - Picture: itemShop.Picture, - Name: itemShop.Name, - Ad: itemShop.Ad, - AdTime: itemShop.AdTime, - RepeatTimes: itemShop.RepeatTimes, - CoolingTime: itemShop.CoolingTime, - Label: itemShop.Label, - AddArea: itemShop.AddArea, - Amount: int64(itemShop.Amount), - ConstType: itemShop.ConstType, - CostArea: itemShop.CostArea, - AddItemInfo: itemInfo, - VipLevel: itemShop.VipLevel, - Ratio: itemShop.Ratio, - EndTime: itemShop.EndTime, - FirstSwitch: itemShop.FirstSwitch, - } - } - this.ShopInfos[cfgs.Platform] = shopInfos -} - // UpExShop 更新兑换商品信息 func (this *ShopMgr) UpExShop(cfgs *webapi_proto.ExchangeShopList) { - this.ExShops[cfgs.GetPlatform()] = cfgs + this.GetConfig(cfgs.Platform).ExchangeShopList = cfgs } -func (this *ShopMgr) GetShopInfoProto(si *ShopInfo, p *Player, vipShopId int32) (shopInfo *shop.ShopInfo) { +func (this *ShopMgr) GetShopInfoProto(si *model.ShopInfo, p *Player, vipShopId int32) (shopInfo *shop.ShopInfo) { if si == nil { return nil } @@ -258,16 +178,11 @@ func (this *ShopMgr) GetShopInfoProto(si *ShopInfo, p *Player, vipShopId int32) } // GetShopInfo 获取玩家某个商品信息(例如玩家看广告领取) -func (this *ShopMgr) GetShopInfo(shopId int32, p *Player) *ShopInfo { +func (this *ShopMgr) GetShopInfo(shopId int32, p *Player) *model.ShopInfo { if shopId == 0 { return nil } - var shopInfo *ShopInfo - if shops, ok := this.ShopInfos[p.Platform]; ok { - if shopInf, ok1 := shops[shopId]; ok1 { - shopInfo = shopInf - } - } + var shopInfo = this.ConfigMgr.GetShopInfo(p.Platform, shopId) if shopInfo != nil { // AdLookedNum 已看次数 // AdReceiveNum 已领次数 @@ -299,7 +214,7 @@ func (this *ShopMgr) GetShopInfo(shopId int32, p *Player) *ShopInfo { firstBuy = !slices.Contains(p.ShopID, int(shopInfo.Id)) } - return &ShopInfo{ + return &model.ShopInfo{ Id: shopInfo.Id, Ad: shopInfo.Ad, AdTime: shopInfo.AdTime, @@ -347,7 +262,9 @@ func (this *ShopMgr) GetShopInfos(p *Player, nowLocation int) []*shop.ShopInfo { this.UpdateVipShopData(p) } - for _, shopInfo := range this.ShopInfos[p.Platform] { + shopInfos := this.GetConfig(p.Platform).ShopInfos + + for _, shopInfo := range shopInfos { if nowLocation == -1 || (nowLocation < len(shopInfo.Location) && shopInfo.Location[nowLocation] == 1) { if shopInfo.Page == ShopPageVip { continue @@ -418,8 +335,14 @@ func (this *ShopMgr) GetShopInfos(p *Player, nowLocation int) []*shop.ShopInfo { } } //VIP商城数据 + if shopInfos == nil { + return newShops + } for i, data := range p.VipShopData { - shopInfo := this.ShopInfos[p.Platform][data.Id] + shopInfo := shopInfos[data.Id] + if shopInfo == nil { + continue + } var AdLookedNum, AdReceiveNum, remainingTime int32 var lastLookTime int64 if shopInfo.Ad > 0 { @@ -522,9 +445,9 @@ func (this *ShopMgr) UpdateVipShopData(p *Player) { return } //获取对应VIP等级物品列表 - vipShopInfoMap := make(map[int32]*ShopInfo) + vipShopInfoMap := make(map[int32]*model.ShopInfo) var sumRatio = 0 //权重 - for _, shopInfo := range this.ShopInfos[p.Platform] { + for _, shopInfo := range this.GetConfig(p.Platform).ShopInfos { if shopInfo.Page == ShopPageVip && shopInfo.VipLevel == p.VIP { vipShopInfoMap[shopInfo.Id] = shopInfo sumRatio += int(shopInfo.Ratio) @@ -560,12 +483,7 @@ func (this *ShopMgr) UpdateVipShopData(p *Player) { // LookAdReceive 看广告领取商品,校验领取次数 func (this *ShopMgr) LookAdReceive(shopId int32, p *Player, position int32) shop.OpResultCode { - var shopInfo *ShopInfo - if shops, ok := this.ShopInfos[p.Platform]; ok { - if shopInf, ok1 := shops[shopId]; ok1 { - shopInfo = shopInf - } - } + var shopInfo = this.ConfigMgr.GetShopInfo(p.Platform, shopId) if shopInfo == nil { logger.Logger.Errorf("this shop == nil shopId[%v] ", shopId) return shop.OpResultCode_OPRC_Error @@ -585,7 +503,7 @@ func (this *ShopMgr) LookAdReceive(shopId int32, p *Player, position int32) shop } // ReceiveVCPayShop 领取VC看广告商品 -func (this *ShopMgr) ReceiveVCPayShop(shopInfo *ShopInfo, p *Player, vipShopId, position int32) shop.OpResultCode { +func (this *ShopMgr) ReceiveVCPayShop(shopInfo *model.ShopInfo, p *Player, vipShopId, position int32) shop.OpResultCode { if shopInfo == nil { logger.Logger.Errorf("this shop == nil") return shop.OpResultCode_OPRC_Error @@ -596,7 +514,7 @@ func (this *ShopMgr) ReceiveVCPayShop(shopInfo *ShopInfo, p *Player, vipShopId, } // PayAway 商城 领取商品 -func (this *ShopMgr) PayAway(shopInfo *ShopInfo, p *Player, vipShopId, position int32) { +func (this *ShopMgr) PayAway(shopInfo *model.ShopInfo, p *Player, vipShopId, position int32) { shopName := shopInfo.Name + "|" + strconv.Itoa(int(shopInfo.Id)) costNum := rand.Int31n(shopInfo.CostArea[1]-shopInfo.CostArea[0]+1) + shopInfo.CostArea[0] if shopInfo.Page == ShopPageVip { @@ -713,12 +631,7 @@ func (this *ShopMgr) GetAmountFinal(p *Player, shopId, vipShopId int32) int64 { return 0 } - var shopInfo *ShopInfo - if shops, ok := this.ShopInfos[p.Platform]; ok { - if shopInf, ok := shops[shopId]; ok { - shopInfo = shopInf - } - } + var shopInfo = this.ConfigMgr.GetShopInfo(p.Platform, shopId) if shopInfo == nil { return 0 } @@ -769,7 +682,7 @@ func (this *ShopMgr) GetAmountFinal(p *Player, shopId, vipShopId int32) int64 { } // 商城购买 额外增加道具 -func (this *ShopMgr) ShopAddItem(shopInfo *ShopInfo, p *Player) { +func (this *ShopMgr) ShopAddItem(shopInfo *model.ShopInfo, p *Player) { if shopInfo.AddItemInfo != nil { for _, info := range shopInfo.AddItemInfo { item := &Item{ItemId: info.ItemId, ItemNum: info.ItemNum, ObtainTime: time.Now().Unix()} @@ -784,7 +697,7 @@ func (this *ShopMgr) ShopAddItem(shopInfo *ShopInfo, p *Player) { } // CreateVCOrder 产生VC订单,记录看广告获取商品的订单 -func (this *ShopMgr) CreateVCOrder(shopInfo *ShopInfo, snid, costNum int32, platform string, amount [3]int32) { +func (this *ShopMgr) CreateVCOrder(shopInfo *model.ShopInfo, snid, costNum int32, platform string, amount [3]int32) { task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { //获得类型 if shopInfo.Type < ShopTypeCoin && shopInfo.Type > ShopTypeItem { @@ -811,7 +724,7 @@ func (this *ShopMgr) CreateVCOrder(shopInfo *ShopInfo, snid, costNum int32, plat } func (this *ShopMgr) GetExchangeData(platform string, id int32) *ExchangeShopInfo { - if exShops := this.ExShops[platform]; exShops != nil { + if exShops := this.GetConfig(platform).ExchangeShopList; exShops != nil { for _, data := range exShops.List { if data.Id == id { var exType []*shop.ExchangeType @@ -1126,7 +1039,10 @@ func (this *ShopMgr) ShopCheckShowRed(p *Player) { } for i := 0; i < 3; i++ { var isShow bool - for _, shopInfo := range this.ShopInfos[p.Platform] { + for _, shopInfo := range this.GetConfig(p.Platform).ShopInfos { + if shopInfo == nil { + continue + } var AdLookedNum, remainingTime int32 var lastLookTime int64 if shopInfo.Ad > 0 && (i == -1 || (i < len(shopInfo.Location) && shopInfo.Location[i] == 1)) { @@ -1171,7 +1087,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { var amount [ShopTypeItem]int32 var dbShop *model.DbShop - if shopInfo, ok := data.(*ShopInfo); ok { + if shopInfo, ok := data.(*model.ShopInfo); ok { // 目前现金只能买钻石 var addTotal = int64(shopInfo.Amount) added := rand.Int31n(shopInfo.AddArea[1]-shopInfo.AddArea[0]+1) + shopInfo.AddArea[0] diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index bb3518c..0522000 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -1538,7 +1538,7 @@ func init() { for _, s := range gameStatus { gameId := s.GetGameId() status := s.GetStatus() - PlatformMgrSingleton.GameStatus[gameId] = status + PlatformMgrSingleton.GetGlobalConfig().GameStatus[gameId] = status } pack.Tag = webapiproto.TagCode_SUCCESS pack.Msg = "" @@ -1573,9 +1573,9 @@ func init() { for _, v := range dbGameFrees { dbGameFree := v.GetDbGameFree() logicId := dbGameFree.GetId() - platform.PltGameCfg.games[logicId] = v + platform.GameConfig.gameFreeId[logicId] = v } - platform.PltGameCfg.RecreateCache() + platform.GameConfig.Init() pack.Tag = webapiproto.TagCode_SUCCESS pack.Msg = "" return common.ResponseTag_Ok, pack @@ -1726,7 +1726,7 @@ func init() { // 首次购买现金商品,获得翻倍;标记商品已经购买过 if addcoin+diamond > 0 { - if m, ok := ShopMgrSington.ShopInfos[platform]; ok && m != nil { + if m := ShopMgrSington.GetConfig(platform).ShopInfos; m != nil { if shopInfo, ok := m[msg.GetShopId()]; ok && shopInfo != nil { if shopInfo.FirstSwitch { if !slices.Contains(findPlayer.ShopID, int(msg.GetShopId())) { @@ -4537,7 +4537,7 @@ func getPlayerDataParam(p *model.PlayerData, season *model.PlayerRankSeason) *mo return nil } - data := PlatformMgrSingleton.Get(p.Platform).PlayerPool + data := PlatformMgrSingleton.GetConfig(p.Platform).PlayerPool rankScore := make(map[int64]int64) if season == nil { diff --git a/worldsrv/welfmgr.go b/worldsrv/welfmgr.go index 0c1b6ea..65f1497 100644 --- a/worldsrv/welfmgr.go +++ b/worldsrv/welfmgr.go @@ -122,7 +122,7 @@ func (this *WelfareMgr) UpdateSign7(cfg *webapi_proto.Welfare7SignDateList) { if model.GameParamData.TestActSwitch { cfg.Switch = model.WelfareOpen } - this.GetAllConfig(cfg.Platform).Welfare7SignDateList = cfg + this.GetConfig(cfg.Platform).Welfare7SignDateList = cfg } func (this *WelfareMgr) UpdateTurnplate(cfg *webapi_proto.WelfareTurnplateDateList) { @@ -130,7 +130,7 @@ func (this *WelfareMgr) UpdateTurnplate(cfg *webapi_proto.WelfareTurnplateDateLi cfg.Switch = model.WelfareOpen } s := int32(0) - info := this.GetAllConfig(cfg.Platform) + info := this.GetConfig(cfg.Platform) if info.WelfareTurnplateDateList != nil { s = info.WelfareTurnplateDateList.Switch } @@ -147,7 +147,7 @@ func (this *WelfareMgr) UpdateBlindBox(cfg *webapi_proto.WelfareBlindBoxDataList cfg.Switch = model.WelfareOpen } s := int32(0) - info := this.GetAllConfig(cfg.Platform) + info := this.GetConfig(cfg.Platform) if info.WelfareBlindBoxDataList != nil { s = info.WelfareBlindBoxDataList.Switch } @@ -166,7 +166,7 @@ func (this *WelfareMgr) UpdateFirstPay(cfg *webapi_proto.WelfareFirstPayDataList cfg.Switch = model.WelfareOpen } s := int32(0) - info := this.GetAllConfig(cfg.Platform) + info := this.GetConfig(cfg.Platform) if info.WelfareFirstPayDataList != nil { s = info.WelfareFirstPayDataList.Switch } @@ -185,7 +185,7 @@ func (this *WelfareMgr) UpdateContinuousPay(cfg *webapi_proto.WelfareContinuousP cfg.Switch = model.WelfareOpen } s := int32(0) - info := this.GetAllConfig(cfg.Platform) + info := this.GetConfig(cfg.Platform) if info.WelfareContinuousPayDataList != nil { s = info.WelfareContinuousPayDataList.Switch } @@ -204,7 +204,7 @@ func (this *WelfareMgr) UpdatePhoneLotteryStatus(cfg *webapi_proto.WelfarePhoneL cfg.Switch = model.WelfareOpen } s := int32(0) - info := this.GetAllConfig(cfg.Platform) + info := this.GetConfig(cfg.Platform) if info.WelfarePhoneLotteryStatus != nil { s = info.WelfarePhoneLotteryStatus.Switch } @@ -216,7 +216,7 @@ func (this *WelfareMgr) UpdatePhoneLotteryStatus(cfg *webapi_proto.WelfarePhoneL } func (this *WelfareMgr) GetPhoneLotteryStatus(platform string) int32 { - info := this.GetAllConfig(platform) + info := this.GetConfig(platform) if info.WelfarePhoneLotteryStatus != nil { return info.WelfarePhoneLotteryStatus.Switch } @@ -228,7 +228,7 @@ func (this *WelfareMgr) UpdateCollectConfig(cfg *webapi_proto.WelfareCollectConf cfg.Switch = model.WelfareOpen } s := int32(0) - info := this.GetAllConfig(cfg.Platform) + info := this.GetConfig(cfg.Platform) if info.WelfareCollectConfig != nil { s = info.WelfareCollectConfig.Switch } @@ -240,7 +240,7 @@ func (this *WelfareMgr) UpdateCollectConfig(cfg *webapi_proto.WelfareCollectConf } func (this *WelfareMgr) GetCollectSwitch(platform string) int32 { - info := this.GetAllConfig(platform) + info := this.GetConfig(platform) if info.WelfareCollectConfig != nil { return info.WelfareCollectConfig.Switch } @@ -253,7 +253,7 @@ func (this *WelfareMgr) OnDayChanged(player *Player) error { } player.WelfData.ReliefFundTimes = 0 - blindBox := this.GetAllConfig(player.Platform).WelfareBlindBoxDataList + blindBox := this.GetConfig(player.Platform).WelfareBlindBoxDataList if blindBox != nil { // 关闭循环重置为-1 if blindBox.Cycle == model.WelfareClose && player.WelfData.BlindBoxId != 0 { player.WelfData.BlindBoxId = -1 @@ -293,7 +293,7 @@ func (this *WelfareMgr) GetTurnplate(p *Player) { pack := &welfare.SCGetTurnplate{ OpRetCode: welfare.OpResultCode_OPRC_Error, } - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) turnplate := info.WelfareTurnplateDateList sign7 := info.Welfare7SignDateList if turnplate != nil && sign7 != nil { @@ -399,7 +399,7 @@ func (this *WelfareMgr) GetTurnplteVideo(p *Player) { p.SendToClient(int(welfare.SPacketID_PACKET_SC_WELF_GETTURNPLATE), pack) } - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) turn := info.WelfareTurnplateDateList // 转盘 sign7 := info.Welfare7SignDateList // 签到 if turn == nil || sign7 == nil { @@ -578,7 +578,7 @@ func (this *WelfareMgr) GetAddupSign(p *Player, addupday int32) { pack := &welfare.SCGetAddupSign{ OpRetCode: welfare.OpResultCode_OPRC_Error, } - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) turnplate := info.WelfareTurnplateDateList sign7 := info.Welfare7SignDateList if turnplate != nil && sign7 != nil { @@ -644,7 +644,7 @@ func (this *WelfareMgr) WelfaredInfo(p *Player) { pack := &welfare.SCWelfaredInfo{} diff := 0 ts := time.Now().Unix() - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) turnplate := info.WelfareTurnplateDateList sign7 := info.Welfare7SignDateList if turnplate != nil && sign7 != nil { @@ -720,7 +720,7 @@ func (this *WelfareMgr) WelfaredInfo(p *Player) { func (this *WelfareMgr) WelfareSwitch(p *Player, platform string, op int) { pack := &player_proto.SCEasyWelfaredInfo{} // 0转盘1盲盒2首冲3连续充值 - info := this.GetAllConfig(platform) + info := this.GetConfig(platform) // 转盘 turnplate := info.WelfareTurnplateDateList @@ -819,7 +819,7 @@ func (this *WelfareMgr) WelfareSwitch(p *Player, platform string, op int) { // Welfareturnplate 转盘红点 func (this *WelfareMgr) Welfareturnplate(p *Player, op int32) bool { // 0 红点提示 1全部领取 var isShow bool - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) turnplate := info.WelfareTurnplateDateList sign7 := info.Welfare7SignDateList if turnplate != nil && sign7 != nil { @@ -884,7 +884,7 @@ func (this *WelfareMgr) BlindBoxInfo(p *Player, bid int32) { pack := &welfare.SCBlindBoxInfo{ OpRetCode: welfare.OpResultCode_OPRC_Error, } - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) blindBox := info.WelfareBlindBoxDataList if blindBox != nil { if blindBox.Switch != model.WelfareOpen { @@ -960,7 +960,7 @@ func (this *WelfareMgr) BuyBlindBox(p *Player, buyid, ConfigPayId int32) { pack := &shop.SCPayInfo{ RetCode: shop.OpResultCode_OPRC_Error, } - blindBox := this.GetAllConfig(p.Platform).WelfareBlindBoxDataList + blindBox := this.GetConfig(p.Platform).WelfareBlindBoxDataList if blindBox == nil { logger.Logger.Tracef("BuyBlindBox blindBox==nil snid: %v pack: %v", p.SnId, pack) p.SendToClient(int(shop.SPacketID_PACKET_SCPAYINFO), pack) @@ -1062,7 +1062,7 @@ func (this *WelfareMgr) FirstPayInfo(p *Player) { pack := &welfare.SCWelfareFirstPayData{ OpRetCode: welfare.OpResultCode_OPRC_Error, } - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) firstPay := info.WelfareFirstPayDataList if firstPay != nil { pack.Switch = firstPay.Switch @@ -1146,7 +1146,7 @@ func (this *WelfareMgr) BuyFirstPay(p *Player, ConfigPayId int32) { pack := &shop.SCPayInfo{ RetCode: shop.OpResultCode_OPRC_Error, } - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) firstPay := info.WelfareFirstPayDataList if firstPay == nil { logger.Logger.Errorf("BuyFirstPay firstPay == nil snid: %v pack: %v", p.SnId, pack) @@ -1271,7 +1271,7 @@ func (this *WelfareMgr) ContinuousPayInfo(p *Player) { pack := &welfare.SCWelfareContinuousPayData{ OpRetCode: welfare.OpResultCode_OPRC_Error, } - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) continuousPay := info.WelfareContinuousPayDataList if continuousPay != nil { pack.Switch = continuousPay.Switch @@ -1355,7 +1355,7 @@ func (this *WelfareMgr) BuyContinuousPay(p *Player, ConfigPayId int32) { pack := &shop.SCPayInfo{ RetCode: shop.OpResultCode_OPRC_Error, } - info := this.GetAllConfig(p.Platform) + info := this.GetConfig(p.Platform) continuousPay := info.WelfareContinuousPayDataList if continuousPay == nil { logger.Logger.Tracef("BuyContinuousPay continuousPay == nil snid: %v pack: %v", p.SnId, pack) @@ -1483,7 +1483,7 @@ func (this *WelfareMgr) Shutdown() { } func (this *WelfareMgr) OnDayTimer() { - for _, v := range this.ConfigMgr.Platform { + for _, v := range this.GetConfigs() { v.BlindBoxCycle = 0 v.FirstPayCycle = 0 v.ContinuousPayCycle = 0