refactor(kds):优化日期时间范围查询逻辑
- 引入 LocalTime 类以精确控制当天结束时间 - 将原先的次日零点减一分钟逻辑替换为当天最大时间 - 统一订单查询的时间范围界定方式 - 提高代码可读性和维护性
Showing
1 changed file
with
5 additions
and
6 deletions
| ... | @@ -36,6 +36,7 @@ import org.springframework.stereotype.Service; | ... | @@ -36,6 +36,7 @@ import org.springframework.stereotype.Service; |
| 36 | 36 | ||
| 37 | import java.time.LocalDate; | 37 | import java.time.LocalDate; |
| 38 | import java.time.LocalDateTime; | 38 | import java.time.LocalDateTime; |
| 39 | +import java.time.LocalTime; | ||
| 39 | import java.util.ArrayList; | 40 | import java.util.ArrayList; |
| 40 | import java.util.List; | 41 | import java.util.List; |
| 41 | import java.util.function.Function; | 42 | import java.util.function.Function; |
| ... | @@ -60,8 +61,7 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -60,8 +61,7 @@ public class KdsServiceImpl implements KdsService { |
| 60 | // 获取当日所有的订单 和 订单明细 | 61 | // 获取当日所有的订单 和 订单明细 |
| 61 | LocalDate today = LocalDate.parse(queryDto.getMealTime(), DateUtil.YYYY_MM_DD); | 62 | LocalDate today = LocalDate.parse(queryDto.getMealTime(), DateUtil.YYYY_MM_DD); |
| 62 | LocalDateTime todayZero = today.atStartOfDay(); | 63 | LocalDateTime todayZero = today.atStartOfDay(); |
| 63 | - LocalDate tomorrow = today.plusDays(1); | 64 | + LocalDateTime todayEnd = today.atTime(LocalTime.MAX); |
| 64 | - LocalDateTime tomorrowZero = tomorrow.atStartOfDay(); | ||
| 65 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); | 65 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); |
| 66 | boolean shouldFilterStallIds = false; | 66 | boolean shouldFilterStallIds = false; |
| 67 | List<Integer> stallIds = new ArrayList<>(); | 67 | List<Integer> stallIds = new ArrayList<>(); |
| ... | @@ -78,7 +78,7 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -78,7 +78,7 @@ public class KdsServiceImpl implements KdsService { |
| 78 | .shouldFilterMealTimeStart(true) | 78 | .shouldFilterMealTimeStart(true) |
| 79 | .mealTimeStart(todayZero) | 79 | .mealTimeStart(todayZero) |
| 80 | .shouldFilterMealTimeEnd(true) | 80 | .shouldFilterMealTimeEnd(true) |
| 81 | - .mealTimeEnd(tomorrowZero) | 81 | + .mealTimeEnd(todayEnd) |
| 82 | .shouldFilterPayStatus(true) | 82 | .shouldFilterPayStatus(true) |
| 83 | .payStatus(PayStatusEnum.SUCCEED) | 83 | .payStatus(PayStatusEnum.SUCCEED) |
| 84 | .build(); | 84 | .build(); |
| ... | @@ -296,8 +296,7 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -296,8 +296,7 @@ public class KdsServiceImpl implements KdsService { |
| 296 | // 获取当日用餐的所有的订单 和 订单明细 | 296 | // 获取当日用餐的所有的订单 和 订单明细 |
| 297 | LocalDate today = LocalDate.parse(queryDto.getMealTime(), DateUtil.YYYY_MM_DD); | 297 | LocalDate today = LocalDate.parse(queryDto.getMealTime(), DateUtil.YYYY_MM_DD); |
| 298 | LocalDateTime todayZero = today.atStartOfDay(); | 298 | LocalDateTime todayZero = today.atStartOfDay(); |
| 299 | - LocalDate tomorrow = today.plusDays(1); | 299 | + LocalDateTime todayEnd = today.atTime(LocalTime.MAX); |
| 300 | - LocalDateTime tomorrowZero = tomorrow.atStartOfDay().minusMinutes(1); | ||
| 301 | 300 | ||
| 302 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); | 301 | final var operatorLoginInfo = LoginContextHolder.getLoginInfo(); |
| 303 | 302 | ||
| ... | @@ -318,7 +317,7 @@ public class KdsServiceImpl implements KdsService { | ... | @@ -318,7 +317,7 @@ public class KdsServiceImpl implements KdsService { |
| 318 | .shouldFilterMealTimeStart(true) | 317 | .shouldFilterMealTimeStart(true) |
| 319 | .mealTimeStart(todayZero) | 318 | .mealTimeStart(todayZero) |
| 320 | .shouldFilterMealTimeEnd(true) | 319 | .shouldFilterMealTimeEnd(true) |
| 321 | - .mealTimeEnd(tomorrowZero) | 320 | + .mealTimeEnd(todayEnd) |
| 322 | .shouldFilterStatus(true) | 321 | .shouldFilterStatus(true) |
| 323 | .status(queryDto.getOrderStatus()) | 322 | .status(queryDto.getOrderStatus()) |
| 324 | .shouldFilterPayStatus(true) | 323 | .shouldFilterPayStatus(true) | ... | ... |
-
Please register or login to post a comment