|
|
@@ -203,7 +203,7 @@ func CentralKitchenForSchoolMyReserve(userIdentityId int, date, startDate, endDa |
|
|
|
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} |
|
|
|
centralKitchenForSchoolUserWithDayDb.Set(userIdentityId) |
|
|
|
var states = []int{enum.CentralKitchenForSchoolUserWithDayStateForWait, enum.CentralKitchenForSchoolUserWithDayStateForAlready} |
|
|
|
list, err := centralKitchenForSchoolUserWithDayDb.FindCentralKitchenForSchoolUserWithDayByDate(startDate, endDate, states) |
|
|
|
list, err := centralKitchenForSchoolUserWithDayDb.FindCentralKitchenForSchoolUserWithDayByDateAndStates(startDate, endDate, states) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
@@ -263,3 +263,40 @@ func CentralKitchenForSchoolMyReserve(userIdentityId int, date, startDate, endDa |
|
|
|
resp.BreakfastTotal = totalBreakfast |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func CentralKitchenForSchoolMyReserveList(userIdentityId int, date, startDate, endDate string) (err error, resp md.CentralKitchenForSchoolMyReserveListResp) { |
|
|
|
resp.Date = date |
|
|
|
//1、查询出对应时间段,所有 "待就餐"、 "已就餐" 记录 |
|
|
|
centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} |
|
|
|
centralKitchenForSchoolUserWithDayDb.Set(userIdentityId) |
|
|
|
list, err := centralKitchenForSchoolUserWithDayDb.FindCentralKitchenForSchoolUserWithDayByDate(startDate, endDate) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//2、构造数据 |
|
|
|
var totalAmount float64 |
|
|
|
var dateMap = map[int]*md.CentralKitchenForSchoolMyReserveListRespList{} |
|
|
|
var dateMapKey []int |
|
|
|
for _, v := range *list { |
|
|
|
tmpDate, _ := time.ParseInLocation("2006-01-02", v.Date, time.Local) |
|
|
|
tmpDateMonth := int(tmpDate.Month()) |
|
|
|
if dateMap[tmpDateMonth] == nil { |
|
|
|
dateMapKey = append(dateMapKey, tmpDateMonth) |
|
|
|
dateMap[tmpDateMonth] = &md.CentralKitchenForSchoolMyReserveListRespList{} |
|
|
|
} |
|
|
|
dateMap[tmpDateMonth].Month = tmpDateMonth |
|
|
|
dateMap[tmpDateMonth].TotalAmount += utils.StrToFloat64(v.Amount) |
|
|
|
totalAmount += utils.StrToFloat64(v.Amount) |
|
|
|
if v.State == enum.CentralKitchenForSchoolUserWithDayStateForCancel { |
|
|
|
dateMap[tmpDateMonth].RefundTotalAmount += utils.StrToFloat64(v.Amount) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for _, value := range dateMapKey { |
|
|
|
resp.List = append(resp.List, *dateMap[value]) |
|
|
|
} |
|
|
|
|
|
|
|
resp.TotalAmount = totalAmount |
|
|
|
return |
|
|
|
} |