yanghui
2022-11-26 f83dceab74da9bda2db807199190fc02168a48dc
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());