From 8ce713c7a98171cc8095b834e92403eccd646f9c Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 1 Nov 2022 16:55:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E4=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/ui/views/sociaty_mine.go | 32 +-------------- cmd/v2/ui/views/sociaty_tasklist.go | 51 ++++++++++++++++++++---- modules/sociaty/api_cross_agree.go | 1 + modules/sociaty/api_cross_sign.go | 5 +++ modules/sociaty/model_sociaty.go | 62 +++++++++++++++++++++++++++-- 5 files changed, 109 insertions(+), 42 deletions(-) diff --git a/cmd/v2/ui/views/sociaty_mine.go b/cmd/v2/ui/views/sociaty_mine.go index c409b4ca6..a9c90dd5a 100644 --- a/cmd/v2/ui/views/sociaty_mine.go +++ b/cmd/v2/ui/views/sociaty_mine.go @@ -131,9 +131,6 @@ func (this *SociatyMineView) CreateView(t *model.TestCase) fyne.CanvasObject { //申请列表 applyListBtn := widget.NewButton("申请审批", this.showSociatyApplyListWin) - // 任务列表 - taskListBtn := widget.NewButton("任务列表", this.showTaskListWin) - // 日志 logBtn := widget.NewButton("日志", this.showLogWin) @@ -156,7 +153,7 @@ func (this *SociatyMineView) CreateView(t *model.TestCase) fyne.CanvasObject { } else { btns.Add(quitBtn) } - btns.Add(taskListBtn) + btns.Add(logBtn) this.sociatyRender(item) this.form.Refresh() @@ -540,33 +537,6 @@ func (this *SociatyMineView) showSignWin() { dconf.Show() } -// 任务列表 -func (this *SociatyMineView) showTaskListWin() { - refreshBtn := widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), func() { - this.memberList.Reset() - this.taskList() - }) - - btns := container.NewHBox(refreshBtn) - - c := container.NewBorder(btns, nil, nil, nil, this.memberList.ItemList) - dconf := dialog.NewCustom("任务", "关闭", c, this.w) - dconf.Resize(fyne.NewSize(800, 500)) - dconf.Show() -} - -func (this *SociatyMineView) taskList() { - 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.SociatySubTypeMembers) { - return - } - }, - }) -} - // 日志列表 func (this *SociatyMineView) showLogWin() { this.logList = common.NewItemList() diff --git a/cmd/v2/ui/views/sociaty_tasklist.go b/cmd/v2/ui/views/sociaty_tasklist.go index 9105c2d80..07276959b 100644 --- a/cmd/v2/ui/views/sociaty_tasklist.go +++ b/cmd/v2/ui/views/sociaty_tasklist.go @@ -21,14 +21,14 @@ import ( type SociatyTasklistView struct { BaseformView - taskList func() - itemList *common.ItemList - flag bool + taskList func() + itemList *common.ItemList + flag bool + activityItemList *common.ItemList } func (this *SociatyTasklistView) CreateView(t *model.TestCase) fyne.CanvasObject { this.itemList = common.NewItemList() - this.itemList.ItemList = this.itemList.CreateList() this.taskList = func() { @@ -48,7 +48,7 @@ func (this *SociatyTasklistView) CreateView(t *model.TestCase) fyne.CanvasObject }) // 领取 - receiveBtn := widget.NewButton("", func() { + receiveBtn := widget.NewButton("领取", func() { selId := this.itemList.SelItemId if selId == "" { common.ShowTip("请选择项目") @@ -65,17 +65,52 @@ func (this *SociatyTasklistView) CreateView(t *model.TestCase) fyne.CanvasObject }) //活跃度领取 - activityBtn := widget.NewButton("", nil) - activityVal := canvas.NewText("", nil) + activityBtn := widget.NewButton("活跃度领取", func() { + if err := service.GetPttService().SendToClient( + string(comm.ModuleSociaty), + sociaty.SociatySubTypeActivityReceive, + &pb.SociatyActivityReceiveReq{ + Id: 1, + }); err != nil { + logrus.Error(err) + } + }) + + // 活跃度列表 + this.activityItemList = common.NewItemList() + this.activityItemList.ItemList = this.activityItemList.CreateList() + this.activityList() + + activityVal := canvas.NewText("0", nil) buttonBar := container.NewHBox(refreshBtn, receiveBtn) c1 := container.NewBorder(buttonBar, nil, nil, nil, this.itemList.ItemList) - c2 := container.NewBorder(nil, nil, nil, nil, container.NewVBox(container.NewCenter(activityVal), activityBtn)) + c2 := container.NewBorder(container.NewVBox(container.NewCenter(activityVal), activityBtn), nil, nil, nil, this.activityItemList.ItemList) cols := container.NewGridWithColumns(2, c1, c2) this.dataListener() return cols } +func (this *SociatyTasklistView) activityList() { + n := map[int32]int32{ + 1: 1000, + 2: 2000, + 3: 3000, + 4: 4000, + 5: 5000, + } + + var nn int + for k, v := range n { + nn++ + item := common.Item{ + Id: cast.ToString(k), + Text: fmt.Sprintf("%d - Id:%v 活跃度:%d ", nn, k, v), + } + this.activityItemList.AddItem(item) + } +} + func (this *SociatyTasklistView) dataListener() { if this.flag { return diff --git a/modules/sociaty/api_cross_agree.go b/modules/sociaty/api_cross_agree.go index 656cb56c0..ad2cda954 100644 --- a/modules/sociaty/api_cross_agree.go +++ b/modules/sociaty/api_cross_agree.go @@ -35,6 +35,7 @@ func (this *apiComp) Agree(session comm.IUserSession, req *pb.SociatyAgreeReq) ( code = pb.ErrorCode_SociatyNoRight return } + if err := this.module.modelSociaty.agree(req.Uid, sociaty); err != nil { code = pb.ErrorCode_SociatyAgree this.module.Errorf("申请同意失败:%v", err) diff --git a/modules/sociaty/api_cross_sign.go b/modules/sociaty/api_cross_sign.go index ff04bb36a..aeeedcc5e 100644 --- a/modules/sociaty/api_cross_sign.go +++ b/modules/sociaty/api_cross_sign.go @@ -25,6 +25,7 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co return } + // 判断是否已签到 if this.module.modelSociaty.IsSign(uid, sociaty) { code = pb.ErrorCode_SociatySigned return @@ -61,6 +62,10 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.SociatySignReq) (co if err := this.module.modelSociaty.updateSociatyExp(cfg.Exp.N, sociaty); err != nil { this.module.Errorf("公会经验更新失败:%v", err) } + // 更新等级 + if err := this.module.modelSociaty.changeLv(sociaty); err != nil { + this.module.Errorf("公会等级更新失败:%v", err) + } } } diff --git a/modules/sociaty/model_sociaty.go b/modules/sociaty/model_sociaty.go index d0dbed355..4b1ecfd58 100644 --- a/modules/sociaty/model_sociaty.go +++ b/modules/sociaty/model_sociaty.go @@ -311,7 +311,9 @@ func (this *ModelSociaty) delFromApplyRecord(uid string, sociaty *pb.DBSociaty) //添加成员 func (this *ModelSociaty) addMember(uid string, sociaty *pb.DBSociaty) error { - defer this.moduleSociaty.modelSociatyLog.addLog(Log_Add, sociaty.Id, uid) + if int32(len(sociaty.Members)) >= this.getMemberMax(sociaty) { + return fmt.Errorf("member max") + } sociaty.Members = append(sociaty.Members, &pb.SociatyMember{ Uid: uid, Job: pb.SociatyJob_MEMBER, @@ -328,8 +330,12 @@ func (this *ModelSociaty) addMember(uid string, sociaty *pb.DBSociaty) error { updateEx := map[string]interface{}{ "sociatyId": sociaty.Id, } + if err := this.moduleSociaty.ModuleUser.ChangeRemoteUserExpand(uid, updateEx); err != nil { + return err + } - return this.moduleSociaty.ModuleUser.ChangeRemoteUserExpand(uid, updateEx) + this.moduleSociaty.modelSociatyLog.addLog(Log_Add, sociaty.Id, uid) + return nil } // 成员列表 @@ -631,14 +637,64 @@ func (this *ModelSociaty) rank() (rank []*pb.DBSociatyRank) { rank = this.sort(rank) - rank = append(rank[:0], rank[19:]...) + if len(rank) > 20 { + rank = append(rank[:0], rank[19:]...) + } return } +// CD func (this *ModelSociaty) isInCDHour(userCdTime int64) bool { if userCdTime == 0 { return false } return time.Now().Unix() < userCdTime } + +// 等级更新 +func (this *ModelSociaty) changeLv(sociaty *pb.DBSociaty) error { + ggl, err := this.moduleSociaty.configure.getSociatyLvCfg() + if err != nil { + return err + } + + if ggl == nil { + return errors.New("sociatyLvConf is nil") + } + + curLv := sociaty.Lv + update := map[string]interface{}{} + + lv := curLv + 1 + if conf, ok := ggl.GetDataMap()[lv]; ok { + if sociaty.Exp > conf.Exp { + update["lv"] = lv + } + } + + if len(update) > 0 { + if err = this.updateSociaty(sociaty.Id, update); err != nil { + return err + } + } + + return nil +} + +// 获取可容纳的最大上限 +func (this *ModelSociaty) getMemberMax(sociaty *pb.DBSociaty) int32 { + ggl, err := this.moduleSociaty.configure.getSociatyLvCfg() + if err != nil { + return 0 + } + + if ggl == nil { + return 0 + } + + if conf, ok := ggl.GetDataMap()[sociaty.Lv]; ok { + return conf.MemberMax + } + return 0 +}