From 6373c1cf0cbc4894c9e6d19ecf3494f9956a9355 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Sat, 14 Jan 2023 18:39:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=85=AC=E4=BC=9Aboss=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/ui/views/sociaty_boss.go | 61 ++++- comm/const.go | 2 +- modules/sociaty/api_cross_Formation.go | 2 +- modules/sociaty/api_cross_accuse.go | 2 +- modules/sociaty/api_cross_activitylist.go | 2 +- modules/sociaty/api_cross_activityreceive.go | 2 +- modules/sociaty/api_cross_agree.go | 2 +- modules/sociaty/api_cross_apply.go | 2 +- modules/sociaty/api_cross_applylist.go | 2 +- modules/sociaty/api_cross_assign.go | 2 +- modules/sociaty/api_cross_bossmain.go | 22 +- ...i_cross_brank.go => api_cross_bossrank.go} | 2 +- modules/sociaty/api_cross_buy.go | 2 +- modules/sociaty/api_cross_challengefinish.go | 2 +- modules/sociaty/api_cross_challengestart.go | 2 +- modules/sociaty/api_cross_discharge.go | 2 +- modules/sociaty/api_cross_dismiss.go | 2 +- modules/sociaty/api_cross_log.go | 2 +- modules/sociaty/api_cross_members.go | 2 +- modules/sociaty/api_cross_mine.go | 2 +- modules/sociaty/api_cross_quit.go | 2 +- modules/sociaty/api_cross_receive.go | 2 +- modules/sociaty/api_cross_refuse.go | 2 +- modules/sociaty/api_cross_search.go | 2 +- modules/sociaty/api_cross_setting.go | 2 +- modules/sociaty/api_cross_settingjob.go | 2 +- modules/sociaty/api_cross_sign.go | 2 +- modules/sociaty/api_cross_tasklist.go | 2 +- modules/sociaty/model_sociaty.go | 13 +- modules/sociaty/model_sociatyboss.go | 209 +++++++++++------ modules/user/module.go | 26 ++- pb/sociaty_db.pb.go | 216 +++++++++--------- 32 files changed, 367 insertions(+), 232 deletions(-) rename modules/sociaty/{api_cross_brank.go => api_cross_bossrank.go} (96%) diff --git a/cmd/v2/ui/views/sociaty_boss.go b/cmd/v2/ui/views/sociaty_boss.go index e91d4b201..79d972b2b 100644 --- a/cmd/v2/ui/views/sociaty_boss.go +++ b/cmd/v2/ui/views/sociaty_boss.go @@ -24,10 +24,13 @@ type SociatyBossView struct { BaseformView itemList common.ItemList + rankItemList common.ItemList //排行榜 heroListFlag bool teamFlag bool bossFlag bool + rankFlag bool heroList func() + rankList func() sociatyId string teams map[int32]*pb.ChallengeTeam endTimeLabel *widget.Label // 赛季结束时间 @@ -73,7 +76,8 @@ func (s *SociatyBossView) CreateView(t *model.TestCase) fyne.CanvasObject { challengestartBtn := widget.NewButton("开始挑战", s.challengestart) challengefinishBtn := widget.NewButton("挑战结束", s.challengefinish) ticketBuyBtn := widget.NewButton("挑战券", s.buy) - btns := container.NewHBox(buzhenBtn, challengestartBtn, challengefinishBtn, ticketBuyBtn) + rankBtn := widget.NewButton("排行榜", s.rank) + btns := container.NewHBox(buzhenBtn, challengestartBtn, challengefinishBtn, ticketBuyBtn, rankBtn) bottomLabels := container.NewHBox( s.ticketLabel, s.settleTimeLabel, s.endTimeLabel, ) @@ -343,6 +347,61 @@ func (s *SociatyBossView) buzhen() { dconf.Show() } +// 排行榜 +func (s *SociatyBossView) rank() { + s.rankItemList = *common.NewItemList() + s.rankItemList.ItemList = s.itemList.CreateList() + + s.rankList = func() { + if err := service.GetPttService().SendToClient(string(comm.ModuleSociaty), "brank", &pb.SociatyBRankReq{ + RankType: 1, + }); err != nil { + logrus.Error(err) + return + } + } + defer s.rankList() + + layout := container.NewBorder(nil, nil, nil, nil, s.rankItemList.ItemList) + + dconf := dialog.NewCustom("排行榜", "关闭", layout, s.w) + dconf.Resize(fyne.NewSize(800, 500)) + dconf.Show() + s.listenRank() +} + +func (this *SociatyBossView) listenRank() { + if this.rankFlag { + return + } + + this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{ + OnNotify: func(d interface{}, args ...interface{}) { + data := d.(*pb.UserMessage) + if !(data.MainType == string(comm.ModuleSociaty) && + data.SubType == sociaty.SociatySubTypeBrank) { + return + } + + rsp := &pb.SociatyBRankResp{} + if !comm.ProtoUnmarshal(data, rsp) { + logrus.Error("unmarshal err") + return + } + + for _, v := range rsp.Rank { + item := common.Item{ + Text: fmt.Sprintf("%d 昵称:%v 公会:%s Lv:%d 积分:%d", + v.Ranking, v.Name, v.SociatyName, v.Lv, v.Integral), + } + this.itemList.AddItem(item) + } + }, + }) + + this.rankFlag = true +} + func (this *SociatyBossView) HeroDataListener() { if this.heroListFlag { return diff --git a/comm/const.go b/comm/const.go index 5cd10c6f8..dc635beea 100644 --- a/comm/const.go +++ b/comm/const.go @@ -184,7 +184,7 @@ const ( // 公会日志 TableSociatyLog = "sociatylog" // 公会BOSS - TableSociatyBoss = "sociatybsoss" + TableSociatyBoss = "sociatyboss" ///充值数据表 TablePay = "payorder" diff --git a/modules/sociaty/api_cross_Formation.go b/modules/sociaty/api_cross_Formation.go index 4774c637f..100945174 100644 --- a/modules/sociaty/api_cross_Formation.go +++ b/modules/sociaty/api_cross_Formation.go @@ -49,7 +49,7 @@ func (this *apiComp) Formation(session comm.IUserSession, req *pb.SociatyBFormat } sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_accuse.go b/modules/sociaty/api_cross_accuse.go index 650275e22..b41781bd6 100644 --- a/modules/sociaty/api_cross_accuse.go +++ b/modules/sociaty/api_cross_accuse.go @@ -21,7 +21,7 @@ func (this *apiComp) Accuse(session comm.IUserSession, req *pb.SociatyAccuseReq) } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_activitylist.go b/modules/sociaty/api_cross_activitylist.go index fcd9d1f17..621561df4 100644 --- a/modules/sociaty/api_cross_activitylist.go +++ b/modules/sociaty/api_cross_activitylist.go @@ -17,7 +17,7 @@ func (this *apiComp) ActivitylistCheck(session comm.IUserSession, req *pb.Sociat func (this *apiComp) Activitylist(session comm.IUserSession, req *pb.SociatyActivityListReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_activityreceive.go b/modules/sociaty/api_cross_activityreceive.go index 40c665bf6..07d8b9891 100644 --- a/modules/sociaty/api_cross_activityreceive.go +++ b/modules/sociaty/api_cross_activityreceive.go @@ -23,7 +23,7 @@ func (this *apiComp) Activityreceive(session comm.IUserSession, req *pb.SociatyA } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_agree.go b/modules/sociaty/api_cross_agree.go index ddd219415..7cacc210e 100644 --- a/modules/sociaty/api_cross_agree.go +++ b/modules/sociaty/api_cross_agree.go @@ -25,7 +25,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) ( } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_apply.go b/modules/sociaty/api_cross_apply.go index ae62325b1..ee79d6fd0 100644 --- a/modules/sociaty/api_cross_apply.go +++ b/modules/sociaty/api_cross_apply.go @@ -31,7 +31,7 @@ func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) ( uid := session.GetUserId() sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("公会未找到", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: req.SociatyId}) return diff --git a/modules/sociaty/api_cross_applylist.go b/modules/sociaty/api_cross_applylist.go index 3ee9ff1ef..9bacfcbad 100644 --- a/modules/sociaty/api_cross_applylist.go +++ b/modules/sociaty/api_cross_applylist.go @@ -24,7 +24,7 @@ func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyLi } uid := session.GetUserId() sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("公会未找到", log.Field{Key: "uid", Value: uid}, diff --git a/modules/sociaty/api_cross_assign.go b/modules/sociaty/api_cross_assign.go index fb7228d53..3a6280b1c 100644 --- a/modules/sociaty/api_cross_assign.go +++ b/modules/sociaty/api_cross_assign.go @@ -31,7 +31,7 @@ func (this *apiComp) Assign(session comm.IUserSession, req *pb.SociatyAssignReq) } sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_bossmain.go b/modules/sociaty/api_cross_bossmain.go index df800bed4..c1d8fae20 100644 --- a/modules/sociaty/api_cross_bossmain.go +++ b/modules/sociaty/api_cross_bossmain.go @@ -36,22 +36,20 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq Ticket: userEx.SociatyTicket, } - // 未开始 - if !this.module.modelSociatyBoss.sportsIsStarted() { - if userEx.SociatyTicket != ggd.GuildBossInitialNum { - userEx.SociatyTicket = ggd.GuildBossInitialNum - update := map[string]interface{}{ - "sociatyTicket": userEx.SociatyTicket, - } - if err := this.module.ModuleUser.ChangeUserExpand(uid, update); err != nil { - code = pb.ErrorCode_DBError - return - } + // 未参赛(恢复挑战券) + if !this.module.modelSociatyBoss.IsSports(uid) { + userEx.SociatyTicket = ggd.GuildBossInitialNum + update := map[string]interface{}{ + "sociatyTicket": userEx.SociatyTicket, + } + if err := this.module.ModuleUser.ChangeUserExpand(uid, update); err != nil { + code = pb.ErrorCode_DBError + return } } sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_brank.go b/modules/sociaty/api_cross_bossrank.go similarity index 96% rename from modules/sociaty/api_cross_brank.go rename to modules/sociaty/api_cross_bossrank.go index 950e03db4..820414264 100644 --- a/modules/sociaty/api_cross_brank.go +++ b/modules/sociaty/api_cross_bossrank.go @@ -20,7 +20,7 @@ func (this *apiComp) Brank(session comm.IUserSession, req *pb.SociatyBRankReq) ( } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_buy.go b/modules/sociaty/api_cross_buy.go index 29a0a2664..2b0a22cca 100644 --- a/modules/sociaty/api_cross_buy.go +++ b/modules/sociaty/api_cross_buy.go @@ -28,7 +28,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.SociatyBuyReq) (code } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_challengefinish.go b/modules/sociaty/api_cross_challengefinish.go index 7895efa6c..a2fde41be 100644 --- a/modules/sociaty/api_cross_challengefinish.go +++ b/modules/sociaty/api_cross_challengefinish.go @@ -19,7 +19,7 @@ func (this *apiComp) Challengefinish(session comm.IUserSession, req *pb.SociatyB } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_challengestart.go b/modules/sociaty/api_cross_challengestart.go index a15e23d08..3574419e3 100644 --- a/modules/sociaty/api_cross_challengestart.go +++ b/modules/sociaty/api_cross_challengestart.go @@ -21,7 +21,7 @@ func (this *apiComp) Challengestart(session comm.IUserSession, req *pb.SociatyBC uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_discharge.go b/modules/sociaty/api_cross_discharge.go index f41b7ec46..722e0141d 100644 --- a/modules/sociaty/api_cross_discharge.go +++ b/modules/sociaty/api_cross_discharge.go @@ -25,7 +25,7 @@ func (this *apiComp) Discharge(session comm.IUserSession, req *pb.SociatyDischar } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_dismiss.go b/modules/sociaty/api_cross_dismiss.go index fe7cd8b03..1d6bed4ab 100644 --- a/modules/sociaty/api_cross_dismiss.go +++ b/modules/sociaty/api_cross_dismiss.go @@ -25,7 +25,7 @@ func (this *apiComp) Dismiss(session comm.IUserSession, req *pb.SociatyDismissRe } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_log.go b/modules/sociaty/api_cross_log.go index 2c19d0901..f6e7cf126 100644 --- a/modules/sociaty/api_cross_log.go +++ b/modules/sociaty/api_cross_log.go @@ -17,7 +17,7 @@ func (this *apiComp) LogCheck(session comm.IUserSession, req *pb.SociatyLogReq) func (this *apiComp) Log(session comm.IUserSession, req *pb.SociatyLogReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_members.go b/modules/sociaty/api_cross_members.go index df6cb66c0..fee77661d 100644 --- a/modules/sociaty/api_cross_members.go +++ b/modules/sociaty/api_cross_members.go @@ -17,7 +17,7 @@ func (this *apiComp) MembersCheck(session comm.IUserSession, req *pb.SociatyMemb func (this *apiComp) Members(session comm.IUserSession, req *pb.SociatyMembersReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_mine.go b/modules/sociaty/api_cross_mine.go index abb4e6a85..c006ca287 100644 --- a/modules/sociaty/api_cross_mine.go +++ b/modules/sociaty/api_cross_mine.go @@ -40,7 +40,7 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (co // 获取公会 sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_quit.go b/modules/sociaty/api_cross_quit.go index 01230dfa9..c7e543b5e 100644 --- a/modules/sociaty/api_cross_quit.go +++ b/modules/sociaty/api_cross_quit.go @@ -18,7 +18,7 @@ func (this *apiComp) QuitCheck(session comm.IUserSession, req *pb.SociatyQuitReq func (this *apiComp) Quit(session comm.IUserSession, req *pb.SociatyQuitReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_receive.go b/modules/sociaty/api_cross_receive.go index 722897657..5fc33d057 100644 --- a/modules/sociaty/api_cross_receive.go +++ b/modules/sociaty/api_cross_receive.go @@ -24,7 +24,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.SociatyReceiveRe } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_refuse.go b/modules/sociaty/api_cross_refuse.go index 5e5f81440..d9f324cfe 100644 --- a/modules/sociaty/api_cross_refuse.go +++ b/modules/sociaty/api_cross_refuse.go @@ -24,7 +24,7 @@ func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SociatyRefuseReq) } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_search.go b/modules/sociaty/api_cross_search.go index 289127671..30c611008 100644 --- a/modules/sociaty/api_cross_search.go +++ b/modules/sociaty/api_cross_search.go @@ -24,7 +24,7 @@ func (this *apiComp) Search(session comm.IUserSession, req *pb.SociatySearchReq) rsp := &pb.SociatySearchResp{} sociaty := this.module.modelSociaty.findByName(req.Name) - if sociaty != nil && sociaty.Id != "" { + if sociaty == nil { rsp.List = append(rsp.List, sociaty) } diff --git a/modules/sociaty/api_cross_setting.go b/modules/sociaty/api_cross_setting.go index c310c3f95..3937ea86e 100644 --- a/modules/sociaty/api_cross_setting.go +++ b/modules/sociaty/api_cross_setting.go @@ -25,7 +25,7 @@ func (this *apiComp) Setting(session comm.IUserSession, req *pb.SociatySettingRe uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_settingjob.go b/modules/sociaty/api_cross_settingjob.go index 1792b2ebd..56ea5ad16 100644 --- a/modules/sociaty/api_cross_settingjob.go +++ b/modules/sociaty/api_cross_settingjob.go @@ -24,7 +24,7 @@ func (this *apiComp) SettingJob(session comm.IUserSession, req *pb.SociatySettin uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil{ code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_sign.go b/modules/sociaty/api_cross_sign.go index a18d1544b..970f26666 100644 --- a/modules/sociaty/api_cross_sign.go +++ b/modules/sociaty/api_cross_sign.go @@ -20,7 +20,7 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty != nil && sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/api_cross_tasklist.go b/modules/sociaty/api_cross_tasklist.go index 73f8a74f3..003735d0d 100644 --- a/modules/sociaty/api_cross_tasklist.go +++ b/modules/sociaty/api_cross_tasklist.go @@ -17,7 +17,7 @@ func (this *apiComp) TaskListCheck(session comm.IUserSession, req *pb.SociatyTas func (this *apiComp) TaskList(session comm.IUserSession, req *pb.SociatyTaskListReq) (code pb.ErrorCode, data proto.Message) { uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty.Id == "" { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return diff --git a/modules/sociaty/model_sociaty.go b/modules/sociaty/model_sociaty.go index e9ddeb97b..92a2806c7 100644 --- a/modules/sociaty/model_sociaty.go +++ b/modules/sociaty/model_sociaty.go @@ -91,9 +91,7 @@ func (this *ModelSociaty) isNameExist(name string) error { // 公会列表 func (this *ModelSociaty) list(uid string, filter pb.SociatyListFilter) (list []*pb.DBSociaty) { user := this.module.ModuleUser.GetUser(uid) - // if err != nil { - // return - // } + if user == nil { return } @@ -169,7 +167,10 @@ func (this *ModelSociaty) getSociaty(sociatyId string) (sociaty *pb.DBSociaty) { sociaty = &pb.DBSociaty{} if err := this.GetListObj(comm.RDS_EMPTY, sociatyId, sociaty); err != nil { log.Error("GetListObj", log.Field{Key: "sociatyId", Value: sociatyId}) - return + return nil + } + if sociaty.Id == "" { + return nil } return } @@ -202,7 +203,7 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) { } if userEx.SociatyId != "" { sociaty = this.getSociaty(userEx.SociatyId) - if sociaty.Id != "" { + if sociaty != nil { //验证是否解散 if this.isDismiss(sociaty) { sociaty.Id = "" @@ -970,5 +971,3 @@ func (s *ModelSociaty) clearSigned(sociaty *pb.DBSociaty) error { } return s.updateSociaty(sociaty.Id, update) } - - diff --git a/modules/sociaty/model_sociatyboss.go b/modules/sociaty/model_sociatyboss.go index 920df6cf2..e562f1104 100644 --- a/modules/sociaty/model_sociatyboss.go +++ b/modules/sociaty/model_sociatyboss.go @@ -2,6 +2,8 @@ package sociaty import ( "context" + "errors" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" @@ -19,9 +21,9 @@ import ( ) var ( - BOSS_SPORTS = "sports" - BOSS_PLAYERS = "players" - SPORTS_HOUR = 3 * 24 //赛季周期 + BOSS_SPORTS = "sports" + BOSS_RANK = "rank" + SPORTS_HOUR = 10 //赛季周期 ) type ModelSociatyBoss struct { @@ -40,6 +42,9 @@ func (this *ModelSociatyBoss) Init(service core.IService, module core.IModule, c // 初始化赛季 func (s *ModelSociatyBoss) initSports() error { + if !s.moduleSociaty.IsCross() { + return nil + } ticker := time.NewTicker(time.Second) sports := &pb.DBSociatyBossSports{} if err := s.Get(BOSS_SPORTS, sports); err != nil { @@ -65,18 +70,19 @@ func (s *ModelSociatyBoss) initSports() error { s.moduleSociaty.Debugln("更新赛季结算时间:" + utils.FormatStr(sports.SettlementTime, "")) } if now.Unix() >= sports.EndTime { - // 更新下一赛季周期结束时间 sports.EndTime, sports.SettlementTime = s.sportsTime() + //归档前赛季数据 + s.reset() + // 更新下一赛季周期结束时间 update := map[string]interface{}{ "endTime": sports.EndTime, "settlementTime": sports.SettlementTime, + "uids": []string{}, } if err := s.Change(BOSS_SPORTS, update); err != nil { s.moduleSociaty.Errorln("Failed to change") return } - //归档前赛季数据、清理前赛季玩家 - s.reset() s.moduleSociaty.Debugln("更新赛季周期时间:" + utils.FormatStr(sports.EndTime, "")) } } @@ -96,11 +102,18 @@ func (s *ModelSociatyBoss) getSociatyBossSports() *pb.DBSociatyBossSports { return sports } +// 更新赛季数据 +func (s *ModelSociatyBoss) updateSociatyBossSports(data map[string]interface{}) { + if err := s.Change(BOSS_SPORTS, data); err != nil { + s.moduleSociaty.Error("更新赛季数据", log.Field{Key: "err", Value: err.Error()}) + } +} + // 赛季时间 func (s *ModelSociatyBoss) sportsTime() (t1, t2 int64) { now := configure.Now() - end1 := now.Add(time.Duration(SPORTS_HOUR) * time.Hour) //测试时单位分钟 else Hour - h, _ := time.ParseDuration("-1h") //测试时2m else -1h + end1 := now.Add(time.Duration(SPORTS_HOUR) * time.Minute) //测试时单位分钟 else Hour + h, _ := time.ParseDuration("-2m") //测试时-2m else -1h end2 := end1.Add(h) return end1.Unix(), end2.Unix() } @@ -195,35 +208,89 @@ func (s *ModelSociatyBoss) challengefinish(sociaty *pb.DBSociaty, uid string, re return nil } + sm := s.moduleSociaty.modelSociaty.getMemberInfo(sociaty, uid) + if sm == nil { + s.moduleSociaty.Error("没有该成员", log.Field{Key: "uid", Value: uid}, log.Field{Key: "sociatyId", Value: sociaty.Id}) + return comm.NewCustomError(pb.ErrorCode_SociatyNoMember) + } + //保存挑战记录 - if err := s.addChallengeRecord(uid, sociaty.Id, &pb.DBSociatyBossRecord{ - Uid: uid, - SociatyId: sociaty.Id, - Integral: s.transIntegral(report.Harm), - Duration: report.Costtime, - Rtime: configure.Now().Unix(), - }); err != nil { + record := &pb.ChallengeRecord{ + Teams: sm.Teams, + Integral: s.transIntegral(report.Harm), + Duration: report.Costtime, + Rtime: configure.Now().Unix(), + } + if err := s.updateChallengeRecord(uid, sociaty.Id, record); err != nil { return err } + + s.addSociatyBossUser(uid) return nil } -// 挑战记录 作为阵容推荐的依据; -func (s *ModelSociatyBoss) addChallengeRecord(uid, sociatyId string, record *pb.DBSociatyBossRecord) error { - if err := s.AddList(uid, sociatyId, record); err != nil { - return err +// 添加参赛玩家 +func (s *ModelSociatyBoss) addSociatyBossUser(uid string) { + sports := s.getSociatyBossSports() + if sports == nil { + return } - return s.addUserWithSports(uid, sociatyId) + if len(sports.Uids) == 0 { + sports.Uids = append(sports.Uids, uid) + } else { + if _, ok := utils.Findx(sports.Uids, uid); !ok { + sports.Uids = append(sports.Uids, uid) + } + } + + update := map[string]interface{}{ + "uids": sports.Uids, + } + if err := s.Change(BOSS_SPORTS, update); err != nil { + s.moduleSociaty.Error("添加参赛玩家", log.Field{Key: "err", Value: err.Error()}) + } } -// 记录参赛的玩家 -func (s *ModelSociatyBoss) addUserWithSports(uid, sociatyId string) error { - record := &pb.DBSociatyBossUser{ - Uid: uid, - SociatyId: sociatyId, +// 获取玩家赛季挑战记录 +func (s *ModelSociatyBoss) getChallengeRecord(uid string) *pb.DBSociatyBossRecord { + his := &pb.DBSociatyBossRecord{} + if err := s.Get(uid, his); err != nil { + return nil } - return s.moduleSociaty.modelSociatyBoss.AddList(BOSS_PLAYERS, uid, record) + if his.Uid == "" { + return nil + } + return his +} + +// 挑战记录 作为阵容推荐的依据; +func (s *ModelSociatyBoss) updateChallengeRecord(uid, sociatyId string, record *pb.ChallengeRecord) error { + his := &pb.DBSociatyBossRecord{} + if err := s.Get(uid, his); err != nil { + if err == rn.RedisNil || err == mongo.ErrNoDocuments { + if err := s.Add(uid, &pb.DBSociatyBossRecord{ + Uid: uid, + SociatyId: sociatyId, + Record: []*pb.ChallengeRecord{record}, + }); err != nil { + return comm.NewCustomError(pb.ErrorCode_DBError) + } + } else { + return comm.NewCustomError(pb.ErrorCode_DBError) + } + } + + //更新挑战记录 + his.Record = append(his.Record, record) + update := map[string]interface{}{ + "record": his.Record, + } + if err := s.Change(uid, update); err != nil { + return comm.NewCustomError(pb.ErrorCode_DBError) + } + + return nil } // 记入排行 @@ -233,7 +300,7 @@ func (s *ModelSociatyBoss) addRank(uid string, integral int64) error { m *redis.Z ) m = &redis.Z{Score: float64(integral), Member: uid} - if cmd := pipe.ZAdd(s.TableName, m); cmd != nil { + if cmd := pipe.ZAdd(fmt.Sprintf("%s:%s", s.TableName, BOSS_RANK), m); cmd != nil { _, err := cmd.Result() if err != nil { return err @@ -317,63 +384,69 @@ func (s *ModelSociatyBoss) rank(sociatyName string, rankType int32) (res []*pb.S } } - } return nil } // 公会BOSS重置数据 func (s *ModelSociatyBoss) reset() error { - s.moduleSociaty.Debugln("赛季重置") - - // 清理前赛季玩家 - var players []*pb.DBSociatyBossUser - if err := s.GetList(BOSS_PLAYERS, &players); err != nil { - return err - } - for _, v := range players { - if err := s.DelListlds(BOSS_PLAYERS, v.Uid); err != nil { - s.moduleSociaty.Error("清理玩家赛事记录", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "err", Value: err.Error()}) - } - - // 归档前赛季数据 - update := map[string]interface{}{ - "status": 1, //归档 - } - if err := s.ChangeList(v.Uid, v.SociatyId, update); err != nil { - s.moduleSociaty.Error("归档玩家赛事记录", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "err", Value: err.Error()}) - } + sports := s.getSociatyBossSports() + if sports == nil { + return errors.New("sociatyboss sports is nil") } + // 归档前赛季数据 + for _, uid := range sports.Uids { + var record []*pb.DBSociatyBossRecord + _ = s.GetList(uid, &record) + for _, v := range record { + update := map[string]interface{}{ + "status": 1, //归档 + } + if err := s.Change(BOSS_SPORTS, update); err != nil { + s.moduleSociaty.Error("归档玩家赛事记录", log.Field{Key: "uid", Value: v.Uid}, log.Field{Key: "err", Value: err.Error()}) + } + } + } + // 清理排行榜 + if err := s.Del(BOSS_RANK); err != nil { + s.moduleSociaty.Error("清理排行榜", log.Field{Key: "err", Value: err.Error()}) + } return nil } +// 是否参赛 +func (s *ModelSociatyBoss) IsSports(uid string) bool { + sports := s.getSociatyBossSports() + if sports == nil { + return false + } + for _, v := range sports.Uids { + if v == uid { + return true + } + } + return false +} + // 赛季结算 func (s *ModelSociatyBoss) settlement() error { - s.moduleSociaty.Debugln("赛季结算") start := time.Now() - var players []*pb.DBSociatyBossUser - - // 查询所有参赛玩家 - if err := s.GetList(BOSS_PLAYERS, &players); err != nil { - return err + sports := s.getSociatyBossSports() + if sports == nil { + return errors.New("sociatyboss sports is nil") } // 计算玩家的赛季积分 - for _, r := range players { - s.moduleSociaty.Debugln(r.Uid) - var record []*pb.DBSociatyBossRecord - if err := s.GetListObj(r.Uid, r.SociatyId, &record); err != nil { - s.moduleSociaty.Error("查询玩家赛事记录", log.Field{Key: "uid", Value: r.Uid}, log.Field{Key: "err", Value: err.Error()}) - continue - } + for _, uid := range sports.Uids { + cr := s.getChallengeRecord(uid) //排序-倒叙 - sort.SliceStable(record, func(i, j int) bool { - return record[i].Integral > record[j].Integral + sort.SliceStable(cr.Record, func(i, j int) bool { + return cr.Record[i].Integral > cr.Record[j].Integral }) var total int64 //当前赛季总积分 var highScore []int64 //暂存玩家积分 - for i, v := range record { + for i, v := range cr.Record { highScore = append(highScore, v.Integral) total += v.Integral if i > 2 { @@ -382,19 +455,21 @@ func (s *ModelSociatyBoss) settlement() error { } // 更新玩家赛季信息 + cr.Total = total + cr.Integrals = highScore update := map[string]interface{}{ "total": total, "integrals": highScore, } - if err := s.ChangeList(BOSS_PLAYERS, r.Uid, update); err != nil { - s.moduleSociaty.Error("更新玩家赛事信息", log.Field{Key: "uid", Value: r.Uid}, log.Field{Key: "err", Value: err.Error()}) + if err := s.Change(uid, update); err != nil { + s.moduleSociaty.Error("更新玩家赛事信息", log.Field{Key: "uid", Value: uid}, log.Field{Key: "err", Value: err.Error()}) continue } //将玩家积分加入排行榜 - s.addRank(r.Uid, total) + s.addRank(uid, total) - s.moduleSociaty.Debugln("耗时:", time.Since(start)) + s.moduleSociaty.Debug("结算:", log.Field{Key: "uid", Value: uid}, log.Field{Key: "耗时", Value: time.Since(start)}) } return nil diff --git a/modules/user/module.go b/modules/user/module.go index 66530d99e..1f7755947 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -223,19 +223,18 @@ func (this *User) SearchRmoteUser(nickname string) ([]*pb.DBUser, error) { //查询用户属性值 例如 金币 经验 func (this *User) QueryAttributeValue(uid string, attr string) (value int64) { var ( - user *pb.DBUser - err error + user *pb.DBUser + userEx *pb.DBUserExpand + err error ) - if this.IsCross() { - user, err = this.getRemoteUser(uid) - if err != nil { - return - } - } else { - user = this.modelUser.GetUser(uid) + + user = this.modelUser.GetUser(uid) + userEx, err = this.GetUserExpand(uid) + if err != nil { + return } - if user == nil { + if user == nil || userEx == nil { return } switch attr { @@ -251,6 +250,10 @@ func (this *User) QueryAttributeValue(uid string, attr string) (value int64) { return user.Diamond case comm.ResPs: return int64(user.Ps) + case comm.SociatyCoin: + return int64(userEx.Guildcoin) + case comm.ArenaCoin: + return int64(userEx.Arenacoin) } return } @@ -262,7 +265,6 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha log.Field{Key: "attr", Value: attr}, log.Field{Key: "add", Value: add}, ) - // code = pb.ErrorCode_ReqParameterError return } @@ -280,7 +282,7 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha return } - if user == nil { + if user == nil || userEx == nil { code = pb.ErrorCode_UserSessionNobeing return } diff --git a/pb/sociaty_db.pb.go b/pb/sociaty_db.pb.go index c76925927..dd640524b 100644 --- a/pb/sociaty_db.pb.go +++ b/pb/sociaty_db.pb.go @@ -888,8 +888,9 @@ type DBSociatyBossSports struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EndTime int64 `protobuf:"varint,1,opt,name=endTime,proto3" json:"endTime" bson:"endTime"` //公会BOSS赛季结束时间 - SettlementTime int64 `protobuf:"varint,2,opt,name=settlementTime,proto3" json:"settlementTime" bson:"settlementTime"` //赛季结算时间 + EndTime int64 `protobuf:"varint,1,opt,name=endTime,proto3" json:"endTime" bson:"endTime"` //公会BOSS赛季结束时间 + SettlementTime int64 `protobuf:"varint,2,opt,name=settlementTime,proto3" json:"settlementTime" bson:"settlementTime"` //赛季结算时间 + Uids []string `protobuf:"bytes,3,rep,name=uids,proto3" json:"uids" bson:"uids"` //参赛玩家 } func (x *DBSociatyBossSports) Reset() { @@ -938,20 +939,27 @@ func (x *DBSociatyBossSports) GetSettlementTime() int64 { return 0 } -// 赛季玩家信息 -type DBSociatyBossUser struct { +func (x *DBSociatyBossSports) GetUids() []string { + if x != nil { + return x.Uids + } + return nil +} + +// 玩家每次挑战的记录 +type ChallengeRecord struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` - SociatyId string `protobuf:"bytes,2,opt,name=sociatyId,proto3" json:"sociatyId" bson:"sociatyId"` - Total int64 `protobuf:"varint,3,opt,name=total,proto3" json:"total" bson:"total"` //赛季总积分 - Integrals []int64 `protobuf:"varint,4,rep,packed,name=integrals,proto3" json:"integrals" bson:"integrals"` //赛季中最高积分 + Teams map[int32]*ChallengeTeam `protobuf:"bytes,1,rep,name=teams,proto3" json:"teams" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3" bson:"teams"` //挑战队伍 + Integral int64 `protobuf:"varint,2,opt,name=integral,proto3" json:"integral" bson:"integral"` //公会BOSS挑战积分 + Duration int32 `protobuf:"varint,3,opt,name=duration,proto3" json:"duration" bson:"duration"` //战斗耗时 + Rtime int64 `protobuf:"varint,4,opt,name=rtime,proto3" json:"rtime" bson:"rtime"` //记录时间 } -func (x *DBSociatyBossUser) Reset() { - *x = DBSociatyBossUser{} +func (x *ChallengeRecord) Reset() { + *x = ChallengeRecord{} if protoimpl.UnsafeEnabled { mi := &file_sociaty_sociaty_db_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -959,13 +967,13 @@ func (x *DBSociatyBossUser) Reset() { } } -func (x *DBSociatyBossUser) String() string { +func (x *ChallengeRecord) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DBSociatyBossUser) ProtoMessage() {} +func (*ChallengeRecord) ProtoMessage() {} -func (x *DBSociatyBossUser) ProtoReflect() protoreflect.Message { +func (x *ChallengeRecord) ProtoReflect() protoreflect.Message { mi := &file_sociaty_sociaty_db_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -977,52 +985,51 @@ func (x *DBSociatyBossUser) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DBSociatyBossUser.ProtoReflect.Descriptor instead. -func (*DBSociatyBossUser) Descriptor() ([]byte, []int) { +// Deprecated: Use ChallengeRecord.ProtoReflect.Descriptor instead. +func (*ChallengeRecord) Descriptor() ([]byte, []int) { return file_sociaty_sociaty_db_proto_rawDescGZIP(), []int{12} } -func (x *DBSociatyBossUser) GetUid() string { +func (x *ChallengeRecord) GetTeams() map[int32]*ChallengeTeam { if x != nil { - return x.Uid - } - return "" -} - -func (x *DBSociatyBossUser) GetSociatyId() string { - if x != nil { - return x.SociatyId - } - return "" -} - -func (x *DBSociatyBossUser) GetTotal() int64 { - if x != nil { - return x.Total - } - return 0 -} - -func (x *DBSociatyBossUser) GetIntegrals() []int64 { - if x != nil { - return x.Integrals + return x.Teams } return nil } -// 成员公会BOSS历史记录 +func (x *ChallengeRecord) GetIntegral() int64 { + if x != nil { + return x.Integral + } + return 0 +} + +func (x *ChallengeRecord) GetDuration() int32 { + if x != nil { + return x.Duration + } + return 0 +} + +func (x *ChallengeRecord) GetRtime() int64 { + if x != nil { + return x.Rtime + } + return 0 +} + +// 成员公会BOSS挑战历史记录 type DBSociatyBossRecord struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SociatyId string `protobuf:"bytes,1,opt,name=sociatyId,proto3" json:"sociatyId" bson:"sociatyId"` //公会ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //玩家ID - Integral int64 `protobuf:"varint,3,opt,name=integral,proto3" json:"integral" bson:"integral"` //公会BOSS挑战积分 - Teams map[int32]*ChallengeTeam `protobuf:"bytes,4,rep,name=teams,proto3" json:"teams" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3" bson:"teams"` //挑战队伍 - Duration int32 `protobuf:"varint,5,opt,name=duration,proto3" json:"duration" bson:"duration"` //战斗耗时 - Rtime int64 `protobuf:"varint,6,opt,name=rtime,proto3" json:"rtime" bson:"rtime"` //记录时间 - Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status"` //@go_tags(`bson:"status"`)0当前赛季记录 1归档赛季记录 + Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid" bson:"uid"` //玩家ID + SociatyId string `protobuf:"bytes,2,opt,name=sociatyId,proto3" json:"sociatyId" bson:"sociatyId"` //公会ID + Record []*ChallengeRecord `protobuf:"bytes,4,rep,name=record,proto3" json:"record" bson:"record"` //赛季挑战记录 + Total int64 `protobuf:"varint,5,opt,name=total,proto3" json:"total" bson:"total"` //赛季总积分(前三积分和) + Integrals []int64 `protobuf:"varint,6,rep,packed,name=integrals,proto3" json:"integrals" bson:"integrals"` //赛季中最高积分 + Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status"` //@go_tags(`bson:"status"`)0当前赛季记录 1归档赛季记录 } func (x *DBSociatyBossRecord) Reset() { @@ -1057,13 +1064,6 @@ func (*DBSociatyBossRecord) Descriptor() ([]byte, []int) { return file_sociaty_sociaty_db_proto_rawDescGZIP(), []int{13} } -func (x *DBSociatyBossRecord) GetSociatyId() string { - if x != nil { - return x.SociatyId - } - return "" -} - func (x *DBSociatyBossRecord) GetUid() string { if x != nil { return x.Uid @@ -1071,32 +1071,32 @@ func (x *DBSociatyBossRecord) GetUid() string { return "" } -func (x *DBSociatyBossRecord) GetIntegral() int64 { +func (x *DBSociatyBossRecord) GetSociatyId() string { if x != nil { - return x.Integral + return x.SociatyId } - return 0 + return "" } -func (x *DBSociatyBossRecord) GetTeams() map[int32]*ChallengeTeam { +func (x *DBSociatyBossRecord) GetRecord() []*ChallengeRecord { if x != nil { - return x.Teams + return x.Record } return nil } -func (x *DBSociatyBossRecord) GetDuration() int32 { +func (x *DBSociatyBossRecord) GetTotal() int64 { if x != nil { - return x.Duration + return x.Total } return 0 } -func (x *DBSociatyBossRecord) GetRtime() int64 { +func (x *DBSociatyBossRecord) GetIntegrals() []int64 { if x != nil { - return x.Rtime + return x.Integrals } - return 0 + return nil } func (x *DBSociatyBossRecord) GetStatus() int32 { @@ -1209,45 +1209,46 @@ var file_sociaty_sociaty_db_proto_rawDesc = []byte{ 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x12, 0x2e, 0x0a, 0x09, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x66, 0x6f, - 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x57, 0x0a, 0x13, 0x44, 0x42, 0x53, 0x6f, 0x63, + 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x6b, 0x0a, 0x13, 0x44, 0x42, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x6f, 0x73, 0x73, 0x53, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, - 0x22, 0x77, 0x0a, 0x11, 0x44, 0x42, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x6f, 0x73, - 0x73, 0x55, 0x73, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x79, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x03, + 0x12, 0x12, 0x0a, 0x04, 0x75, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, + 0x75, 0x69, 0x64, 0x73, 0x22, 0xdc, 0x01, 0x0a, 0x0f, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, + 0x67, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x31, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, + 0x6e, 0x67, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x69, + 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, + 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x61, + 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, + 0x65, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x22, 0xbb, 0x01, 0x0a, 0x13, 0x44, 0x42, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, + 0x79, 0x42, 0x6f, 0x73, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, + 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x06, 0x72, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x43, 0x68, + 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x69, - 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x03, 0x52, 0x09, - 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x73, 0x22, 0xac, 0x02, 0x0a, 0x13, 0x44, 0x42, - 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x6f, 0x73, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, - 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, - 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, - 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x12, 0x35, 0x0a, - 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x44, - 0x42, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x6f, 0x73, 0x73, 0x52, 0x65, 0x63, 0x6f, - 0x72, 0x64, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x74, - 0x65, 0x61, 0x6d, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x14, 0x0a, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1a, 0x48, - 0x0a, 0x0a, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, - 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x50, 0x0a, 0x0a, 0x53, 0x6f, 0x63, 0x69, - 0x61, 0x74, 0x79, 0x4a, 0x6f, 0x62, 0x12, 0x09, 0x0a, 0x05, 0x4e, 0x4f, 0x4a, 0x4f, 0x42, 0x10, - 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x45, 0x4d, 0x42, 0x45, 0x52, 0x10, 0x01, 0x12, 0x09, 0x0a, - 0x05, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x10, 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x56, 0x49, 0x43, 0x45, - 0x50, 0x52, 0x45, 0x53, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x50, - 0x52, 0x45, 0x53, 0x49, 0x44, 0x45, 0x4e, 0x54, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x03, 0x52, 0x09, + 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x2a, 0x50, 0x0a, 0x0a, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4a, 0x6f, 0x62, 0x12, + 0x09, 0x0a, 0x05, 0x4e, 0x4f, 0x4a, 0x4f, 0x42, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4d, 0x45, + 0x4d, 0x42, 0x45, 0x52, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x44, 0x4d, 0x49, 0x4e, 0x10, + 0x02, 0x12, 0x11, 0x0a, 0x0d, 0x56, 0x49, 0x43, 0x45, 0x50, 0x52, 0x45, 0x53, 0x49, 0x44, 0x45, + 0x4e, 0x54, 0x10, 0x03, 0x12, 0x0d, 0x0a, 0x09, 0x50, 0x52, 0x45, 0x53, 0x49, 0x44, 0x45, 0x4e, + 0x54, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -1278,10 +1279,10 @@ var file_sociaty_sociaty_db_proto_goTypes = []interface{}{ (*ChallengeTeamInfo)(nil), // 10: ChallengeTeamInfo (*ChallengeTeam)(nil), // 11: ChallengeTeam (*DBSociatyBossSports)(nil), // 12: DBSociatyBossSports - (*DBSociatyBossUser)(nil), // 13: DBSociatyBossUser + (*ChallengeRecord)(nil), // 13: ChallengeRecord (*DBSociatyBossRecord)(nil), // 14: DBSociatyBossRecord nil, // 15: SociatyMember.TeamsEntry - nil, // 16: DBSociatyBossRecord.TeamsEntry + nil, // 16: ChallengeRecord.TeamsEntry (*BattleFormation)(nil), // 17: BattleFormation } var file_sociaty_sociaty_db_proto_depIdxs = []int32{ @@ -1293,14 +1294,15 @@ var file_sociaty_sociaty_db_proto_depIdxs = []int32{ 7, // 5: DBSociatyTask.taskList:type_name -> SociatyTask 8, // 6: DBSociatyTask.activityList:type_name -> SociatyActivity 17, // 7: ChallengeTeam.formation:type_name -> BattleFormation - 16, // 8: DBSociatyBossRecord.teams:type_name -> DBSociatyBossRecord.TeamsEntry - 11, // 9: SociatyMember.TeamsEntry.value:type_name -> ChallengeTeam - 11, // 10: DBSociatyBossRecord.TeamsEntry.value:type_name -> ChallengeTeam - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 16, // 8: ChallengeRecord.teams:type_name -> ChallengeRecord.TeamsEntry + 13, // 9: DBSociatyBossRecord.record:type_name -> ChallengeRecord + 11, // 10: SociatyMember.TeamsEntry.value:type_name -> ChallengeTeam + 11, // 11: ChallengeRecord.TeamsEntry.value:type_name -> ChallengeTeam + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_sociaty_sociaty_db_proto_init() } @@ -1455,7 +1457,7 @@ func file_sociaty_sociaty_db_proto_init() { } } file_sociaty_sociaty_db_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DBSociatyBossUser); i { + switch v := v.(*ChallengeRecord); i { case 0: return &v.state case 1: From 7113d791f68e056f4fba9999faa23551bd8b99e5 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Sat, 14 Jan 2023 18:46:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=94=B9=E8=AE=A1=E6=97=B6=E5=99=A8?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/sociaty/model_sociatyboss.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/modules/sociaty/model_sociatyboss.go b/modules/sociaty/model_sociatyboss.go index e562f1104..6501b2c0e 100644 --- a/modules/sociaty/model_sociatyboss.go +++ b/modules/sociaty/model_sociatyboss.go @@ -23,7 +23,7 @@ import ( var ( BOSS_SPORTS = "sports" BOSS_RANK = "rank" - SPORTS_HOUR = 10 //赛季周期 + SPORTS_HOUR = 3 * 24 //赛季周期 ) type ModelSociatyBoss struct { @@ -112,8 +112,8 @@ func (s *ModelSociatyBoss) updateSociatyBossSports(data map[string]interface{}) // 赛季时间 func (s *ModelSociatyBoss) sportsTime() (t1, t2 int64) { now := configure.Now() - end1 := now.Add(time.Duration(SPORTS_HOUR) * time.Minute) //测试时单位分钟 else Hour - h, _ := time.ParseDuration("-2m") //测试时-2m else -1h + end1 := now.Add(time.Duration(SPORTS_HOUR) * time.Hour) //测试时单位分钟 else Hour + h, _ := time.ParseDuration("-1h") //测试时-2m else -1h end2 := end1.Add(h) return end1.Unix(), end2.Unix() } @@ -431,7 +431,6 @@ func (s *ModelSociatyBoss) IsSports(uid string) bool { // 赛季结算 func (s *ModelSociatyBoss) settlement() error { - start := time.Now() sports := s.getSociatyBossSports() if sports == nil { return errors.New("sociatyboss sports is nil") @@ -469,7 +468,7 @@ func (s *ModelSociatyBoss) settlement() error { //将玩家积分加入排行榜 s.addRank(uid, total) - s.moduleSociaty.Debug("结算:", log.Field{Key: "uid", Value: uid}, log.Field{Key: "耗时", Value: time.Since(start)}) + s.moduleSociaty.Debug("结算:", log.Field{Key: "uid", Value: uid}) } return nil