作者 陈志颖

fix:修改年榜时间段判断

... ... @@ -449,8 +449,10 @@ func (statisticsService *StatisticsService) ContributionsWealthRanking(contribut
employeeDao = value
}
// 返回年榜开始时间、结束时间
if contributionsWealthRankingQuery.RankingType == 2 {
if contributionsWealthRankingQuery.RankingType == 1 { // 返回总榜
contributionsWealthRankingQuery.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
contributionsWealthRankingQuery.EndTime = time.Now()
} else if contributionsWealthRankingQuery.RankingType == 2 { // 返回年榜
// 获取公司最新年榜
var listIntervalRepository domain.ListIntervalRepository
if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
... ... @@ -470,22 +472,36 @@ func (statisticsService *StatisticsService) ContributionsWealthRanking(contribut
if _, listIntervals, err := listIntervalRepository.Find(listListIntervalQuery); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if len(listIntervals) == 0 {
contributionsWealthRankingQuery.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
contributionsWealthRankingQuery.EndTime = time.Now()
} else {
contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime
contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime
if len(listIntervals) == 0 { // 未配置年榜
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
} else if len(listIntervals) == 1 { // 只配置了一个年榜
currentTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
if currentTime.Before(listIntervals[0].IntervalStartTime) && currentTime.After(listIntervals[0].IntervalEndTime) || currentTime.Equal(listIntervals[0].IntervalStartTime) || currentTime.Equal(listIntervals[0].IntervalEndTime) { // 当前时间在榜单内
contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime
contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime
} else { // 当前时间处于空档期
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
}
} else { // 配置了多个年榜
// 判断当前时间是否在榜单里
currentTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
for _, listInterval := range listIntervals {
if currentTime.Before(listInterval.IntervalStartTime) && currentTime.After(listInterval.IntervalEndTime) || currentTime.Equal(listInterval.IntervalStartTime) || currentTime.Equal(listInterval.IntervalEndTime) { // 当前时间在榜单内
contributionsWealthRankingQuery.StartTime = listInterval.IntervalStartTime
contributionsWealthRankingQuery.EndTime = listInterval.IntervalEndTime
break
} else { // 当前时间处于空档期
contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
break
}
}
}
}
}
// 返回总榜
if contributionsWealthRankingQuery.RankingType == 1 {
contributionsWealthRankingQuery.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
contributionsWealthRankingQuery.EndTime = time.Now()
}
// 默认返回总榜
if contributionsWealthRankingStatistics, err := employeeDao.ContributionsWealthRanking(tool_funs.SimpleStructToMap(contributionsWealthRankingQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...