diff --git a/comm/const.go b/comm/const.go index 016d28de6..5c32ea50d 100644 --- a/comm/const.go +++ b/comm/const.go @@ -686,8 +686,11 @@ const ( //公会 Reddot15102 ReddotType = 15102 //公会----签到红点 今日剩余签到 Reddot15201 ReddotType = 15201 //公会----申请红点 - Reddot15301 ReddotType = 15301 //公会----公会副本 今日剩余挑战次数:x - Reddot15401 ReddotType = 15401 //公会----公会任务 今日剩余任务:x + Reddot15301 ReddotType = 15301 //公会----任务待领取 + Reddot15302 ReddotType = 15302 //公会----活跃度待领取 + Reddot15400 ReddotType = 15400 //公会----公会远征 可挑战 + //工会boos + //主线关卡 //Reddot11100 ReddotType = 11100 //主线关卡----可挑战红点 -- 废弃 // 铁匠铺 diff --git a/comm/imodule.go b/comm/imodule.go index ce0b10930..c322f3987 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -639,7 +639,11 @@ type ( IGetReddot ModifyBooslv(session IUserSession, lv int32) (errdata *pb.ErrorData) } - + //远征 + IExpedition interface { + ///红点 + IGetReddot + } //购物中心 IShopcenter interface { IActivityNotice diff --git a/modules/expedition/model.go b/modules/expedition/model.go index 3ff1000ee..a6e4f4ad3 100644 --- a/modules/expedition/model.go +++ b/modules/expedition/model.go @@ -212,15 +212,35 @@ func (this *guildgveModel) userlock(id string) (result *redis.RedisMutex, err er } // 获取用户全部的埋点数据 -func (this *guildgveModel) getGuildGve(guildid string) (results *pb.DBGuildGve, err error) { - - results = &pb.DBGuildGve{ - Boos: make([]*pb.DBGuildGveBoss, 0), - } - if err = this.model.GetByID(guildid, results); err != nil { +func (this *guildgveModel) getInfo(guildid string) (result *pb.DBExpedition, err error) { + var ( + confs []*cfg.GameExpeditionBossData + ) + result = &pb.DBExpedition{} + if err = this.model.GetByID(guildid, result); err != nil && err != mgo.MongodbNil { this.module.Errorln(err) return } + if err == mgo.MongodbNil { + if confs, err = this.module.configure.getGameExpeditionBoosDatas(1); err != nil { + return + } + result = &pb.DBExpedition{ + Guildid: guildid, + Lv: 1, + Refresh: configure.Now().Unix(), + Indexboos: 0, + Boos: make([]*pb.DBExpeditionBoos, 0), + } + for _, v := range confs { + result.Boos = append(result.Boos, &pb.DBExpeditionBoos{ + Boosid: v.BossId, + Hp: v.Fighting, + Members: make(map[string]*pb.DBExpeditionMember), + }) + } + err = this.model.Add(guildid, result) + } return } diff --git a/modules/expedition/module.go b/modules/expedition/module.go index 9bd2a1fd9..543ffc44f 100644 --- a/modules/expedition/module.go +++ b/modules/expedition/module.go @@ -64,16 +64,52 @@ func (this *Expedition) OnInstallComp() { } // 红点 -func (this *Expedition) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { - var () - reddot = make(map[comm.ReddotType]*pb.ReddotItem) - - for _, v := range rid { - switch v { - case comm.Reddot15301: - +// 红点需求 +func (this *Expedition) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { + var ( + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot15400} + model *guildgveModel + user *pb.DBUserExpand + info *pb.DBExpedition + member *pb.DBExpeditionMember + err error + ok bool + ) + items = make(map[comm.ReddotType]*pb.ReddotItem) + for _, v := range selfrid { + if _, ok = rid[v]; ok { break } } + if ok { + return + } + for _, v := range selfrid { + if _, ok = rid[v]; ok { + switch v { + case comm.Reddot15400: + state := getSysDayTimeState() + if state == 1 { + if user, err = this.GetUserExpandForSession(session); user.SociatyId != "" { + if model, err = this.model.guildgveModel(); err != nil { + this.Errorln(err) + return + } + if info, err = model.getInfo(user.SociatyId); err != nil { + this.Errorln(err) + return + } + if member, ok = info.Boos[info.Indexboos].Members[session.GetUserId()]; !ok || member.State == 0 { + items[comm.Reddot17] = &pb.ReddotItem{ + Rid: int32(comm.Reddot17), + Activated: true, + } + } + } + } + break + } + } + } return } diff --git a/modules/reddot/module.go b/modules/reddot/module.go index 0680e9865..a678c48ff 100644 --- a/modules/reddot/module.go +++ b/modules/reddot/module.go @@ -22,23 +22,23 @@ type Reddot struct { modules.ModuleBase service base.IRPCXService - smithy comm.ISmithy //铁匠铺 - library comm.ILibrary //羁绊 - mail comm.Imail //邮件 - sociaty comm.ISociaty //工会 - pagoda comm.IPagoda - horoscope comm.IHoroscope - arena comm.IArena //竞技场 - practice comm.IPractice //武馆 - dailytask comm.IDailytask //每日任务 - friend comm.IFriend - gourmet comm.IGourmet - viking comm.IViking - hunting comm.IHunting - guildgve comm.IGuildgve //工会boos战 - - api_comp *apiComp - mainline comm.IMainline + smithy comm.ISmithy //铁匠铺 + library comm.ILibrary //羁绊 + mail comm.Imail //邮件 + sociaty comm.ISociaty //工会 + pagoda comm.IPagoda + horoscope comm.IHoroscope + arena comm.IArena //竞技场 + practice comm.IPractice //武馆 + dailytask comm.IDailytask //每日任务 + friend comm.IFriend + gourmet comm.IGourmet + viking comm.IViking + hunting comm.IHunting + guildgve comm.IGuildgve //工会boos战 + expedition comm.IExpedition //工会远征 + api_comp *apiComp + mainline comm.IMainline } // 模块名 diff --git a/modules/sociaty/module.go b/modules/sociaty/module.go index 2135e110a..a5ee91c29 100644 --- a/modules/sociaty/module.go +++ b/modules/sociaty/module.go @@ -178,15 +178,16 @@ func (this *Sociaty) GetSociatys(sociatyIds []string) (result []*pb.DBSociaty, e return } -// 公会 +// 公会红点 func (this *Sociaty) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { var ( - selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot15102, comm.Reddot15201, comm.Reddot15401} - applyReddot bool - tasks *pb.DBSociatyTask - nocomplete int32 - err error - ok bool + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot15102, comm.Reddot15201, comm.Reddot15301} + applyReddot bool + tasks *pb.DBSociatyTask + comdi []int32 + condisProgress []*pb.ConIProgress + err error + ok bool ) items = make(map[comm.ReddotType]*pb.ReddotItem) @@ -202,15 +203,7 @@ func (this *Sociaty) Reddot(session comm.IUserSession, rid map[comm.ReddotType]s if sociaty == nil || sociaty.Id == "" { return } - if this.modelSociaty.isRight(session.GetUserId(), sociaty, - pb.SociatyJob_PRESIDENT, - pb.SociatyJob_VICEPRESIDENT, - pb.SociatyJob_ADMIN) { - if len(sociaty.ApplyRecord) > 0 { - applyReddot = true - } - } for _, v := range selfrid { if _, ok = rid[v]; ok { switch v { @@ -229,26 +222,52 @@ func (this *Sociaty) Reddot(session comm.IUserSession, rid map[comm.ReddotType]s Total: 1, } case comm.Reddot15201: + if this.modelSociaty.isRight(session.GetUserId(), sociaty, + pb.SociatyJob_PRESIDENT, + pb.SociatyJob_VICEPRESIDENT, + pb.SociatyJob_ADMIN) { + if len(sociaty.ApplyRecord) > 0 { + applyReddot = true + } + } items[comm.Reddot15201] = &pb.ReddotItem{ Rid: int32(comm.Reddot15201), Activated: applyReddot, Nextchanagetime: 0, } - case comm.Reddot15401: + case comm.Reddot15301: if tasks, err = this.modelSociatyTask.getUserTask(session.GetUserId(), sociaty.Id); err != nil { continue } - for _, v := range tasks.TaskList { - if v != 1 { - nocomplete++ + for k, _ := range tasks.TaskList { + comdi = append(comdi, k) + } + if _, condisProgress, err = this.ModuleBuried.CheckCondition(session, comdi...); err != nil { + this.Errorln(err) + return + } + for _, v := range condisProgress { + if v.State == pb.BuriedItemFinishState_buried_finish { + if value, ok := tasks.TaskList[v.Conid]; !ok || value == 0 { + items[comm.Reddot15301] = &pb.ReddotItem{ + Rid: int32(comm.Reddot15301), + Activated: true, + } + break + } } } - items[comm.Reddot15401] = &pb.ReddotItem{ - Rid: int32(comm.Reddot15401), - Activated: true, - Nextchanagetime: 0, - Progress: nocomplete, - Total: int32(len(tasks.TaskList)), + case comm.Reddot15400: + for _, v := range this.sociatyActivityConf.GetDataMap() { + if sociaty.Activity >= v.Activity { + if value, ok := tasks.ActivityList[v.Id]; !ok || value == 0 { + items[comm.Reddot15301] = &pb.ReddotItem{ + Rid: int32(comm.Reddot15400), + Activated: true, + } + break + } + } } } } @@ -338,47 +357,16 @@ type TaskParams struct { // 任务条件达成通知 // 废弃 不需要主动推送任务变化 前端主动刷新页面即可 func (this *Sociaty) BuriedsNotify(session comm.IUserSession, conds []*pb.ConIProgress) { - // log.Debug("公会任务通知", - // log.Field{Key: "uid", Value: session.GetUserId()}, - // log.Field{Key: "condIds", Value: conds}) + log.Debug("公会任务通知", + log.Field{Key: "uid", Value: session.GetUserId()}, + log.Field{Key: "condIds", Value: conds}) - // sociaty := this.modelSociaty.getUserSociaty(session.GetUserId()) - // if sociaty == nil { - // return - // } - - // sociatyId := sociaty.Id - - // dt := &pb.DBSociatyTask{} - // err := this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), - // comm.Service_Worker, string(comm.Rpc_ModuleSociatyGetTask), - // &pb.RPCGeneralReqA2{Param1: sociatyId, Param2: session.GetUserId()}, dt) - - // var flag bool - // for _, v := range dt.TaskList { - // for _, cond := range conds { - // if v.TaskId == cond.Conid && cond.State == pb.BuriedItemFinishState_buried_finish { - // v.Status = 1 - // flag = true - // } - // } - // } - // if !flag { - // return - // } - - // update := map[string]interface{}{ - // "taskList": dt.TaskList, - // "lastUpdateTime": configure.Now().Unix(), - // } - - // err = this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), - // comm.Service_Worker, string(comm.Rpc_ModuleSociatyTask), - // &TaskParams{SociatyId: sociatyId, Uid: session.GetUserId(), Data: update}, &pb.EmptyResp{}) - // if err != nil { - // return - // } - // return + session.SendMsg(string(comm.ModuleReddot), "change", &pb.ReddotChangePush{Rids: []*pb.ReddotItem{ + { + Rid: int32(comm.Reddot15301), + Activated: true, + }, + }}) } func (this *Sociaty) RpcUpdateUserTask(ctx context.Context, p *TaskParams, reply *pb.EmptyResp) error {