From 60ced96cb5ef00f870e722eb3e95306384cb9385 Mon Sep 17 00:00:00 2001 From: "YAS\\29473" <2947326429@qq.com> Date: Fri, 26 Sep 2025 14:55:18 +0800 Subject: [PATCH] update --- .../api/uniapp/customer/TempController.java | 2 +- .../java/com/jsowell/service/TempService.java | 20 ++++++++--- .../pile/vo/web/OrderCountByTimeVO.java | 36 ++++++++++++++----- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/TempController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/TempController.java index 1f9495308..fcf462648 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/TempController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/customer/TempController.java @@ -923,7 +923,7 @@ public class TempController extends BaseController { RestApiResponse response = null; try { //stationId ,merchantIdList,stationIdList,merchantId,startTime,endTime - List result = tempService.queryOrderCountByTime(dto); + OrderCountByTimeVO result = tempService.queryOrderCountByTime(dto); response = new RestApiResponse<>(result); } catch (Exception e) { logger.error("时间区间查询订单统计 error", e); diff --git a/jsowell-admin/src/main/java/com/jsowell/service/TempService.java b/jsowell-admin/src/main/java/com/jsowell/service/TempService.java index 27c7c703a..3c29cfe82 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/TempService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/TempService.java @@ -1280,7 +1280,7 @@ public class TempService { * @param dto * @return */ - public List queryOrderCountByTime(QueryOrderDTO dto) { + public OrderCountByTimeVO queryOrderCountByTime(QueryOrderDTO dto) { // 处理时间默认值 if (dto == null) { dto = new QueryOrderDTO(); @@ -1301,7 +1301,7 @@ public class TempService { List orderListVOS = orderBasicInfoMapper.selectOrderBasicInfoList(dto); //统计订单 - List result = new ArrayList<>(); + List result = new ArrayList<>(); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DateUtils.YYYY_MM_DD_HH_MM_SS); try { // 将开始时间和结束时间转换为LocalDateTime类型 @@ -1332,22 +1332,32 @@ public class TempService { LocalDateTime nextHour = currentHour.plusHours(1); int count = ordersByHour.getOrDefault(currentHour, Collections.emptyList()).size(); - OrderCountByTimeVO vo = new OrderCountByTimeVO(); + OrderCountByTimeVO.OrderCountByTimeListVO vo = new OrderCountByTimeVO.OrderCountByTimeListVO(); vo.setStartTime(currentHour.format(dateTimeFormatter)); vo.setEndTime(nextHour.format(dateTimeFormatter)); vo.setCount(count); + vo.setOrderCount(count); result.add(vo); currentHour = nextHour; } // 按开始时间排序 - result.sort(Comparator.comparing(OrderCountByTimeVO::getStartTime)); + result.sort(Comparator.comparing(OrderCountByTimeVO.OrderCountByTimeListVO::getStartTime)); } catch (Exception e) { logger.error("统计订单数量失败", e); } logger.info("查询订单数量结果:{}", JSONObject.toJSONString(result)); - return result; + OrderCountByTimeVO orderCountByTimeVO = new OrderCountByTimeVO(); + orderCountByTimeVO.setOrderCountByTimeList(result); + + //订单总数 + Integer totalCount = 0; + for (OrderCountByTimeVO.OrderCountByTimeListVO vo : result) { + totalCount += vo.getCount(); + } + orderCountByTimeVO.setTotalCount(totalCount); + return orderCountByTimeVO; } public void updateWalletCode() { diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderCountByTimeVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderCountByTimeVO.java index 7355f33f5..071af757e 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderCountByTimeVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/OrderCountByTimeVO.java @@ -2,19 +2,37 @@ package com.jsowell.pile.vo.web; import lombok.Data; +import java.util.List; + + @Data public class OrderCountByTimeVO { - /** - * 时间段 - */ - private String timeSlot; /** - * 订单数量 + * 总订单数量 */ - private Integer orderCount; + private Integer totalCount; + + private List orderCountByTimeList; + + + @Data + public static class OrderCountByTimeListVO { + /** + * 时间段 + */ + private String timeSlot; + + /** + * 订单数量 + */ + private Integer orderCount; + + private String startTime; + private String endTime; + private Integer count ; + } + + - private String startTime; - private String endTime; - private Integer count ; }