作者 陈志颖

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

... ... @@ -13,7 +13,7 @@ import (
type ListIntervalService struct {
}
// 创建排行榜时间
// TODO 创建排行榜时间,需要判断是否和当前排行榜时间冲突
func (listIntervalService *ListIntervalService) CreateListInterval(createListIntervalCommand *command.CreateListIntervalCommand) (interface{}, error) {
if err := createListIntervalCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -29,12 +29,7 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt
transactionContext.RollbackTransaction()
}()
newListInterval := &domain.ListInterval {
CompanyId: createListIntervalCommand.CompanyId,
IntervalStartTime: createListIntervalCommand.ListIntervalStartTime,
IntervalEndTime: createListIntervalCommand.ListIntervalEndTime,
}
// 排行榜时间仓储初始化
var listIntervalRepository domain.ListIntervalRepository
if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -44,6 +39,20 @@ func (listIntervalService *ListIntervalService) CreateListInterval(createListInt
listIntervalRepository = value
}
// 获取当前最新排行榜时间
// 判断排行榜时间是否重叠
// 创建排行榜时间命令
newListInterval := &domain.ListInterval {
CompanyId: createListIntervalCommand.CompanyId,
IntervalStartTime: createListIntervalCommand.ListIntervalStartTime,
IntervalEndTime: createListIntervalCommand.ListIntervalEndTime,
}
// 保存排行榜时间
if listInterval, err := listIntervalRepository.Save(newListInterval); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -106,7 +106,7 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i
} else {
query = query.Limit(20)
}
if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
if count, err := query.OrderExpr("deadline ASC").SelectAndCount(); err != nil {
return 0, exchangeCashActivities, err
} else {
for _, exchangeCashActivityModel := range exchangeCashActivityModels {
... ...