update
This commit is contained in:
@@ -21,7 +21,7 @@ type TimeObject struct {
|
||||
Y bool `json:"y"`
|
||||
}
|
||||
|
||||
func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFilter, orderTimeMap map[string]string, carNum int, orderNumMap map[string]int, carServiceNum int, times []string, orderTimeCount map[string]int) map[string][]TimeObject {
|
||||
func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFilter, orderTimeMap map[string]string, carNum int, orderNumMap map[string]int, carServiceNum int, times []string, orderTimeCount map[string]int, projectionTime map[string]int) map[string][]TimeObject {
|
||||
// 获取当前时间
|
||||
currentTime := time.Now()
|
||||
// 计算半小时后的时间
|
||||
@@ -51,23 +51,27 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
|
||||
serviceDaysMap[dayTime] = dayTime
|
||||
}
|
||||
for nextHour.Before(oneWeekLater) {
|
||||
key := nextHour.Format("2006-01-02")
|
||||
key1 := nextHour.Format("2006-01-02 15:04")
|
||||
if nextHour.Hour() < workStart || nextHour.Hour() > workEnd {
|
||||
nextHour = nextHour.Add(time.Duration(minute) * time.Minute)
|
||||
continue
|
||||
}
|
||||
if _, ok := serviceDaysMap[key1]; len(serviceDaysMap) > 0 && !ok {
|
||||
//不存在服务配置中返回false
|
||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||
Time: nextHour.Format("15:04"),
|
||||
Y: false,
|
||||
})
|
||||
nextHour = nextHour.Add(time.Duration(minute) * time.Minute)
|
||||
continue
|
||||
}
|
||||
//且不存在过滤时间中
|
||||
_, existsDay := reserveMap[nextHour.Format("2006-01-02")]
|
||||
_, existsHour := reserveMap[nextHour.Format("15")]
|
||||
_, existOrderTime := orderTimeMap[nextHour.Format("2006-01-02 15:04")]
|
||||
orderNum, existOrderNum := orderNumMap[nextHour.Format("2006-01-02 15:04")]
|
||||
if (nextHour.Hour() >= workStart && nextHour.Hour() < workEnd) && (!existsDay && !existsHour) && !existOrderTime {
|
||||
key := nextHour.Format("2006-01-02")
|
||||
key1 := nextHour.Format("2006-01-02 15:04")
|
||||
if _, ok := serviceDaysMap[key1]; len(serviceDaysMap) > 0 && !ok {
|
||||
//不存在服务配置中返回false
|
||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||
Time: nextHour.Format("15:04"),
|
||||
Y: false,
|
||||
})
|
||||
nextHour = nextHour.Add(time.Duration(minute) * time.Minute)
|
||||
continue
|
||||
}
|
||||
if (!existsDay && !existsHour) && !existOrderTime {
|
||||
if _, ok := dayHoursMap[key]; ok {
|
||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||
Time: nextHour.Format("15:04"),
|
||||
@@ -98,8 +102,9 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
|
||||
} else if nextHour.Hour() >= workStart && nextHour.Hour() < workEnd {
|
||||
//查看当前时间对应的订单数量
|
||||
orderCount := orderTimeCount[key1]
|
||||
//预约时间对应的订单数<车辆数量 当前时间可以预约
|
||||
if orderCount < carNum*carServiceNum {
|
||||
time := projectionTime[key1]
|
||||
//预约时间对应的订单数<车辆数量 当前时间可以预约 且是1笔订单
|
||||
if orderCount < carNum*carServiceNum && time > 60 {
|
||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||
Time: nextHour.Format("15:04"),
|
||||
Y: true,
|
||||
|
||||
Reference in New Issue
Block a user