作者 陈志颖

fix:修改年榜时间段判断

@@ -449,8 +449,10 @@ func (statisticsService *StatisticsService) ContributionsWealthRanking(contribut @@ -449,8 +449,10 @@ func (statisticsService *StatisticsService) ContributionsWealthRanking(contribut
449 employeeDao = value 449 employeeDao = value
450 } 450 }
451 451
452 - // 返回年榜开始时间、结束时间  
453 - if contributionsWealthRankingQuery.RankingType == 2 { 452 + if contributionsWealthRankingQuery.RankingType == 1 { // 返回总榜
  453 + contributionsWealthRankingQuery.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
  454 + contributionsWealthRankingQuery.EndTime = time.Now()
  455 + } else if contributionsWealthRankingQuery.RankingType == 2 { // 返回年榜
454 // 获取公司最新年榜 456 // 获取公司最新年榜
455 var listIntervalRepository domain.ListIntervalRepository 457 var listIntervalRepository domain.ListIntervalRepository
456 if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ 458 if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
@@ -470,22 +472,36 @@ func (statisticsService *StatisticsService) ContributionsWealthRanking(contribut @@ -470,22 +472,36 @@ func (statisticsService *StatisticsService) ContributionsWealthRanking(contribut
470 if _, listIntervals, err := listIntervalRepository.Find(listListIntervalQuery); err != nil { 472 if _, listIntervals, err := listIntervalRepository.Find(listListIntervalQuery); err != nil {
471 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 473 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
472 } else { 474 } else {
473 - if len(listIntervals) == 0 {  
474 - contributionsWealthRankingQuery.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())  
475 - contributionsWealthRankingQuery.EndTime = time.Now()  
476 - } else {  
477 - contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime  
478 - contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime 475 + if len(listIntervals) == 0 { // 未配置年榜
  476 + contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
  477 + contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
  478 + } else if len(listIntervals) == 1 { // 只配置了一个年榜
  479 + currentTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
  480 + if currentTime.Before(listIntervals[0].IntervalStartTime) && currentTime.After(listIntervals[0].IntervalEndTime) || currentTime.Equal(listIntervals[0].IntervalStartTime) || currentTime.Equal(listIntervals[0].IntervalEndTime) { // 当前时间在榜单内
  481 + contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime
  482 + contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime
  483 + } else { // 当前时间处于空档期
  484 + contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
  485 + contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
  486 + }
  487 + } else { // 配置了多个年榜
  488 + // 判断当前时间是否在榜单里
  489 + currentTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
  490 + for _, listInterval := range listIntervals {
  491 + if currentTime.Before(listInterval.IntervalStartTime) && currentTime.After(listInterval.IntervalEndTime) || currentTime.Equal(listInterval.IntervalStartTime) || currentTime.Equal(listInterval.IntervalEndTime) { // 当前时间在榜单内
  492 + contributionsWealthRankingQuery.StartTime = listInterval.IntervalStartTime
  493 + contributionsWealthRankingQuery.EndTime = listInterval.IntervalEndTime
  494 + break
  495 + } else { // 当前时间处于空档期
  496 + contributionsWealthRankingQuery.StartTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
  497 + contributionsWealthRankingQuery.EndTime = time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.UTC)
  498 + break
  499 + }
  500 + }
479 } 501 }
480 } 502 }
481 } 503 }
482 504
483 - // 返回总榜  
484 - if contributionsWealthRankingQuery.RankingType == 1 {  
485 - contributionsWealthRankingQuery.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())  
486 - contributionsWealthRankingQuery.EndTime = time.Now()  
487 - }  
488 -  
489 // 默认返回总榜 505 // 默认返回总榜
490 if contributionsWealthRankingStatistics, err := employeeDao.ContributionsWealthRanking(tool_funs.SimpleStructToMap(contributionsWealthRankingQuery)); err != nil { 506 if contributionsWealthRankingStatistics, err := employeeDao.ContributionsWealthRanking(tool_funs.SimpleStructToMap(contributionsWealthRankingQuery)); err != nil {
491 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 507 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())