gm 跳过手动激活类型
This commit is contained in:
parent
2c000b99bd
commit
4dd7f0f4ee
@ -171,8 +171,11 @@ func (this *ModuleSys) GMOpenAllCondition(uid string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range opencfg.GetDataList() {
|
for _, v := range opencfg.GetDataList() {
|
||||||
|
if v.ActivateType != 1 { // 跳过手动激活类型
|
||||||
list.Cond[v.Id] = 2
|
list.Cond[v.Id] = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
this.modelSys.ChangeOpenCondData(uid, map[string]interface{}{
|
this.modelSys.ChangeOpenCondData(uid, map[string]interface{}{
|
||||||
"cond": list.Cond,
|
"cond": list.Cond,
|
||||||
})
|
})
|
||||||
|
@ -53,7 +53,7 @@ func (this *Activity) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
timer := time.NewTicker(time.Second * 1)
|
timer := time.NewTicker(time.Second * 1)
|
||||||
this.LoadActivityData("")
|
this.LoadActivityData()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
locp:
|
locp:
|
||||||
@ -70,43 +70,7 @@ func (this *Activity) Start() (err error) {
|
|||||||
//cron.AddFunc("0 0 0 ? * MON", this.TimerSeason)
|
//cron.AddFunc("0 0 0 ? * MON", this.TimerSeason)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
func (this *Activity) ReLoadActivityData(id string) {
|
||||||
func (this *Activity) LoadActivityData(id string) {
|
|
||||||
if id == "" { // 查所有的
|
|
||||||
if c, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{}); err == nil {
|
|
||||||
var (
|
|
||||||
szEnd []string // 活动结束
|
|
||||||
szStart []string // 有活动开启
|
|
||||||
)
|
|
||||||
this.hlock.Lock()
|
|
||||||
this.curActivity = make(map[pb.HdType]*pb.DBHuodong)
|
|
||||||
this.delActivity = make(map[pb.HdType]*pb.DBHuodong)
|
|
||||||
this.futureActivity = make(map[pb.HdType]*pb.DBHuodong)
|
|
||||||
defer this.hlock.Unlock()
|
|
||||||
for c.Next(context.Background()) {
|
|
||||||
hd := &pb.DBHuodong{}
|
|
||||||
if err = c.Decode(hd); err != nil {
|
|
||||||
this.module.Errorf("err:%v", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if hd.Etime <= configure.Now().Unix() {
|
|
||||||
this.delActivity[hd.Itype] = hd
|
|
||||||
szEnd = append(szEnd, hd.Id)
|
|
||||||
} else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() {
|
|
||||||
this.curActivity[hd.Itype] = hd
|
|
||||||
szStart = append(szStart, hd.Id)
|
|
||||||
} else {
|
|
||||||
this.futureActivity[hd.Itype] = hd
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(szEnd) > 0 {
|
|
||||||
this.NotifyActivityOver(szEnd)
|
|
||||||
}
|
|
||||||
if len(szStart) > 0 {
|
|
||||||
this.NotifyActivityStart(szStart)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var hd *pb.DBHuodong
|
var hd *pb.DBHuodong
|
||||||
if err := this.DB.FindOne(core.SqlTable(this.TableName), bson.M{"_id": id}).Decode(&hd); err != nil {
|
if err := this.DB.FindOne(core.SqlTable(this.TableName), bson.M{"_id": id}).Decode(&hd); err != nil {
|
||||||
return
|
return
|
||||||
@ -135,7 +99,34 @@ func (this *Activity) LoadActivityData(id string) {
|
|||||||
this.futureActivity[hd.Itype] = hd
|
this.futureActivity[hd.Itype] = hd
|
||||||
}
|
}
|
||||||
defer this.hlock.Unlock()
|
defer this.hlock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Activity) LoadActivityData() {
|
||||||
|
|
||||||
|
if c, err := this.DB.Find(core.SqlTable(this.TableName), bson.M{}); err == nil {
|
||||||
|
|
||||||
|
this.hlock.Lock()
|
||||||
|
this.curActivity = make(map[pb.HdType]*pb.DBHuodong)
|
||||||
|
this.delActivity = make(map[pb.HdType]*pb.DBHuodong)
|
||||||
|
this.futureActivity = make(map[pb.HdType]*pb.DBHuodong)
|
||||||
|
defer this.hlock.Unlock()
|
||||||
|
for c.Next(context.Background()) {
|
||||||
|
hd := &pb.DBHuodong{}
|
||||||
|
if err = c.Decode(hd); err != nil {
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
if hd.Etime <= configure.Now().Unix() {
|
||||||
|
this.delActivity[hd.Itype] = hd
|
||||||
|
} else if hd.Etime > configure.Now().Unix() && hd.Stime < configure.Now().Unix() {
|
||||||
|
this.curActivity[hd.Itype] = hd
|
||||||
|
} else {
|
||||||
|
this.futureActivity[hd.Itype] = hd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Activity) NotifyActivityOver(szEnd []string) {
|
func (this *Activity) NotifyActivityOver(szEnd []string) {
|
||||||
@ -167,6 +158,7 @@ func (this *Activity) NotifyActivityStart(szStart []string) {
|
|||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Activity) CheckActivityData() {
|
func (this *Activity) CheckActivityData() {
|
||||||
var (
|
var (
|
||||||
szEnd []string // 活动结束
|
szEnd []string // 活动结束
|
||||||
|
@ -101,7 +101,7 @@ func (this *Timer) getDBModelByUid(uid, tableName string) (model *db.DBModel, er
|
|||||||
|
|
||||||
// 重新加载活动数据
|
// 重新加载活动数据
|
||||||
func (this *Timer) ReloadActivityData(id string) {
|
func (this *Timer) ReloadActivityData(id string) {
|
||||||
this.activity.LoadActivityData(id)
|
this.activity.ReLoadActivityData(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 日志
|
// 日志
|
||||||
|
Loading…
Reference in New Issue
Block a user