作者 陈志颖

fix:修复活动截止时间正序排序

@@ -13,7 +13,7 @@ import ( @@ -13,7 +13,7 @@ import (
13 type ListIntervalService struct { 13 type ListIntervalService struct {
14 } 14 }
15 15
16 -// 创建排行榜时间 16 +// TODO 创建排行榜时间,需要判断是否和当前排行榜时间冲突
17 func (listIntervalService *ListIntervalService) CreateListInterval(createListIntervalCommand *command.CreateListIntervalCommand) (interface{}, error) { 17 func (listIntervalService *ListIntervalService) CreateListInterval(createListIntervalCommand *command.CreateListIntervalCommand) (interface{}, error) {
18 if err := createListIntervalCommand.ValidateCommand(); err != nil { 18 if err := createListIntervalCommand.ValidateCommand(); err != nil {
19 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 19 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -29,12 +29,7 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt @@ -29,12 +29,7 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt
29 transactionContext.RollbackTransaction() 29 transactionContext.RollbackTransaction()
30 }() 30 }()
31 31
32 - newListInterval := &domain.ListInterval {  
33 - CompanyId: createListIntervalCommand.CompanyId,  
34 - IntervalStartTime: createListIntervalCommand.ListIntervalStartTime,  
35 - IntervalEndTime: createListIntervalCommand.ListIntervalEndTime,  
36 - }  
37 - 32 + // 排行榜时间仓储初始化
38 var listIntervalRepository domain.ListIntervalRepository 33 var listIntervalRepository domain.ListIntervalRepository
39 if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ 34 if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
40 "transactionContext": transactionContext, 35 "transactionContext": transactionContext,
@@ -44,6 +39,20 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt @@ -44,6 +39,20 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt
44 listIntervalRepository = value 39 listIntervalRepository = value
45 } 40 }
46 41
  42 + // 获取当前最新排行榜时间
  43 +
  44 +
  45 + // 判断排行榜时间是否重叠
  46 +
  47 +
  48 + // 创建排行榜时间命令
  49 + newListInterval := &domain.ListInterval {
  50 + CompanyId: createListIntervalCommand.CompanyId,
  51 + IntervalStartTime: createListIntervalCommand.ListIntervalStartTime,
  52 + IntervalEndTime: createListIntervalCommand.ListIntervalEndTime,
  53 + }
  54 +
  55 + // 保存排行榜时间
47 if listInterval, err := listIntervalRepository.Save(newListInterval); err != nil { 56 if listInterval, err := listIntervalRepository.Save(newListInterval); err != nil {
48 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 57 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
49 } else { 58 } else {
@@ -106,7 +106,7 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i @@ -106,7 +106,7 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i
106 } else { 106 } else {
107 query = query.Limit(20) 107 query = query.Limit(20)
108 } 108 }
109 - if count, err := query.Order("id DESC").SelectAndCount(); err != nil { 109 + if count, err := query.OrderExpr("deadline ASC").SelectAndCount(); err != nil {
110 return 0, exchangeCashActivities, err 110 return 0, exchangeCashActivities, err
111 } else { 111 } else {
112 for _, exchangeCashActivityModel := range exchangeCashActivityModels { 112 for _, exchangeCashActivityModel := range exchangeCashActivityModels {