update sign

This commit is contained in:
wh_zcy 2022-12-26 09:52:49 +08:00
parent 79887121e6
commit a1de2bab58
4 changed files with 14 additions and 52 deletions

View File

@ -54,6 +54,8 @@ func (this *apiComp) Mine(session comm.IUserSession, req *pb.SociatyMineReq) (co
if sociatyTask.SociatyId != "" { if sociatyTask.SociatyId != "" {
// 今日首次进入公会 // 今日首次进入公会
if utils.IsFirstTody(sociatyTask.LastUpdateTime) { if utils.IsFirstTody(sociatyTask.LastUpdateTime) {
//更新昨日签到数
this.module.modelSociaty.updateSign(sociaty)
// 删除任务 // 删除任务
if err := this.module.modelSociatyTask.deleTask(sociaty.Id, uid); err == nil { if err := this.module.modelSociatyTask.deleTask(sociaty.Id, uid); err == nil {
// 初始新的公会任务 // 初始新的公会任务

View File

@ -352,7 +352,7 @@ func (this *ModelSociaty) updateSociaty(sociatyId string, update map[string]inte
// 退出公会 // 退出公会
func (this *ModelSociaty) quit(uid string, sociaty *pb.DBSociaty) error { func (this *ModelSociaty) quit(uid string, sociaty *pb.DBSociaty) error {
for i:=0;i<len(sociaty.Members);i++{ for i := 0; i < len(sociaty.Members); i++ {
if sociaty.Members[i].Uid == uid { if sociaty.Members[i].Uid == uid {
sociaty.Members = append(sociaty.Members[:i], sociaty.Members[i+1:]...) sociaty.Members = append(sociaty.Members[:i], sociaty.Members[i+1:]...)
i-- i--
@ -386,7 +386,7 @@ func (this *ModelSociaty) dismiss(sociaty *pb.DBSociaty) error {
//删除请求记录 //删除请求记录
func (this *ModelSociaty) delFromApplyRecord(uid string, sociaty *pb.DBSociaty) error { func (this *ModelSociaty) delFromApplyRecord(uid string, sociaty *pb.DBSociaty) error {
for i:=0;i<len(sociaty.ApplyRecord);i++{ for i := 0; i < len(sociaty.ApplyRecord); i++ {
if sociaty.ApplyRecord[i].Uid == uid { if sociaty.ApplyRecord[i].Uid == uid {
sociaty.ApplyRecord = append(sociaty.ApplyRecord[:i], sociaty.ApplyRecord[i+1:]...) sociaty.ApplyRecord = append(sociaty.ApplyRecord[:i], sociaty.ApplyRecord[i+1:]...)
i-- i--
@ -513,7 +513,7 @@ func (this *ModelSociaty) assign(srcId, targetId string, sociaty *pb.DBSociaty)
// targetId 踢出目标 // targetId 踢出目标
// 不允许踢出会长 // 不允许踢出会长
func (this *ModelSociaty) discharge(targetId string, sociaty *pb.DBSociaty) error { func (this *ModelSociaty) discharge(targetId string, sociaty *pb.DBSociaty) error {
for i:=0;i<len(sociaty.Members);i++ { for i := 0; i < len(sociaty.Members); i++ {
if sociaty.Members[i].Uid == targetId { if sociaty.Members[i].Uid == targetId {
if sociaty.Members[i].Job == pb.SociatyJob_PRESIDENT { if sociaty.Members[i].Job == pb.SociatyJob_PRESIDENT {
return comm.NewCustomError(pb.ErrorCode_SociatyMasterNoDiss) return comm.NewCustomError(pb.ErrorCode_SociatyMasterNoDiss)
@ -950,3 +950,12 @@ func (this *ModelSociaty) memberClear(sociaty *pb.DBSociaty) error {
// } // }
return nil return nil
} }
func (s *ModelSociaty) updateSign(sociaty *pb.DBSociaty) error {
lastSignCount := len(sociaty.SignIds)
update := map[string]interface{}{
"lastSignCount": lastSignCount,
"signIds": []string{},
}
return s.updateSociaty(sociaty.Id, update)
}

View File

@ -27,7 +27,6 @@ type Timer struct {
season *SeasonPagoda season *SeasonPagoda
forum *ForumComp forum *ForumComp
arena *ArenaComp arena *ArenaComp
sociaty *SociatyTimer
} }
//模块名 //模块名
@ -59,7 +58,6 @@ func (this *Timer) OnInstallComp() {
this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp) this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp)
this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda) this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda)
this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp) this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp)
this.sociaty = this.RegisterComp(new(SociatyTimer)).(*SociatyTimer)
} }
//日志 //日志

View File

@ -1,47 +0,0 @@
package timer
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/cron"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson"
)
type SociatyTimer struct {
modules.MCompModel
service core.IService
}
//组件初始化接口
func (this *SociatyTimer) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.TableName = comm.TableSociaty
this.MCompModel.Init(service, module, comp, options)
this.service = service
return
}
func (this *SociatyTimer) Start() (err error) {
err = this.MCompModel.Start()
cron.AddFunc("0 0 12 * * ?", this.updateSign)
return
}
// updateSign
func (this *SociatyTimer) updateSign() {
cur, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{})
if err != nil {
return
}
for cur.Next(context.TODO()) {
sociaty := &pb.DBSociaty{}
if err = cur.Decode(sociaty); err == nil {
sociaty.LastSignCount = int32(len(sociaty.SignIds))
sociaty.SignIds = make([]string, 0)
_, err = this.DB.UpdateOne(core.SqlTable(this.TableName), bson.M{}, sociaty)
}
}
}