商队结算

This commit is contained in:
meixiongfeng 2023-05-23 19:11:50 +08:00
parent 92f2aaeea2
commit c5e09f3281

View File

@ -2,10 +2,12 @@ package timer
import (
"context"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/cron"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/timewheel"
"go_dreamfactory/modules"
@ -68,26 +70,22 @@ func (this *CaravanRank) GetGlobalConf() *cfg.GameGlobalData {
func (this *CaravanRank) Start() (err error) {
err = this.MCompModel.Start()
opentime := this.service.GetOpentime().Unix()
//cron.AddFunc("30 10 1 * * ?", this.TimerSeason)
//seasonTime := this.GetGlobalConf().BusinessRewardday * 24 * 3600
if configure.Now().Unix() < opentime { // 开服时间是未来可能存在问题
return
}
// subTime := int32(configure.Now().Unix() - opentime)
// if subTime < seasonTime {
// this.cTimerObj = timewheel.Add(time.Second*time.Duration(subTime), this.TimerSeason, nil)
// } else {
// s := configure.Now().Unix() - (configure.Now().Unix()-opentime)%int64(subTime) + int64(seasonTime)
// this.cTimerObj = timewheel.Add(time.Second*time.Duration(s), this.TimerSeason, nil)
// }
//获取时分秒
currentTime := time.Unix(opentime, 0)
m := currentTime.Minute()
s := currentTime.Second()
day := this.GetGlobalConf().BusinessRewardday
cronStr := fmt.Sprintf("%d %d */%d * * ?", m, s, day) // 每天的
cron.AddFunc(cronStr, this.TimerSeason)
return
}
func (this *CaravanRank) TimerSeason(task *timewheel.Task, args ...interface{}) {
this.module.Debugf("==%d", time.Now().Unix())
func (this *CaravanRank) TimerSeason() {
if _, err := this.service.RpcGo(context.Background(),
comm.Service_Worker,
string(comm.Rpc_ModuleCaravanSettlement),
@ -96,9 +94,5 @@ func (this *CaravanRank) TimerSeason(task *timewheel.Task, args ...interface{})
); err != nil {
this.module.Errorln(err)
}
if this.cTimerObj != nil {
timewheel.Remove(this.cTimerObj)
} // 重新开启一个时间轮
this.cTimerObj = timewheel.Add(time.Second*time.Duration(this.GetGlobalConf().BusinessRewardday), this.TimerSeason, nil)
}