update sign
This commit is contained in:
parent
79887121e6
commit
a1de2bab58
@ -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 {
|
||||||
// 初始新的公会任务
|
// 初始新的公会任务
|
||||||
|
@ -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)
|
||||||
|
}
|
||||||
|
@ -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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//日志
|
//日志
|
||||||
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user