|
...
|
...
|
@@ -17,6 +17,7 @@ type RankTypeAutoPeriod struct { |
|
|
|
CompanyId int64 `orm:"column(company_id)"`
|
|
|
|
AutoPeriod int64 `orm:"column(auto_period)"`
|
|
|
|
CreateTime int64 `orm:"column(create_time)"`
|
|
|
|
RankType int8 `orm:"column(rank_type)`
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
...
|
...
|
@@ -28,7 +29,7 @@ type RankPeriodEndTime struct { |
|
|
|
func AutoCreateRankPeriod() error {
|
|
|
|
log.Info("计划任务:【自动创建赛季】")
|
|
|
|
//获取需要执行自动创建的榜单记录
|
|
|
|
sql1 := `SELECT a.id AS rank_type_id,a.auto_period,UNIX_TIMESTAMP(a.create_at) AS create_time
|
|
|
|
sql1 := `SELECT a.id AS rank_type_id,a.type AS rank_type,a.auto_period,UNIX_TIMESTAMP(a.create_at) AS create_time
|
|
|
|
,a.company_id
|
|
|
|
FROM rank_type AS a
|
|
|
|
JOIN company AS b ON a.company_id=b.id AND b.enable=1 AND b.delete_at=0
|
|
...
|
...
|
@@ -111,7 +112,7 @@ LOOP0: |
|
|
|
end := begin + v.AutoPeriod*24*60*60 - 1
|
|
|
|
m.BeginTime = time.Unix(begin, 0).Local()
|
|
|
|
m.EndTime = time.Unix(end, 0).Local()
|
|
|
|
m.SeasonName = fmt.Sprintf("自动创建赛季%s", s)
|
|
|
|
// m.SeasonName = fmt.Sprintf("自动创建赛季%s", s)
|
|
|
|
} else {
|
|
|
|
s := nowTime.Format("2006-01-02")
|
|
|
|
dayTime, _ := time.ParseInLocation("2006-01-02", s, time.Local)
|
|
...
|
...
|
@@ -119,7 +120,14 @@ LOOP0: |
|
|
|
end := begin + v.AutoPeriod*24*60*60 - 1
|
|
|
|
m.BeginTime = time.Unix(begin, 0).Local()
|
|
|
|
m.EndTime = time.Unix(end, 0).Local()
|
|
|
|
m.SeasonName = fmt.Sprintf("自动创建赛季%s", s)
|
|
|
|
// m.SeasonName = fmt.Sprintf("自动创建赛季%s", s)
|
|
|
|
}
|
|
|
|
if v.RankType == models.RANK_TYPE_YEAR {
|
|
|
|
//年榜
|
|
|
|
m.SeasonName = fmt.Sprintf("%d%s", nowTime.Year(), "年赛季")
|
|
|
|
} else if v.RankType == models.RANK_TYPE_SEASON {
|
|
|
|
//季榜
|
|
|
|
m.SeasonName = fmt.Sprintf("%d%s", nowTime.Month(), "月赛季")
|
|
|
|
}
|
|
|
|
addRankPeriod = append(addRankPeriod, m)
|
|
|
|
}
|
...
|
...
|
|