定时器 每天0点 校验是否 有结算任务
This commit is contained in:
parent
7424b5c57b
commit
f7dbcd42bc
@ -368,7 +368,7 @@ func (this *Caravan) CheckOverweight(data *pb.DBCaravan) (b bool) {
|
|||||||
var weight int32
|
var weight int32
|
||||||
|
|
||||||
for k, v := range data.Items {
|
for k, v := range data.Items {
|
||||||
if d, err := this.configure.GetCaravanGoods(k); err != nil {
|
if d, err := this.configure.GetCaravanGoods(k); err == nil {
|
||||||
weight += d.Weight * v.Count
|
weight += d.Weight * v.Count
|
||||||
if weight > data.Baglimit {
|
if weight > data.Baglimit {
|
||||||
return true
|
return true
|
||||||
@ -376,7 +376,7 @@ func (this *Caravan) CheckOverweight(data *pb.DBCaravan) (b bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获得利润判断是否能提升商队等级
|
// 获得利润判断是否能提升商队等级
|
||||||
|
@ -2,7 +2,6 @@ package timer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/base"
|
"go_dreamfactory/lego/base"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
@ -15,7 +14,7 @@ import (
|
|||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
"go_dreamfactory/sys/db"
|
"go_dreamfactory/sys/db"
|
||||||
"time"
|
"go_dreamfactory/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 此组件废弃
|
// 此组件废弃
|
||||||
@ -77,20 +76,19 @@ func (this *CaravanRank) Start() (err error) {
|
|||||||
if configure.Now().Unix() < opentime { // 开服时间是未来可能存在问题
|
if configure.Now().Unix() < opentime { // 开服时间是未来可能存在问题
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//获取时分秒
|
_, end := utils.WeekIntervalTime(0)
|
||||||
currentTime := time.Unix(opentime, 0)
|
this.module.Errorf("%v", end)
|
||||||
m := currentTime.Minute()
|
|
||||||
s := currentTime.Second()
|
cron.AddFunc("0,0,0,*,*,*", this.TimerSeason)
|
||||||
h := currentTime.Hour()
|
this.module.Debugf("cron start: %s", configure.Now().Unix())
|
||||||
day := this.GetGlobalConf().BusinessRewardday
|
|
||||||
cronStr := fmt.Sprintf("%d %d %d */%d * ?", m, s, h, day) //
|
|
||||||
this.module.Debugf("cron start: %s", cronStr)
|
|
||||||
cron.AddFunc(cronStr, this.TimerSeason)
|
|
||||||
//this.TimerSeason()
|
//this.TimerSeason()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *CaravanRank) TimerSeason() {
|
func (this *CaravanRank) TimerSeason() {
|
||||||
|
_, end := utils.WeekIntervalTime(0)
|
||||||
|
this.module.Debugf("TimerSeason end: %d,cur time:%d", end, configure.Now().Unix())
|
||||||
|
if configure.Now().Unix()-end < 5 {
|
||||||
this.module.Debugf("TimerSeason start: %d", configure.Now().Unix())
|
this.module.Debugf("TimerSeason start: %d", configure.Now().Unix())
|
||||||
if err := this.service.RpcCall(
|
if err := this.service.RpcCall(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
@ -102,3 +100,5 @@ func (this *CaravanRank) TimerSeason() {
|
|||||||
this.module.Errorln(err)
|
this.module.Errorln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -164,3 +164,19 @@ func DiffDays(t1, t2 int64) int {
|
|||||||
}
|
}
|
||||||
return diffDays
|
return diffDays
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WeekIntervalTime(week int) (startTime, endTime int64) {
|
||||||
|
now := time.Now()
|
||||||
|
offset := int(time.Monday - now.Weekday())
|
||||||
|
//周日做特殊判断 因为time.Monday = 0
|
||||||
|
if offset > 0 {
|
||||||
|
offset = -6
|
||||||
|
}
|
||||||
|
|
||||||
|
year, month, day := now.Date()
|
||||||
|
thisWeek := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
|
||||||
|
startTime = thisWeek.AddDate(0, 0, offset+7*week).Unix()
|
||||||
|
endTime = thisWeek.AddDate(0, 0, offset+6+7*week).Unix()
|
||||||
|
|
||||||
|
return startTime, endTime
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user