From 52d41ba1f8365731cd1d3baffa9d65b4d909d643 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Fri, 15 Jan 2021 15:13:34 +0800
Subject: [PATCH] modify

---
 zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java |   59 ++++++++---
 zq-erp/src/main/java/com/matrix/system/app/vo/BusinessesDataShowVo.java    |  154 ++++++++++++++++--------------
 zq-erp/src/main/java/com/matrix/system/hive/dao/SysBusinessDataDao.java    |    2 
 zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml       |   39 ++++---
 4 files changed, 146 insertions(+), 108 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java b/zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java
index 24514fb..97bbb20 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java
@@ -3,6 +3,7 @@
 import com.matrix.core.constance.MatrixConstance;
 import com.matrix.core.pojo.AjaxResult;
 import com.matrix.core.pojo.PaginationVO;
+import com.matrix.core.tools.DateUtil;
 import com.matrix.core.tools.WebUtil;
 import com.matrix.system.app.dto.BusinessesDto;
 import com.matrix.system.app.dto.VipStatisticsParamDto;
@@ -21,6 +22,7 @@
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiResponse;
 import io.swagger.annotations.ApiResponses;
+import org.jsoup.helper.DataUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -53,20 +55,54 @@
     @PostMapping(value = "/findShopBusinessesData")
     public AjaxResult findShopBusinessesData(@RequestBody BusinessesDto businessesDto) {
         String unit = "";
+        int calenderUnit;
         if (BusinessesDto.DAY.equals(businessesDto.getType())) {
             unit = "日";
+            calenderUnit = Calendar.DATE;
         } else {
             unit = "月";
+            calenderUnit = Calendar.MONTH;
         }
 
-        //        PaginationVO pageVo = new PaginationVO();
-//        pageVo.setOffset((businessesDto.getPageNum() - 1) * businessesDto.getPageSize());
-//        pageVo.setLimit(businessesDto.getPageSize());
+        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
+        int start = (businessesDto.getPageNum() - 1) * businessesDto.getPageSize();
+        int size = businessesDto.getPageSize();
         Calendar calendar = Calendar.getInstance();
-        Date now = calendar.getTime();
-        List<Date> xAxis = StatisticsTimeUtil.getTimeSpace("2021-01-13", "2021-01-13", unit);
+        calendar.add(calenderUnit, -start);
+        String endTime = DateUtil.dateToString(calendar.getTime(), DateUtil.DATE_FORMAT_DD);
+        calendar.add(calenderUnit, -size);
+        String startTime = DateUtil.dateToString(calendar.getTime(), DateUtil.DATE_FORMAT_DD);
+        List<Date> xAxis = StatisticsTimeUtil.getTimeSpace(startTime, endTime, unit);
         List<StatisticsTimeDaoParam> timeSpaceParam = StatisticsTimeUtil.buidParam(xAxis);
-        return AjaxResult.buildSuccessInstance("123");
+        List<StatisticsTimeDaoParam> statisticsTimeDaoParams = timeSpaceParam.subList(0, timeSpaceParam.size() - 2);
+        List<BusinessesDataShowVo> list = sysBusinessDataDao.selectApiBusinessData(statisticsTimeDaoParams, businessesDto.getShopId(), user.getCompanyId());
+
+        List<BusinessesDataShowVo> result = new ArrayList<>();
+        for (int i = list.size() - 1; i >= 0; i--) {
+            BusinessesDataShowVo item = list.get(i);
+            String dataTime = item.getDataTime();
+            if (BusinessesDto.DAY.equals(businessesDto.getType())) {
+                item.setDataTime(DateUtil.dateToString(DateUtil.stringToDate(dataTime, DateUtil.DATE_FORMAT_DD), DateUtil.DATE_FORMAT_DD));
+            } else {
+                item.setDataTime(DateUtil.dateToString(DateUtil.stringToDate(dataTime, DateUtil.MONTH), DateUtil.MONTH));
+            }
+            result.add(item);
+        }
+        return AjaxResult.buildSuccessInstance(result);
+    }
+
+    public static void main(String[] args) {
+        int start = 1;
+
+        int end  = 10;
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.add(Calendar.DATE, start);
+        Date time = calendar.getTime();
+        System.out.println(time);
+        calendar.add(Calendar.DATE, end);
+        System.out.println(calendar.getTime());
+
     }
 
     @ApiOperation(value = "专项", notes = "专项")
@@ -209,16 +245,5 @@
         });
 
         return setDataList(ajaxResult);
-    }
-
-    @ApiOperation(value = "测试", notes = "测试")
-    @GetMapping(value = "/findTestData")
-    public AjaxResult findTestData() {
-        List<Date> xAxis = StatisticsTimeUtil.getTimeSpace("2021-01-13", "2021-01-13", "日");
-
-        List<StatisticsTimeDaoParam> timeSpaceParam = StatisticsTimeUtil.buidParam(xAxis);
-//        List<BusinessesDataShowVo> businessesDataShowVo = sysBusinessDataDao.selectDemo2();
-        List<BusinessesDataShowVo> map = sysBusinessDataDao.selectDemo(timeSpaceParam, 34L, 17L);
-        return AjaxResult.buildSuccessInstance(map);
     }
 }
diff --git a/zq-erp/src/main/java/com/matrix/system/app/vo/BusinessesDataShowVo.java b/zq-erp/src/main/java/com/matrix/system/app/vo/BusinessesDataShowVo.java
index 7806b4f..ab14537 100644
--- a/zq-erp/src/main/java/com/matrix/system/app/vo/BusinessesDataShowVo.java
+++ b/zq-erp/src/main/java/com/matrix/system/app/vo/BusinessesDataShowVo.java
@@ -17,64 +17,64 @@
     private String dataTime;
 
     @ApiModelProperty(value = "营业收入")
-    private String totalPay;
+    private BigDecimal totalPay;
 
     @ApiModelProperty(value = "现金收款")
-    private String cashPay;
+    private BigDecimal cashPay;
 
     @ApiModelProperty(value = "储值卡收款")
-    private String cardPay;
+    private BigDecimal cardPay;
 
     @ApiModelProperty(value = "欠款")
-    private String arrearsPay;
+    private BigDecimal arrearsPay;
 
     @ApiModelProperty(value = "现金退款")
-    private String refundCashPay;
+    private BigDecimal refundCashPay;
 
     @ApiModelProperty(value = "卡项退款")
-    private String refundCardPay;
+    private BigDecimal refundCardPay;
 
     @ApiModelProperty(value = "产品业绩")
-    private String productAchieve;
+    private BigDecimal productAchieve;
 
     @ApiModelProperty(value = "卡项业绩")
-    private String cardAchieve;
+    private BigDecimal cardAchieve;
 
     @ApiModelProperty(value = "退款")
-    private String refund;
+    private BigDecimal refund;
 
     @ApiModelProperty(value = "客单数")
-    private String perCustomCnt;
+    private BigDecimal perCustomCnt;
 
     @ApiModelProperty(value = "客品数")
-    private String customGoodsCnt;
+    private BigDecimal customGoodsCnt;
 
     @ApiModelProperty(value = "客单价")
-    private String perCustomPrice;
+    private BigDecimal perCustomPrice;
 
     @ApiModelProperty(value = "成本")
-    private String cost;
+    private BigDecimal cost;
 
     @ApiModelProperty(value = "毛利")
-    private String grossProfit;
+    private BigDecimal grossProfit;
 
     @ApiModelProperty(value = "毛利率")
-    private String grossProfitRate;
+    private BigDecimal grossProfitRate;
 
     @ApiModelProperty(value = "本金消耗")
-    private String consumePay;
+    private BigDecimal consumePay;
 
     @ApiModelProperty(value = "赠送消耗")
-    private String freeConsumePay;
+    private BigDecimal freeConsumePay;
 
     @ApiModelProperty(value = "人头数")
-    private String peopleCnt;
+    private BigDecimal peopleCnt;
 
     @ApiModelProperty(value = "项目消耗数")
-    private String projConsumeCnt;
+    private BigDecimal projConsumeCnt;
 
     @ApiModelProperty(value = "服务时长")
-    private String timeLength;
+    private BigDecimal timeLength;
 
     /**
      * 当天销售总数量
@@ -86,13 +86,13 @@
      * 家居产品成本
      */
     @ApiModelProperty(hidden = true)
-    private String goodsCost;
+    private BigDecimal goodsCost;
 
     /**
      * 除家具产品以外成本
      */
     @ApiModelProperty(hidden = true)
-    private String otherCost;
+    private BigDecimal otherCost;
 
     public Integer getTotalSaleCnt() {
         return totalSaleCnt;
@@ -102,19 +102,19 @@
         this.totalSaleCnt = totalSaleCnt;
     }
 
-    public String getGoodsCost() {
+    public BigDecimal getGoodsCost() {
         return goodsCost;
     }
 
-    public void setGoodsCost(String goodsCost) {
+    public void setGoodsCost(BigDecimal goodsCost) {
         this.goodsCost = goodsCost;
     }
 
-    public String getOtherCost() {
+    public BigDecimal getOtherCost() {
         return otherCost;
     }
 
-    public void setOtherCost(String otherCost) {
+    public void setOtherCost(BigDecimal otherCost) {
         this.otherCost = otherCost;
     }
 
@@ -126,163 +126,175 @@
         this.dataTime = dataTime;
     }
 
-    public String getTotalPay() {
+    public BigDecimal getTotalPay() {
         return totalPay;
     }
 
-    public void setTotalPay(String totalPay) {
+    public void setTotalPay(BigDecimal totalPay) {
         this.totalPay = totalPay;
     }
 
-    public String getCashPay() {
+    public BigDecimal getCashPay() {
         return cashPay;
     }
 
-    public void setCashPay(String cashPay) {
+    public void setCashPay(BigDecimal cashPay) {
         this.cashPay = cashPay;
     }
 
-    public String getCardPay() {
+    public BigDecimal getCardPay() {
         return cardPay;
     }
 
-    public void setCardPay(String cardPay) {
+    public void setCardPay(BigDecimal cardPay) {
         this.cardPay = cardPay;
     }
 
-    public String getArrearsPay() {
+    public BigDecimal getArrearsPay() {
         return arrearsPay;
     }
 
-    public void setArrearsPay(String arrearsPay) {
+    public void setArrearsPay(BigDecimal arrearsPay) {
         this.arrearsPay = arrearsPay;
     }
 
-    public String getFreeConsumePay() {
+    public BigDecimal getFreeConsumePay() {
         return freeConsumePay;
     }
 
-    public void setFreeConsumePay(String freeConsumePay) {
+    public void setFreeConsumePay(BigDecimal freeConsumePay) {
         this.freeConsumePay = freeConsumePay;
     }
 
-    public String getConsumePay() {
+    public BigDecimal getConsumePay() {
         return consumePay;
     }
 
-    public void setConsumePay(String consumePay) {
+    public void setConsumePay(BigDecimal consumePay) {
         this.consumePay = consumePay;
     }
 
-    public String getRefundCashPay() {
+    public BigDecimal getRefundCashPay() {
         return refundCashPay;
     }
 
-    public void setRefundCashPay(String refundCashPay) {
+    public void setRefundCashPay(BigDecimal refundCashPay) {
         this.refundCashPay = refundCashPay;
     }
 
-    public String getRefundCardPay() {
+    public BigDecimal getRefundCardPay() {
         return refundCardPay;
     }
 
-    public void setRefundCardPay(String refundCardPay) {
+    public void setRefundCardPay(BigDecimal refundCardPay) {
         this.refundCardPay = refundCardPay;
     }
 
-    public String getProductAchieve() {
+    public BigDecimal getProductAchieve() {
         return productAchieve;
     }
 
-    public void setProductAchieve(String productAchieve) {
+    public void setProductAchieve(BigDecimal productAchieve) {
         this.productAchieve = productAchieve;
     }
 
-    public String getCardAchieve() {
+    public BigDecimal getCardAchieve() {
         return cardAchieve;
     }
 
-    public void setCardAchieve(String cardAchieve) {
+    public void setCardAchieve(BigDecimal cardAchieve) {
         this.cardAchieve = cardAchieve;
     }
 
-    public String getRefund() {
+    public BigDecimal getRefund() {
         return refund;
     }
 
-    public void setRefund(String refund) {
+    public void setRefund(BigDecimal refund) {
         this.refund = refund;
     }
 
-    public String getPerCustomCnt() {
+    public BigDecimal getPerCustomCnt() {
         return perCustomCnt;
     }
 
-    public void setPerCustomCnt(String perCustomCnt) {
+    public void setPerCustomCnt(BigDecimal perCustomCnt) {
         this.perCustomCnt = perCustomCnt;
     }
 
-    public String getCustomGoodsCnt() {
-        return new BigDecimal(totalSaleCnt).divide(new BigDecimal(perCustomCnt), 2, BigDecimal.ROUND_DOWN).toPlainString();
+    public BigDecimal getCustomGoodsCnt() {
+        if (BigDecimal.ZERO.compareTo(perCustomCnt) != 0) {
+            return new BigDecimal(totalSaleCnt).divide(perCustomCnt, 2, BigDecimal.ROUND_DOWN);
+        } else {
+            return BigDecimal.ZERO;
+        }
     }
 
-    public void setCustomGoodsCnt(String customGoodsCnt) {
+    public void setCustomGoodsCnt(BigDecimal customGoodsCnt) {
         this.customGoodsCnt = customGoodsCnt;
     }
 
-    public String getPerCustomPrice() {
-        return new BigDecimal(totalPay).divide(new BigDecimal(perCustomCnt), 2, BigDecimal.ROUND_DOWN).toPlainString();
+    public BigDecimal getPerCustomPrice() {
+        if (perCustomCnt.compareTo(BigDecimal.ZERO) != 0) {
+            return totalPay.divide(perCustomCnt, 2, BigDecimal.ROUND_DOWN);
+        } else {
+            return BigDecimal.ZERO;
+        }
     }
 
-    public void setPerCustomPrice(String perCustomPrice) {
+    public void setPerCustomPrice(BigDecimal perCustomPrice) {
         this.perCustomPrice = perCustomPrice;
     }
 
-    public String getCost() {
-        return new BigDecimal(goodsCost).add(new BigDecimal(otherCost)).toPlainString();
+    public BigDecimal getCost() {
+        return goodsCost.add(otherCost);
     }
 
-    public void setCost(String cost) {
+    public void setCost(BigDecimal cost) {
         this.cost = cost;
     }
 
-    public String getGrossProfit() {
-        return new BigDecimal(totalPay).subtract(new BigDecimal(getCost())).toPlainString();
+    public BigDecimal getGrossProfit() {
+        return totalPay.subtract(getCost());
     }
 
-    public void setGrossProfit(String grossProfit) {
+    public void setGrossProfit(BigDecimal grossProfit) {
         this.grossProfit = grossProfit;
     }
 
-    public String getGrossProfitRate() {
-        return new BigDecimal(getGrossProfit()).divide(new BigDecimal(totalPay), 2, BigDecimal.ROUND_DOWN).toPlainString();
+    public BigDecimal getGrossProfitRate() {
+        if (totalPay.compareTo(BigDecimal.ZERO) != 0) {
+            return getGrossProfit().divide(totalPay, 2, BigDecimal.ROUND_DOWN);
+        } else {
+            return BigDecimal.ZERO;
+        }
     }
 
-    public void setGrossProfitRate(String grossProfitRate) {
+    public void setGrossProfitRate(BigDecimal grossProfitRate) {
         this.grossProfitRate = grossProfitRate;
     }
 
-    public String getPeopleCnt() {
+    public BigDecimal getPeopleCnt() {
         return peopleCnt;
     }
 
-    public void setPeopleCnt(String peopleCnt) {
+    public void setPeopleCnt(BigDecimal peopleCnt) {
         this.peopleCnt = peopleCnt;
     }
 
-    public String getProjConsumeCnt() {
+    public BigDecimal getProjConsumeCnt() {
         return projConsumeCnt;
     }
 
-    public void setProjConsumeCnt(String projConsumeCnt) {
+    public void setProjConsumeCnt(BigDecimal projConsumeCnt) {
         this.projConsumeCnt = projConsumeCnt;
     }
 
-    public String getTimeLength() {
+    public BigDecimal getTimeLength() {
         return timeLength;
     }
 
-    public void setTimeLength(String timeLength) {
+    public void setTimeLength(BigDecimal timeLength) {
         this.timeLength = timeLength;
     }
 }
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/dao/SysBusinessDataDao.java b/zq-erp/src/main/java/com/matrix/system/hive/dao/SysBusinessDataDao.java
index 02e755a..cd90f42 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/dao/SysBusinessDataDao.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/dao/SysBusinessDataDao.java
@@ -51,5 +51,5 @@
 
 	int selectApiBusinessDataTotal(@Param("record") SysBusinessData data);
 
-	List<BusinessesDataShowVo> selectDemo(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
+	List<BusinessesDataShowVo> selectApiBusinessData(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
 }
\ No newline at end of file
diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml
index 84736e1..eb9e0c9 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml
@@ -619,10 +619,11 @@
         ) a
     </select>
 
-    <select id="selectDemo" resultType="com.matrix.system.app.vo.BusinessesDataShowVo">
+    <select id="selectApiBusinessData" resultType="com.matrix.system.app.vo.BusinessesDataShowVo">
         <foreach collection="list" index="index" item="item"   separator="union all"  >
             select
-                (select sum(amount) from sys_order_flow
+                #{item.beginTime} dataTime,
+                (select IFNULL(sum(amount),0) from sys_order_flow
                     where <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -631,7 +632,7 @@
                         and company_id=#{companyId}
                     </if>
                     )totalPay,
-                (select sum(amount) from sys_order_flow
+                (select IFNULL(sum(amount),0) from sys_order_flow
                     where pay_method not in ('储值卡', '欠款') and flow_type != '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -640,7 +641,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) cashPay,
-                (select sum(amount) from sys_order_flow
+                (select IFNULL(sum(amount),0) from sys_order_flow
                     where pay_method = '储值卡' and flow_type != '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -649,7 +650,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) cardPay,
-                (select sum(amount) from sys_order_flow
+                (select IFNULL(sum(amount),0) from sys_order_flow
                     where pay_method = '欠款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -658,7 +659,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) arrearsPay,
-                (select sum(amount) from sys_order_flow
+                (select IFNULL(sum(amount),0) from sys_order_flow
                     where pay_method not in ('储值卡', '欠款') and flow_type = '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -667,7 +668,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) refundCashPay,
-                (select sum(amount) from sys_order_flow
+                (select IFNULL(sum(amount),0) from sys_order_flow
                     where pay_method in ('储值卡') and flow_type = '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -676,7 +677,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) refundCardPay,
-                (select sum(a.amount) from sys_order_flow a
+                (select IFNULL(sum(amount),0) from sys_order_flow a
                     inner join sys_order_item b on a.order_id=b.ORDER_ID
                     inner join shopping_goods c on b.goods_id=c.id
                     where c.good_type='家居产品' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]>
@@ -687,7 +688,7 @@
                         and a.company_id=#{companyId}
                     </if>
                     ) productAchieve,
-                (select sum(a.amount) from sys_order_flow a
+                (select IFNULL(sum(amount),0) from sys_order_flow a
                     inner join sys_order_item b on a.order_id=b.ORDER_ID
                     inner join shopping_goods c on b.goods_id=c.id
                     where c.good_type!='家居产品' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]>
@@ -698,7 +699,7 @@
                         and a.company_id=#{companyId}
                     </if>
                     ) cardAchieve,
-                (select sum(amount) from sys_order_flow where flow_type = '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
+                (select IFNULL(sum(amount),0) from sys_order_flow where flow_type = '退款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
                     </if>
@@ -706,7 +707,7 @@
                         and company_id=#{companyId}
                     </if>
                 ) refund,
-                (select count(1) from sys_order
+                (select IFNULL(count(1),0) from sys_order
                     where STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > #{item.beginTime} and ORDER_TIME < #{item.endTime} ]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -715,7 +716,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) perCustomCnt,
-                (select sum(b.COUNT) from sys_order a inner join sys_order_item b on a.ID=b.ORDER_ID
+                (select IFNULL(sum(b.COUNT),0) from sys_order a inner join sys_order_item b on a.ID=b.ORDER_ID
                     where a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > #{item.beginTime} and ORDER_TIME < #{item.endTime} ]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -724,7 +725,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) totalSaleCnt,
-                (select sum(e.count * d.GOODS_PRICE) from sys_order a
+                (select IFNULL(sum(e.count * d.GOODS_PRICE),0) from sys_order a
                     inner join sys_out_store b on a.id=b.ORDER_ID
                     inner join sys_out_store_item c on b.id=c.OUT_STORE_ID
                     inner join sys_store_info d on c.store_id = d.ID
@@ -738,7 +739,7 @@
                         and a.company_id=#{companyId}
                     </if>
                 ) goodsCost,
-                (select sum(b.COUNT * IFNULL(c.price, 0)) from sys_order a
+                (select IFNULL(sum(b.COUNT * IFNULL(c.price, 0)),0) from sys_order a
                     inner join sys_order_item b on a.ID=b.ORDER_ID
                     inner join shopping_goods c on c.good_type != '家居产品' and b.goods_id=c.id
                     where a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > #{item.beginTime} and ORDER_TIME < #{item.endTime} ]]>
@@ -749,7 +750,7 @@
                         and a.company_id=#{companyId}
                     </if>
                 ) otherCost,
-                (select sum(IFNULL(his_consume, 0)) from achieve_new
+                (select IFNULL(sum(IFNULL(his_consume, 0)),0) from achieve_new
                     where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -758,7 +759,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) consumePay,
-                (select sum(IFNULL(free_consume, 0)) from achieve_new
+                (select IFNULL(sum(IFNULL(free_consume, 0)),0) from achieve_new
                     where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -767,7 +768,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) freeConsumePay,
-                (select sum(IFNULL(number_of_people, 0)) from achieve_new
+                (select IFNULL(sum(IFNULL(number_of_people, 0)),0) from achieve_new
                     where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -776,7 +777,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) peopleCnt,
-                (select sum(IFNULL(proj_num, 0)) from achieve_new
+                (select IFNULL(sum(IFNULL(proj_num, 0)),0) from achieve_new
                     where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}
@@ -785,7 +786,7 @@
                         and company_id=#{companyId}
                     </if>
                     ) projConsumeCnt,
-                (select sum(IFNULL(proj_time, 0)) from achieve_new
+                (select IFNULL(sum(IFNULL(proj_time, 0)),0) from achieve_new
                     where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
                     <if test="shopId != null">
                         and shop_id=#{shopId}

--
Gitblit v1.9.1