From 0c9874c42bfa88f9b86112a3dbf9cf77f4393880 Mon Sep 17 00:00:00 2001
From: yanghui <2536613402@qq.com>
Date: 星期六, 26 十一月 2022 16:23:49 +0800
Subject: [PATCH] #feat 商家浏览量计算

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComShopFlowerOrderServiceImpl.java |   76 ++++++++++++++++++++++++++++---------
 1 files changed, 57 insertions(+), 19 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 d228712..33527b5 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
@@ -537,6 +537,7 @@
         } catch (Exception e) {
             log.error("申请退款失败," + e.getMessage());
             e.printStackTrace();
+            return R.fail("取消订单失败");
         }
         if (this.baseMapper.updateById(shopOrderDO) > 0) {
             // 添加订单操作记录
@@ -1010,27 +1011,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,10 +1071,22 @@
         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());
-        IPage<ComShopFlowerOrderStoreListVO> orderPageVOIPage = this.baseMapper.pageOrderByStoreId(page, pageComFlowerOrderListDTO);
+        IPage<ComShopFlowerOrderStoreListVO> orderPageVOIPage = this.baseMapper.pageOrderByDeliveryNo(page, pageComFlowerOrderListDTO);
         ComShopFlowerOrderDeliveryNoListVO comShopFlowerOrderDeliveryNoListVO = new ComShopFlowerOrderDeliveryNoListVO();
         ComShopFlowerOrderDeliveryDO comShopFlowerOrderDeliveryDO = comShopFlowerOrderDeliveryDAO.selectById(pageComFlowerOrderListDTO.getDeliveryId());
         ComShopFlowerOrderDeliveryVO comShopFlowerOrderDeliveryVO = new ComShopFlowerOrderDeliveryVO();

--
Gitblit v1.7.1