diff --git a/comm/const.go b/comm/const.go index e8e448768..c55a544ef 100644 --- a/comm/const.go +++ b/comm/const.go @@ -228,10 +228,13 @@ const ( //Rpc Rpc_ModuleArenaRaceSettlement core.Rpc_Key = "Rpc_ModuleArenaRaceSettlement" //竞技场比赛结算信息 // 充值发货 - Rpc_ModulePayDelivery core.Rpc_Key = "Rpc_ModuleArenaRaceSettlement" //充值发货 + Rpc_ModulePayDelivery core.Rpc_Key = "Rpc_ModulePayDelivery" //充值发货 // 羁绊信息 Rpc_ModuleFetter core.Rpc_Key = "Rpc_ModuleFetter" + + // 赛季塔计算邮件奖励 + Rpc_ModuleSeasonPagodaReward core.Rpc_Key = "Rpc_ModuleSeasonPagodaReward" ) //事件类型定义处 diff --git a/modules/hero/api_talentreset.go b/modules/hero/api_talentreset.go index 2d716ddf0..9e37aadd0 100644 --- a/modules/hero/api_talentreset.go +++ b/modules/hero/api_talentreset.go @@ -3,6 +3,7 @@ package hero import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" "google.golang.org/protobuf/proto" ) @@ -17,8 +18,9 @@ func (this *apiComp) TalentResetCheck(session comm.IUserSession, req *pb.HeroTal func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentResetReq) (code pb.ErrorCode, data proto.Message) { var ( - heroList []*pb.DBHero - chanegCard []*pb.DBHero // 推送属性变化 + heroList []*pb.DBHero + chanegCard []*pb.DBHero // 推送属性变化 + talentPoint int32 // 已经消耗的天赋点数 ) if code = this.TalentResetCheck(session, req); code != pb.ErrorCode_Success { return @@ -41,6 +43,19 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe return } + for k := range _talent.Talent { + if conf := this.module.configure.GetHeroTalent(k); conf != nil { + talentPoint += conf.Point // 获取当前英雄的天赋点数 + } + res := &cfg.Gameatn{ + A: "item", + T: _talent.HeroId, + N: talentPoint, + } + if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success { + this.module.Errorf("DispenseRes err,uid:%s,item:%v", session.GetUserId(), res) + } // 返还升级的天赋点数 + } if len(_talent.Talent) > 0 { update := make(map[string]interface{}, 0) szTalent := map[int32]int32{} diff --git a/modules/pagoda/api_ranklist.go b/modules/pagoda/api_ranklist.go index 534b1509d..3f6eb0b3b 100644 --- a/modules/pagoda/api_ranklist.go +++ b/modules/pagoda/api_ranklist.go @@ -45,8 +45,6 @@ func (this *apiComp) RankList(session comm.IUserSession, req *pb.PagodaRankListR return } _data3 := rd.Val() - _data, err2 := rd.Result() - this.module.Errorln(_data, err2, _data3) for _, v := range _data3 { conn_, err := db.Cross() dbModel := db.NewDBModel(comm.TableSeasonRecord, time.Hour, conn_) diff --git a/modules/pagoda/comp_configure.go b/modules/pagoda/comp_configure.go index 2aa86a989..91a426b12 100644 --- a/modules/pagoda/comp_configure.go +++ b/modules/pagoda/comp_configure.go @@ -1,6 +1,7 @@ package pagoda import ( + "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" @@ -63,6 +64,9 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp log.Errorf("get game_pagoda conf err:%v", err) return }) + + _data := this.GetPagodaSeasonReward() + fmt.Printf("%v", _data) return } @@ -163,3 +167,21 @@ func (this *configureComp) GetPassCheckByID(id int32) *cfg.GamePassCheckData { } return nil } + +// 获取 +func (this *configureComp) GetPagodaSeasonReward() [][]int32 { + rank := make([][]int32, 0) + if v, err := this.GetConfigure(game_pagodaseasonreward); err == nil { + var ( + configure *cfg.GamePagodaSeasonReward + ok bool + ) + if configure, ok = v.(*cfg.GamePagodaSeasonReward); ok { + for _, v := range configure.GetDataList() { + rank = append(rank, v.Ranking) + } + return rank + } + } + return nil +} diff --git a/modules/pagoda/model_rank.go b/modules/pagoda/model_rank.go index 5f47a2ae9..d9c802bf5 100644 --- a/modules/pagoda/model_rank.go +++ b/modules/pagoda/model_rank.go @@ -241,3 +241,44 @@ func (this *ModelRank) SetNormalPagodaRankList(tableName string, score int32, ui } } + +func (this *ModelRank) seasonSettlement() { + + list := this.modulePagoda.configure.GetPagodaSeasonReward() + if list == nil { + return + } + if !db.IsCross() { + if conn, err := db.Cross(); err == nil { + var ( + pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO()) + Items []*pb.UserAssets + ) + + rd := pipe.ZRange("pagodaSeasonRank0", 0, 50) + + if _, err = pipe.Exec(); err != nil { + this.modulePagoda.Errorln(err) + return + } + uids := rd.Val() + + if len(uids) > 0 { + Items = make([]*pb.UserAssets, 0) //TO 排名配置 + // for i, v := range v.RankReward { + // Items[i] = &pb.UserAssets{ + // A: v.A, + // T: v.T, + // N: v.N, + // } + // } + //发邮件 + this.modulePagoda.mail.SendNewMail(&pb.DBMailData{ + CreateTime: uint64(configure.Now().Unix()), + Items: Items, + }, uids...) + } + } + } + +} diff --git a/modules/pagoda/module.go b/modules/pagoda/module.go index 629469b8a..01b542744 100644 --- a/modules/pagoda/module.go +++ b/modules/pagoda/module.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "go_dreamfactory/comm" + "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/redis/pipe" @@ -22,7 +23,8 @@ type Pagoda struct { modulerank *ModelRank configure *configureComp battle comm.IBattle - service core.IService + service base.IRPCXService + mail comm.Imail } func NewModule() core.IModule { @@ -35,7 +37,7 @@ func (this *Pagoda) GetType() core.M_Modules { func (this *Pagoda) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { err = this.ModuleBase.Init(service, module, options) - this.service = service + this.service = service.(base.IRPCXService) return } @@ -71,8 +73,12 @@ func (this *Pagoda) Start() (err error) { if module, err = this.service.GetModule(comm.ModuleBattle); err != nil { return } - + if module, err = this.service.GetModule(comm.ModuleMail); err != nil { + return + } + this.mail = module.(comm.Imail) this.battle = module.(comm.IBattle) + this.service.RegisterFunctionName(string(comm.Rpc_ModuleSeasonPagodaReward), this.Rpc_ModuleSeasonPagodaReward) return } @@ -169,3 +175,7 @@ func (this *Pagoda) CheckPoint(uid string) bool { } return true } +func (this *Pagoda) Rpc_ModuleSeasonPagodaReward(ctx context.Context, args *pb.EmptyReq, reply *pb.EmptyResp) { + this.Debug("Rpc_ModuleSeasonPagodaReward", log.Field{Key: "args", Value: args.String()}) + this.modulerank.seasonSettlement() +} diff --git a/modules/timer/season.go b/modules/timer/season.go index 2b25b4fdd..955be891f 100644 --- a/modules/timer/season.go +++ b/modules/timer/season.go @@ -10,11 +10,11 @@ import ( cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" + "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/sys/cron" "go_dreamfactory/lego/sys/log" - "go_dreamfactory/lego/sys/redis/pipe" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" @@ -30,7 +30,7 @@ type SeasonPagoda struct { cbase.ModuleCompBase modules.MCompConfigure modules.MCompModel - service core.IService + service base.IRPCXService module *Timer mail comm.Imail } @@ -40,7 +40,7 @@ func (this *SeasonPagoda) Init(service core.IService, module core.IModule, comp this.MCompConfigure.Init(service, module, comp, options) this.TableName = comm.TableSeasonPagoda this.MCompModel.Init(service, module, comp, options) - this.service = service + this.service = service.(base.IRPCXService) this.module = module.(*Timer) if module1, err := this.service.GetModule(comm.ModuleMail); err == nil { @@ -104,28 +104,6 @@ func (this *SeasonPagoda) GetSeasonLoop(id int32) *cfg.GameSeasonLoopData { // // 赛季塔结束 func (this *SeasonPagoda) TimerSeasonOver() { this.module.Debugf("TimerSeasonOver:%d", configure.Now().Unix()) - - if conn, err := db.Cross(); err == nil { - var ( - pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO()) - ) - - rd := pipe.ZRange("pagodaSeasonRank", 0, 50) - - if _, err = pipe.Exec(); err != nil { - this.module.Errorln(err) - return - } - _data3 := rd.Val() - this.module.Debugf("%v", _data3) - //sz := this.GetSeasonReward() - - // this.mail.SendNewMail(&pb.DBMailData{ - // CreateTime: uint64(configure.Now().Unix()), - // Items: nil, - // }, _data3...) - } - if db.IsCross() { if conn, err := db.Cross(); err == nil { if rst := conn.Mgo.FindOne(comm.TableServerData, bson.M{}); rst != nil { @@ -156,12 +134,22 @@ func (this *SeasonPagoda) TimerSeasonOver() { } } - //star := configure.Now() - this.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete()) - //this.module.Debugf("=====%d,", time.Since(star).Milliseconds()) + if _, err := this.service.RpcGo(context.Background(), + comm.Service_Worker, + string(comm.Rpc_ModuleSeasonPagodaReward), + pb.EmptyReq{}, + nil, + ); err != nil { + this.module.Errorln(err) + } } // 赛季塔开始 func (this *SeasonPagoda) TimerSeasonStar() { this.module.Debugf("TimerSeasonStar:%d", configure.Now().Unix()) + + // 打印耗时 + //star := configure.Now() + this.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete()) + //this.module.Debugf("=====%d,", time.Since(star).Milliseconds()) }