作者 tangxvhui

bug 修复

... ... @@ -15,7 +15,8 @@ func init() {
}
return true
}),
beego.NSGet("/create_rank_peroid", func(ctx *context.Context) {
beego.NSGet("/create_rank_peroid",
func(ctx *context.Context) {
crontab.AutoCreateRankPeriod()
}),
)
... ...
... ... @@ -22,7 +22,7 @@ type RankTypeAutoPeriod struct {
//
type RankPeriodEndTime struct {
RankTypeId int64 `orm:"column(rank_type_id)"`
EndTime int64 `orm:"column(end_time)"`
EndTime time.Time `orm:"column(end_time)"`
}
func AutoCreateRankPeriod() error {
... ... @@ -36,7 +36,7 @@ func AutoCreateRankPeriod() error {
AND NOT EXISTS(
SELECT 1 FROM rank_period AS c WHERE a.id=c.rank_type_id AND c.status<2
)
AND a.create_at>?
AND UNIX_TIMESTAMP(a.create_at)>?
LIMIT 1000`
//获取自动创建赛季时需要的开始时间
... ... @@ -75,7 +75,7 @@ LOOP0:
var (
rankPeriodList []RankPeriodEndTime
)
rankPeriodMap := make(map[int64]int64)
rankPeriodMap := make(map[int64]time.Time)
err = utils.ExecuteQueryAll(&rankPeriodList, runsql2)
if err != nil {
log.Error("【自动创建赛季】,获取自动创建赛季时需要的开始时间失败:%s")
... ... @@ -101,8 +101,8 @@ LOOP0:
IsAuto: 1,
}
if t, ok := rankPeriodMap[v.RankTypeId]; ok {
s := time.Unix(t, 0).Format("2006-01-02")
dayTime, err := time.Parse("2006-01-02", s)
s := t.Format("2006-01-02")
dayTime, err := time.ParseInLocation("2006-01-02", s, time.Local)
if err != nil {
log.Error("【自动创建赛季】,格式化rank_period的end_time失败,id=%d,end_time=%d", v.RankTypeId, t)
continue LOOP1
... ... @@ -114,7 +114,7 @@ LOOP0:
m.SeasonName = fmt.Sprintf("自动创建赛季%s", s)
} else {
s := nowTime.Format("2006-01-02")
dayTime, _ := time.Parse("2006-01-02", s)
dayTime, _ := time.ParseInLocation("2006-01-02", s, time.Local)
begin := dayTime.Unix() + 24*60*60
end := begin + v.AutoPeriod*24*60*60 - 1
m.BeginTime = time.Unix(begin, 0).Local()
... ...