diff --git a/app/customer/svc/order/svc_central_kitchen_for_school_order.go b/app/customer/svc/order/svc_central_kitchen_for_school_order.go index 0e9945f..d9ce2bc 100644 --- a/app/customer/svc/order/svc_central_kitchen_for_school_order.go +++ b/app/customer/svc/order/svc_central_kitchen_for_school_order.go @@ -166,9 +166,11 @@ func CentralKitchenForSchoolMyReserve(userIdentityId int, date, startDate, endDa //2、构造数据 var totalBreakfast, totalLunch, totalDinner, total int var dateMap = map[string]*md.CentralKitchenForSchoolMyReserveRespList{} + var dateMapKey []string for _, v := range *list { if v.State == enum.CentralKitchenForSchoolUserWithDayStateForWait || v.State == enum.CentralKitchenForSchoolUserWithDayStateForAlready { if dateMap[v.Date] == nil { + dateMapKey = append(dateMapKey, v.Date) dateMap[v.Date] = &md.CentralKitchenForSchoolMyReserveRespList{} } dateMap[v.Date].Date = v.Date @@ -187,12 +189,14 @@ func CentralKitchenForSchoolMyReserve(userIdentityId int, date, startDate, endDa } } } + + for _, value := range dateMapKey { + resp.List = append(resp.List, *dateMap[value]) + } + resp.Total = total resp.LunchTotal = totalLunch resp.DinnerTotal = totalDinner resp.BreakfastTotal = totalBreakfast - for _, v := range dateMap { - resp.List = append(resp.List, *v) - } return } diff --git a/app/db/db_central_kitchen_for_school_user_with_day.go b/app/db/db_central_kitchen_for_school_user_with_day.go index c0f689c..7087147 100644 --- a/app/db/db_central_kitchen_for_school_user_with_day.go +++ b/app/db/db_central_kitchen_for_school_user_with_day.go @@ -32,7 +32,7 @@ func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) FindCentralKitchenForSchoolUserWithDayByDate(sDate, eDate string) (*[]model.CentralKitchenForSchoolUserWithDay, error) { var m []model.CentralKitchenForSchoolUserWithDay if err := centralKitchenForSchoolUserWithDayDb.Db.Where("identity_id =?", centralKitchenForSchoolUserWithDayDb.IdentityId). - And("date >= ? And date <= ?", sDate, eDate).Desc("id").Find(&m); err != nil { + And("date >= ? And date <= ?", sDate, eDate).Asc("date").Find(&m); err != nil { return nil, logx.Error(err) } return &m, nil