group_power_exp.go 1020 Bytes
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
package group_cron

import (
	"git.hilo.cn/hilo-common/domain"
	"github.com/robfig/cron"
	"hilo-group/domain/event/group_power_ev"
	"hilo-group/domain/model/groupPower_m"
)

// 清理家族经验和等级
func GroupPowerExpClear() {
	c := cron.New()
	// 每月1号0:00经验值清零
	spec := "0 0 0 1 * ?"
	_ = c.AddFunc(spec, func() {
		var model = domain.CreateModelNil()
		if err := groupPower_m.ClearGroupPowerExp(model); err != nil {
			model.Log.Errorf("ClearGroupPowerExp fail:%v", err)
		}
	})

	// 每分钟清理过期家族等级
	spec = "0 * * * * ?"
	_ = c.AddFunc(spec, func() {
		var model = domain.CreateModelNil()
		if err := groupPower_m.ClearGroupPowerGrade(model); err != nil {
			model.Log.Errorf("ClearGroupPowerGrade fail:%v", err)
		}
	})
	// 每月20号发家族即将过期通知
	spec = "0 0 0 20 * ?"
	_ = c.AddFunc(spec, func() {
		var model = domain.CreateModelNil()
		_ = group_power_ev.PublishGroupPowerExpireNotice(model, &group_power_ev.GroupPowerExpireNoticeEvent{})
	})
	c.Start()
}