From f83dceab74da9bda2db807199190fc02168a48dc Mon Sep 17 00:00:00 2001 From: yanghui <2536613402@qq.com> Date: 星期六, 26 十一月 2022 13:13:58 +0800 Subject: [PATCH] #feat 统计接口修改 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java | 73 +++++++++++++++++++++++++++--------- 1 files changed, 55 insertions(+), 18 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java index 71c53c8..e59ab1b 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java @@ -1010,27 +1010,52 @@ return R.ok(retMap); } - public R selectOrderLineChart(Long storeId, Integer type) { - if (1 == type) { - //近15天的订单量 - int days = 15; - return getCountByStoreIdAndDays(storeId, days); - } else if (2 == type) { - //近30天的订单量 - int days = 30; - return getCountByStoreIdAndDays(storeId, days); - } else { - //今年所有月份订单量 - List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS = this.baseMapper.selectCountOrderMonthByStoreId(storeId); - Map<String, Integer> retMap = comShopOrderStoreIdCountVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum)); - List<String> yearMonths = DateUtils.getYearMonths(); - for (String yearMonth : yearMonths) { - if (!retMap.containsKey(yearMonth)) { - retMap.put(yearMonth, 0); + public R selectOrderLineChart(Long storeId, Integer type,Integer tab) { + if (tab == 1){ + if (1 == type) { + //近15天的订单量 + int days = 15; + return getCountByStoreIdAndDays(storeId, days); + } else if (2 == type) { + //近30天的订单量 + int days = 30; + return getCountByStoreIdAndDays(storeId, days); + } else { + //今年所有月份订单量 + List<ComShopOrderStoreIdCountVO> comShopOrderStoreIdCountVOS = this.baseMapper.selectCountOrderMonthByStoreId(storeId); + Map<String, Integer> retMap = comShopOrderStoreIdCountVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdCountVO::getCountName, ComShopOrderStoreIdCountVO::getCountNum)); + List<String> yearMonths = DateUtils.getYearMonths(); + for (String yearMonth : yearMonths) { + if (!retMap.containsKey(yearMonth)) { + retMap.put(yearMonth, 0); + } } + return R.ok(retMap); } - return R.ok(retMap); + }else if (2==tab){ + if (1 == type) { + //近15天的营收 + int days = 15; + return getSumByStoreIdAndDays(storeId, days); + } else if (2 == type) { + //近30天的营收 + int days = 30; + return getSumByStoreIdAndDays(storeId, days); + } else { + //今年所有月份订单量 + List<ComShopOrderStoreIdNumVO> comShopOrderStoreIdCountVOS = this.baseMapper.selectOrderSumMonthByStoreId(storeId); + Map<String, BigDecimal> retMap = comShopOrderStoreIdCountVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdNumVO::getCountName, ComShopOrderStoreIdNumVO::getCountNum)); + List<String> yearMonths = DateUtils.getYearMonths(); + for (String yearMonth : yearMonths) { + if (!retMap.containsKey(yearMonth)) { + retMap.put(yearMonth, BigDecimal.ZERO); + } + } + return R.ok(retMap); + } } + return R.ok(); + } private R getCountByStoreIdAndDays(Long storeId, int days) { @@ -1045,6 +1070,18 @@ return R.ok(retMap); } + private R getSumByStoreIdAndDays(Long storeId, int days) { + List<ComShopOrderStoreIdNumVO> comShopOrderStoreIdNumVOS = this.baseMapper.selectOrderSumPayDayByStoreId(storeId, days); + Map<String, BigDecimal> retMap = comShopOrderStoreIdNumVOS.stream().collect(Collectors.toMap(ComShopOrderStoreIdNumVO::getCountName, ComShopOrderStoreIdNumVO::getCountNum)); + List<String> beforeDays = DateUtils.getBeforeDays(days); + for (String beforeDay : beforeDays) { + if (!retMap.containsKey(beforeDay)) { + retMap.put(beforeDay, BigDecimal.ZERO); + } + } + return R.ok(retMap); + } + @Override public R pageOrderByDeliveryNo(PageComFlowerOrderListDTO pageComFlowerOrderListDTO) { Page page = new Page(pageComFlowerOrderListDTO.getPageNum(), pageComFlowerOrderListDTO.getPageSize()); -- Gitblit v1.7.1