From 19fb7fa1fdbcee7cecfee1554610bb40f40e2976 Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Fri, 15 Jan 2021 23:38:25 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/api' into api

---
 zq-erp/src/main/resources/templates/views/admin/hive/statistics/daily-sale-list.html |  149 +++++++++++
 zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java                 |   15 
 zq-erp/src/main/java/com/matrix/system/hive/statistics/DailySaleVo.java              |  402 ++++++++++++++++++++++++++++++
 zq-erp/src/main/java/com/matrix/system/hive/statistics/SysBusinessDataAction.java    |   33 ++
 zq-erp/src/main/java/com/matrix/system/hive/dao/SysBusinessDataDao.java              |    3 
 zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java     |    2 
 zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml                 |  137 ++++++++++
 7 files changed, 737 insertions(+), 4 deletions(-)

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 cd90f42..5b94366 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
@@ -4,6 +4,7 @@
 import com.matrix.system.app.vo.BusinessesDataShowVo;
 import com.matrix.system.hive.bean.SysBusinessData;
 import com.matrix.system.hive.statistics.BusinessDataShowVo;
+import com.matrix.system.hive.statistics.DailySaleVo;
 import com.matrix.system.hiveErp.analysUtil.StatisticsTimeDaoParam;
 import org.apache.ibatis.annotations.Param;
 
@@ -52,4 +53,6 @@
 	int selectApiBusinessDataTotal(@Param("record") SysBusinessData data);
 
 	List<BusinessesDataShowVo> selectApiBusinessData(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
+
+	List<DailySaleVo> selectDailySaleData(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId);
 }
\ No newline at end of file
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
index 21f8bde..41b857e 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
@@ -798,6 +798,8 @@
             }
 
             refundTotal += flow.getAmount().doubleValue();
+            flow.setShopId(sourceOrder.getShopId());
+            flow.setCompanyId(sourceOrder.getCompanyId());
             sysOrderFlowDao.insert(flow);
             i++;
         }
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/statistics/DailySaleVo.java b/zq-erp/src/main/java/com/matrix/system/hive/statistics/DailySaleVo.java
new file mode 100644
index 0000000..743bd33
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/hive/statistics/DailySaleVo.java
@@ -0,0 +1,402 @@
+package com.matrix.system.hive.statistics;
+
+import com.matrix.core.anotations.Extend;
+import com.matrix.core.tools.DateUtil;
+import io.swagger.annotations.ApiModelProperty;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author wzy
+ * @date 2021-01-15
+ **/
+public class DailySaleVo {
+
+    private String dataTime;
+
+    private String shopName;
+
+    private BigDecimal totalPay;
+
+    private BigDecimal cashPay;
+
+    private BigDecimal cardPay;
+
+    private BigDecimal arrearsPay;
+
+    private BigDecimal refundCashPay;
+
+    private BigDecimal refundCardPay;
+
+    private BigDecimal productAchieve;
+
+    private BigDecimal cardAchieve;
+
+    private BigDecimal refund;
+
+    private BigDecimal perCustomCnt;
+
+    private BigDecimal customGoodsCnt;
+
+    private BigDecimal perCustomPrice;
+
+    private BigDecimal cost;
+
+    private BigDecimal grossProfit;
+
+    private BigDecimal grossProfitRate;
+
+    private BigDecimal consumePay;
+
+    private BigDecimal freeConsumePay;
+
+    private BigDecimal peopleCnt;
+
+    private BigDecimal projConsumeCnt;
+
+    private BigDecimal timeLength;
+
+    /**
+     * 当天销售总数量
+     */
+    private Integer totalSaleCnt;
+
+    /**
+     * 家居产品成本
+     */
+    private BigDecimal goodsCost;
+
+    /**
+     * 除家具产品以外成本
+     */
+    private BigDecimal otherCost;
+
+    private BigDecimal wechat;
+
+    private BigDecimal alipay;
+
+    private BigDecimal cash;
+
+    private BigDecimal bankCard;
+
+    private BigDecimal tuan;
+
+    private BigDecimal cardBj;
+
+    private BigDecimal cardFree;
+
+    private BigDecimal arrears;
+
+    @Extend
+    @DateTimeFormat(pattern = DateUtil.DATE_FORMAT_DD)
+
+    private Date beginTime;
+
+    @Extend
+    @DateTimeFormat(pattern = DateUtil.DATE_FORMAT_DD)
+    private Date endTime;
+
+    private Long shopId;
+
+    public BigDecimal getWechat() {
+        return wechat;
+    }
+
+    public void setWechat(BigDecimal wechat) {
+        this.wechat = wechat;
+    }
+
+    public BigDecimal getAlipay() {
+        return alipay;
+    }
+
+    public void setAlipay(BigDecimal alipay) {
+        this.alipay = alipay;
+    }
+
+    public BigDecimal getCash() {
+        return cash;
+    }
+
+    public void setCash(BigDecimal cash) {
+        this.cash = cash;
+    }
+
+    public BigDecimal getBankCard() {
+        return bankCard;
+    }
+
+    public void setBankCard(BigDecimal bankCard) {
+        this.bankCard = bankCard;
+    }
+
+    public BigDecimal getTuan() {
+        return tuan;
+    }
+
+    public void setTuan(BigDecimal tuan) {
+        this.tuan = tuan;
+    }
+
+    public BigDecimal getCardBj() {
+        return cardBj;
+    }
+
+    public void setCardBj(BigDecimal cardBj) {
+        this.cardBj = cardBj;
+    }
+
+    public BigDecimal getCardFree() {
+        return cardFree;
+    }
+
+    public void setCardFree(BigDecimal cardFree) {
+        this.cardFree = cardFree;
+    }
+
+    public BigDecimal getArrears() {
+        return arrears;
+    }
+
+    public void setArrears(BigDecimal arrears) {
+        this.arrears = arrears;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+
+    public Date getBeginTime() {
+        return beginTime;
+    }
+
+    public void setBeginTime(Date beginTime) {
+        this.beginTime = beginTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public Long getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Long shopId) {
+        this.shopId = shopId;
+    }
+
+    public Integer getTotalSaleCnt() {
+        return totalSaleCnt;
+    }
+
+    public void setTotalSaleCnt(Integer totalSaleCnt) {
+        this.totalSaleCnt = totalSaleCnt;
+    }
+
+    public BigDecimal getGoodsCost() {
+        return goodsCost;
+    }
+
+    public void setGoodsCost(BigDecimal goodsCost) {
+        this.goodsCost = goodsCost;
+    }
+
+    public BigDecimal getOtherCost() {
+        return otherCost;
+    }
+
+    public void setOtherCost(BigDecimal otherCost) {
+        this.otherCost = otherCost;
+    }
+
+    public String getDataTime() {
+        return DateUtil.dateToString(DateUtil.stringToDate(dataTime, DateUtil.DATE_FORMAT_DD),DateUtil.DATE_FORMAT_DD);
+    }
+
+    public void setDataTime(String dataTime) {
+        this.dataTime = dataTime;
+    }
+
+    public BigDecimal getTotalPay() {
+        return totalPay;
+    }
+
+    public void setTotalPay(BigDecimal totalPay) {
+        this.totalPay = totalPay;
+    }
+
+    public BigDecimal getCashPay() {
+        return cashPay;
+    }
+
+    public void setCashPay(BigDecimal cashPay) {
+        this.cashPay = cashPay;
+    }
+
+    public BigDecimal getCardPay() {
+        return cardPay;
+    }
+
+    public void setCardPay(BigDecimal cardPay) {
+        this.cardPay = cardPay;
+    }
+
+    public BigDecimal getArrearsPay() {
+        return arrearsPay;
+    }
+
+    public void setArrearsPay(BigDecimal arrearsPay) {
+        this.arrearsPay = arrearsPay;
+    }
+
+    public BigDecimal getFreeConsumePay() {
+        return freeConsumePay;
+    }
+
+    public void setFreeConsumePay(BigDecimal freeConsumePay) {
+        this.freeConsumePay = freeConsumePay;
+    }
+
+    public BigDecimal getConsumePay() {
+        return consumePay;
+    }
+
+    public void setConsumePay(BigDecimal consumePay) {
+        this.consumePay = consumePay;
+    }
+
+    public BigDecimal getRefundCashPay() {
+        return refundCashPay;
+    }
+
+    public void setRefundCashPay(BigDecimal refundCashPay) {
+        this.refundCashPay = refundCashPay;
+    }
+
+    public BigDecimal getRefundCardPay() {
+        return refundCardPay;
+    }
+
+    public void setRefundCardPay(BigDecimal refundCardPay) {
+        this.refundCardPay = refundCardPay;
+    }
+
+    public BigDecimal getProductAchieve() {
+        return productAchieve;
+    }
+
+    public void setProductAchieve(BigDecimal productAchieve) {
+        this.productAchieve = productAchieve;
+    }
+
+    public BigDecimal getCardAchieve() {
+        return cardAchieve;
+    }
+
+    public void setCardAchieve(BigDecimal cardAchieve) {
+        this.cardAchieve = cardAchieve;
+    }
+
+    public BigDecimal getRefund() {
+        return refund;
+    }
+
+    public void setRefund(BigDecimal refund) {
+        this.refund = refund;
+    }
+
+    public BigDecimal getPerCustomCnt() {
+        return perCustomCnt;
+    }
+
+    public void setPerCustomCnt(BigDecimal perCustomCnt) {
+        this.perCustomCnt = perCustomCnt;
+    }
+
+    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(BigDecimal customGoodsCnt) {
+        this.customGoodsCnt = customGoodsCnt;
+    }
+
+    public BigDecimal getPerCustomPrice() {
+        if (perCustomCnt.compareTo(BigDecimal.ZERO) != 0) {
+            return totalPay.divide(perCustomCnt, 2, BigDecimal.ROUND_DOWN);
+        } else {
+            return BigDecimal.ZERO;
+        }
+    }
+
+    public void setPerCustomPrice(BigDecimal perCustomPrice) {
+        this.perCustomPrice = perCustomPrice;
+    }
+
+    public BigDecimal getCost() {
+        return goodsCost.add(otherCost);
+    }
+
+    public void setCost(BigDecimal cost) {
+        this.cost = cost;
+    }
+
+    public BigDecimal getGrossProfit() {
+        return totalPay.subtract(getCost());
+    }
+
+    public void setGrossProfit(BigDecimal grossProfit) {
+        this.grossProfit = grossProfit;
+    }
+
+    public BigDecimal getGrossProfitRate() {
+        if (totalPay.compareTo(BigDecimal.ZERO) != 0) {
+            return getGrossProfit().divide(totalPay, 2, BigDecimal.ROUND_DOWN);
+        } else {
+            return BigDecimal.ZERO;
+        }
+    }
+
+    public void setGrossProfitRate(BigDecimal grossProfitRate) {
+        this.grossProfitRate = grossProfitRate;
+    }
+
+    public BigDecimal getPeopleCnt() {
+        return peopleCnt;
+    }
+
+    public void setPeopleCnt(BigDecimal peopleCnt) {
+        this.peopleCnt = peopleCnt;
+    }
+
+    public BigDecimal getProjConsumeCnt() {
+        return projConsumeCnt;
+    }
+
+    public void setProjConsumeCnt(BigDecimal projConsumeCnt) {
+        this.projConsumeCnt = projConsumeCnt;
+    }
+
+    public BigDecimal getTimeLength() {
+        return timeLength;
+    }
+
+    public void setTimeLength(BigDecimal timeLength) {
+        this.timeLength = timeLength;
+    }
+}
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/statistics/SysBusinessDataAction.java b/zq-erp/src/main/java/com/matrix/system/hive/statistics/SysBusinessDataAction.java
index 1cd802f..0b2fa69 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/statistics/SysBusinessDataAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/statistics/SysBusinessDataAction.java
@@ -3,15 +3,21 @@
 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.common.bean.SysUsers;
 import com.matrix.system.common.constance.AppConstance;
 import com.matrix.system.hive.dao.SysBusinessDataDao;
+import com.matrix.system.hiveErp.analysUtil.StatisticsTimeDaoParam;
+import com.matrix.system.hiveErp.analysUtil.StatisticsTimeUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -44,5 +50,32 @@
         return result;
     }
 
+    /**
+     * 日销售汇总
+     *
+     * @param dailySaleVo
+     * @param pageVo
+     * @return
+     */
+    @RequestMapping(value = "/findDailySaleData")
+    @ResponseBody
+    public AjaxResult findDailySaleData(DailySaleVo dailySaleVo, PaginationVO pageVo) {
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.add(Calendar.DATE, -pageVo.getOffset());
+        String endTime = DateUtil.dateToString(calendar.getTime(), DateUtil.DATE_FORMAT_DD);
+        calendar.add(Calendar.DATE, -pageVo.getLimit());
+        String startTime = DateUtil.dateToString(calendar.getTime(), DateUtil.DATE_FORMAT_DD);
+        List<Date> xAxis = StatisticsTimeUtil.getTimeSpace(startTime, endTime, "日");
+        List<StatisticsTimeDaoParam> timeSpaceParam = StatisticsTimeUtil.buidParam(xAxis);
+        List<StatisticsTimeDaoParam> statisticsTimeDaoParams = timeSpaceParam.subList(0, timeSpaceParam.size() - 2);
+
+        List<DailySaleVo> dailySaleVos = sysBusinessDataDao.selectDailySaleData(statisticsTimeDaoParams, dailySaleVo.getShopId());
+        List<DailySaleVo> result = new ArrayList<>();
+        for (int i = dailySaleVos.size() - 1; i >= 0; i--) {
+            result.add(dailySaleVos.get(i));
+        }
+        return AjaxResult.buildSuccessInstance(result);
+    }
 
 }
\ No newline at end of file
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java
index 944bb09..2fbc032 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java
@@ -8,10 +8,7 @@
 import com.matrix.system.common.constance.AppConstance;
 import com.matrix.system.common.dao.BusParameterSettingsDao;
 import com.matrix.system.constance.Dictionary;
-import com.matrix.system.hive.bean.ShoppingGoods;
-import com.matrix.system.hive.bean.SysOrder;
-import com.matrix.system.hive.bean.SysOrderItem;
-import com.matrix.system.hive.bean.SysVipInfo;
+import com.matrix.system.hive.bean.*;
 import com.matrix.system.hive.dao.SysOrderDao;
 import com.matrix.system.hive.dao.SysOrderItemDao;
 import com.matrix.system.hive.dao.SysVipInfoDao;
@@ -30,6 +27,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -193,6 +191,15 @@
         // 设置销量
         orderService.setShopSelCount(sourceOrder);
 
+        SysOrderFlow flow = new SysOrderFlow();
+        flow.setAmount(orderDto.getOrderMoney());
+        flow.setPayMethod("微信");
+
+        List<SysOrderFlow> flows = new ArrayList<>();
+        flows.add(flow);
+        sourceOrder.setFlows(flows);
+        orderService.updateAfterMoney(sourceOrder);
+
     }
 
 
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 eb9e0c9..bd84c02 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml
@@ -623,6 +623,7 @@
         <foreach collection="list" index="index" item="item"   separator="union all"  >
             select
                 #{item.beginTime} dataTime,
+                (select shop_short_name from sys_shop_info where id=#{shopId}) shopName,
                 (select IFNULL(sum(amount),0) from sys_order_flow
                     where <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
                     <if test="shopId != null">
@@ -799,4 +800,140 @@
         </foreach>
     </select>
 
+    <select id="selectDailySaleData" resultType="com.matrix.system.hive.statistics.DailySaleVo">
+        <foreach collection="list" index="index" item="item"   separator="union all"  >
+            select
+            #{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}
+            </if>
+            )totalPay,
+            (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}
+            </if>
+            ) cashPay,
+            (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}
+            </if>
+            ) cardPay,
+            (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}
+            </if>
+            ) arrearsPay,
+            (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}
+            </if>
+            ) refundCashPay,
+            (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}
+            </if>
+            ) refundCardPay,
+            (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}]]>
+            <if test="shopId != null">
+                and a.shop_id=#{shopId}
+            </if>
+            ) productAchieve,
+            (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}]]>
+            <if test="shopId != null">
+                and a.shop_id=#{shopId}
+            </if>
+            ) cardAchieve,
+            (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>
+            ) refund,
+            (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}
+            </if>
+            ) perCustomCnt,
+            (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}
+            </if>
+            ) totalSaleCnt,
+            (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
+            inner join sys_order_item e on a.ID=e.ORDER_ID
+            inner join shopping_goods f on e.goods_id=f.id and f.good_type='家居产品'
+            where a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > #{item.beginTime} and ORDER_TIME < #{item.endTime} ]]>
+            <if test="shopId != null">
+                and a.shop_id=#{shopId}
+            </if>
+            ) goodsCost,
+            (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} ]]>
+            <if test="shopId != null">
+                and a.shop_id=#{shopId}
+            </if>
+            ) otherCost,
+            (select  sum(case a.paymethod when '微信' then amount else 0 end) wechat
+                from (<include refid="dailySaleFlow"></include>) a
+            ) wechat,
+            (select
+                sum(case a.paymethod when '支付宝' then amount else 0 end) alipay
+                from (<include refid="dailySaleFlow"></include>) a
+            ) alipay,
+            (select
+                sum(case a.paymethod when '现金支付' then amount else 0 end) cash
+                from (<include refid="dailySaleFlow"></include>) a
+            ) cash,
+            (select
+                sum(case a.paymethod when '银行卡' then amount else 0 end) bankCard
+                from (<include refid="dailySaleFlow"></include>) a
+            ) bankCard,
+            (select
+                sum(case a.paymethod when '团购' then amount else 0 end) tuan
+                from (<include refid="dailySaleFlow"></include>) a
+            ) tuan,
+            (select
+                sum(case a.paymethod when '本金收款' then amount else 0 end) cardBj
+                from (<include refid="dailySaleFlow"></include>) a
+            ) cardBj,
+            (select
+                sum(case a.paymethod when '赠金收款' then amount else 0 end) cardFree
+            from (<include refid="dailySaleFlow"></include>) a
+            ) cardFree,
+            (select
+                sum(case a.paymethod when '欠款' then amount else 0 end) arrears
+            from (<include refid="dailySaleFlow"></include>) a
+            ) arrears
+            from dual
+        </foreach>
+    </select>
+
+    <sql id="dailySaleFlow">
+        select sum(amount) amount, case when is_gift = 'Y' then '赠金收款' when is_gift='N' then '本金收款' else pay_method end paymethod
+        from sys_order_flow
+        where <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime} ]]>
+        <if test="shopId != null">
+            and a.shop_id=#{shopId}
+        </if>
+        group by paymethod
+    </sql>
 </mapper>
\ No newline at end of file
diff --git a/zq-erp/src/main/resources/templates/views/admin/hive/statistics/daily-sale-list.html b/zq-erp/src/main/resources/templates/views/admin/hive/statistics/daily-sale-list.html
new file mode 100644
index 0000000..4d459b9
--- /dev/null
+++ b/zq-erp/src/main/resources/templates/views/admin/hive/statistics/daily-sale-list.html
@@ -0,0 +1,149 @@
+
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml">
+<head>
+<meta charset="utf-8">
+<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
+<meta name="renderer" content="webkit|ie-comp|ie-stand">
+<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+<meta name="viewport"
+	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
+<meta http-equiv="Cache-Control" content="no-siteapp" />
+<LINK rel="Bookmark" href="../images/favicon.ico">
+<!-- 本框架基本脚本和样式 -->
+<script type="text/javascript"
+        th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
+<script type="text/javascript" th:src="@{/js/systools/MBase.js}"></script>
+ 
+</head>
+<body class="gray-bg">
+	 
+
+	<div class="ibox-content">
+		<!-- 搜索框部分start -->
+		<form class="form-inline" id="serchform">
+			<div class="form-group mr-20">
+				<label>日期范围</label>
+				<input name="beginTime" type="text" class="form-control datetimepicker" id="beginTime">-
+				<input name="endTime"  type="text" class="form-control datetimepicker" id="endTime">
+			</div>
+
+			<div class="form-group mr-20">
+				<label>门店</label>
+				<select class="form-control autoFull" data-filed="shopName" name="shopId" id="shopId"
+						th:data-url="@{/admin/shopInfo/findAllWithPermi}">
+					<option value=''>--请选择部所属门店--</option>
+				</select>
+			</div>
+
+			<div class="row mb-10">
+				<div class="col-sm-8">
+					<button  onclick="myGrid.serchData()" type="button" class="btn btn-info btn-sm"><i class="fa fa-search" ></i> 搜索</button>
+					<button  type="reset"   class="btn btn-default btn-sm"><i class="fa fa-refresh " ></i> 重置</button>
+<!--					<button  matrix:btn="ygyjbb-exportExcel"  onclick="exportExcel()" type="button" class="btn btn-default btn-sm"><i class="fa fa-download" ></i> 导出</button>-->
+				</div>
+			</div>
+		</form>
+
+
+		<table id="mgrid">
+			<thead>
+				<tr>
+					<th data-formatter="MGrid.indexfn" data-align="center"
+						data-width="30px">序号</th>
+					<th data-field="dataTime">日期</th>
+					<th data-field="shopName">门店名称</th>
+					<th data-field="totalPay">应收金额</th>
+					<th data-field="totalPay">实收金额</th>
+					<th data-field="hisConsume">折扣金额</th>
+					<th data-field="perCustomCnt">客单数</th>
+					<th data-field="customGoodsCnt">客品数</th>
+					<th data-field="cost">成本</th>
+					<th data-field="grossProfit">毛利</th>
+					<th data-field="grossProfitRate">毛利率</th>
+					<th data-field="wechat">微信</th>
+					<th data-field="alipay">支付宝</th>
+					<th data-field="cash">现金</th>
+					<th data-field="bankCard">银行卡</th>
+					<th data-field="tuan">团购</th>
+					<th data-field="cardBj">本金收款</th>
+					<th data-field="cardFree">赠金收款</th>
+					<th data-field="arrears">欠款</th>
+				</tr>
+			</thead>
+		</table>
+	</div>
+
+	<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script>
+	<script type="text/javascript" th:src="@{/js/function/public.js}"></script>
+	<script type="text/javascript">
+		var myGrid;
+		var initParam = {
+				format : "yyyy-mm-dd hh:ii", //默认显示年与日,如果想显示十分秒:"yyyy-mm-dd hh:ii:ss"
+				minView: "hour", 	//"month",只显示年月日的选择,不会再跳转去选择时分秒;如果想要选择时分秒的:"hour"
+			}
+		 MTools.ininDatetimepicker(initParam);
+		//限制结束时间不小于开始时间
+		 MTools.limitStartEndTime({});
+
+		$(function() {
+			MTools.autoFullSelect();
+			$(".select2").select2();
+			myGrid = MGrid.initGrid({
+				url : basePath+"/admin/sysBusinessData/findDailySaleData",
+				showExport : true,
+				showFooter : false,
+				height:'auto',
+				width:'auto',
+				exportDataType : "basic", //basic', 'all', 'selected'.
+				exportTypes : [ 'excel', 'xlsx' ], //导出类型
+				exportOptions : {
+					ignoreColumn : [ 0 ],
+					fileName : "客户消费统计" + MTools.getTime(), //文件名称设置
+					worksheetName : 'Sheet1', //表格工作区名称  
+					tableName : '客户消费统计',
+					excelstyles : [ 'background-color', 'color', 'font-size',
+							'font-weight' ],
+				}
+			});
+
+			$('[data-toggle="tooltip"]').tooltip()
+
+		});
+
+		function footCountTitle(data) {
+			return "<b>合计</b>";
+		};
+		function countColumn(data) {
+			if (data) {
+				var resultsumQuantity = parseFloat(data).toFixed(2);//保留有效数字
+				return resultsumQuantity;
+			} else {
+				return "-";
+			}
+		};
+
+		function buildVipNameJump(value, row, index) {
+			return '<a  onClick="vipDetail(\'' + row.t9 +'\')"   class="text-primary " >'+value+'</a>';
+		}
+
+		function vipDetail(value) {
+			layer.full(layer.open({
+				type : 2,
+				title : "订单详情",
+				maxmin : true,
+				area : MUI.SIZE_M,
+				content : [basePath+'/admin/redirect/hive/beautySalon/vip?vipPhone=' + value ]
+			}));
+		}
+
+		function exportExcel(){
+
+			var param=MForm.toUrlParam("#serchform");
+
+			window.location.href=basePath+"/admin/achieve/exportDailyInfoNew?"+param;
+		}
+		
+	</script>
+</body>
+</html>

--
Gitblit v1.9.1