作者 tangxvhui

bug 修复

@@ -15,9 +15,10 @@ func init() { @@ -15,9 +15,10 @@ func init() {
15 } 15 }
16 return true 16 return true
17 }), 17 }),
18 - beego.NSGet("/create_rank_peroid", func(ctx *context.Context) {  
19 - crontab.AutoCreateRankPeriod()  
20 - }), 18 + beego.NSGet("/create_rank_peroid",
  19 + func(ctx *context.Context) {
  20 + crontab.AutoCreateRankPeriod()
  21 + }),
21 ) 22 )
22 beego.AddNamespace(testNs) 23 beego.AddNamespace(testNs)
23 } 24 }
@@ -21,8 +21,8 @@ type RankTypeAutoPeriod struct { @@ -21,8 +21,8 @@ type RankTypeAutoPeriod struct {
21 21
22 // 22 //
23 type RankPeriodEndTime struct { 23 type RankPeriodEndTime struct {
24 - RankTypeId int64 `orm:"column(rank_type_id)"`  
25 - EndTime int64 `orm:"column(end_time)"` 24 + RankTypeId int64 `orm:"column(rank_type_id)"`
  25 + EndTime time.Time `orm:"column(end_time)"`
26 } 26 }
27 27
28 func AutoCreateRankPeriod() error { 28 func AutoCreateRankPeriod() error {
@@ -36,7 +36,7 @@ func AutoCreateRankPeriod() error { @@ -36,7 +36,7 @@ func AutoCreateRankPeriod() error {
36 AND NOT EXISTS( 36 AND NOT EXISTS(
37 SELECT 1 FROM rank_period AS c WHERE a.id=c.rank_type_id AND c.status<2 37 SELECT 1 FROM rank_period AS c WHERE a.id=c.rank_type_id AND c.status<2
38 ) 38 )
39 - AND a.create_at>? 39 + AND UNIX_TIMESTAMP(a.create_at)>?
40 LIMIT 1000` 40 LIMIT 1000`
41 41
42 //获取自动创建赛季时需要的开始时间 42 //获取自动创建赛季时需要的开始时间
@@ -75,7 +75,7 @@ LOOP0: @@ -75,7 +75,7 @@ LOOP0:
75 var ( 75 var (
76 rankPeriodList []RankPeriodEndTime 76 rankPeriodList []RankPeriodEndTime
77 ) 77 )
78 - rankPeriodMap := make(map[int64]int64) 78 + rankPeriodMap := make(map[int64]time.Time)
79 err = utils.ExecuteQueryAll(&rankPeriodList, runsql2) 79 err = utils.ExecuteQueryAll(&rankPeriodList, runsql2)
80 if err != nil { 80 if err != nil {
81 log.Error("【自动创建赛季】,获取自动创建赛季时需要的开始时间失败:%s") 81 log.Error("【自动创建赛季】,获取自动创建赛季时需要的开始时间失败:%s")
@@ -101,8 +101,8 @@ LOOP0: @@ -101,8 +101,8 @@ LOOP0:
101 IsAuto: 1, 101 IsAuto: 1,
102 } 102 }
103 if t, ok := rankPeriodMap[v.RankTypeId]; ok { 103 if t, ok := rankPeriodMap[v.RankTypeId]; ok {
104 - s := time.Unix(t, 0).Format("2006-01-02")  
105 - dayTime, err := time.Parse("2006-01-02", s) 104 + s := t.Format("2006-01-02")
  105 + dayTime, err := time.ParseInLocation("2006-01-02", s, time.Local)
106 if err != nil { 106 if err != nil {
107 log.Error("【自动创建赛季】,格式化rank_period的end_time失败,id=%d,end_time=%d", v.RankTypeId, t) 107 log.Error("【自动创建赛季】,格式化rank_period的end_time失败,id=%d,end_time=%d", v.RankTypeId, t)
108 continue LOOP1 108 continue LOOP1
@@ -114,7 +114,7 @@ LOOP0: @@ -114,7 +114,7 @@ LOOP0:
114 m.SeasonName = fmt.Sprintf("自动创建赛季%s", s) 114 m.SeasonName = fmt.Sprintf("自动创建赛季%s", s)
115 } else { 115 } else {
116 s := nowTime.Format("2006-01-02") 116 s := nowTime.Format("2006-01-02")
117 - dayTime, _ := time.Parse("2006-01-02", s) 117 + dayTime, _ := time.ParseInLocation("2006-01-02", s, time.Local)
118 begin := dayTime.Unix() + 24*60*60 118 begin := dayTime.Unix() + 24*60*60
119 end := begin + v.AutoPeriod*24*60*60 - 1 119 end := begin + v.AutoPeriod*24*60*60 - 1
120 m.BeginTime = time.Unix(begin, 0).Local() 120 m.BeginTime = time.Unix(begin, 0).Local()