Helius
2021-01-18 fc46f2a7c6680df278f4c68c5e91a0ce544a2de4
modify
4 files modified
71 ■■■■ changed files
zq-erp/src/main/java/com/matrix/system/hive/statistics/DailySaleVo.java 10 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/statistics/SysBusinessDataAction.java 28 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml 17 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/hive/statistics/daily-sale-list.html 16 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/statistics/DailySaleVo.java
@@ -18,6 +18,8 @@
    private String shopName;
    private BigDecimal shouldPay;
    private BigDecimal totalPay;
    private BigDecimal cashPay;
@@ -100,6 +102,14 @@
    private Long shopId;
    public BigDecimal getShouldPay() {
        return shouldPay;
    }
    public void setShouldPay(BigDecimal shouldPay) {
        this.shouldPay = shouldPay;
    }
    public BigDecimal getWechat() {
        return wechat;
    }
zq-erp/src/main/java/com/matrix/system/hive/statistics/SysBusinessDataAction.java
@@ -60,22 +60,46 @@
    @RequestMapping(value = "/findDailySaleData")
    @ResponseBody
    public AjaxResult findDailySaleData(DailySaleVo dailySaleVo, PaginationVO pageVo) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        Calendar calendar = Calendar.getInstance();
        int total = 999;
        Date endDate = new Date();
        if (dailySaleVo.getEndTime() != null) {
            if (!dailySaleVo.getEndTime().after(new Date())) {
                calendar.setTime(dailySaleVo.getEndTime());
                endDate = DateUtil.nextNDate(dailySaleVo.getEndTime(), 1);
            }
        }
        calendar.add(Calendar.DATE, 1);
        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);
        if (dailySaleVo.getBeginTime() != null) {
            Date startDate = DateUtil.stringToDate(startTime, DateUtil.DATE_FORMAT_DD);
            if(dailySaleVo.getBeginTime().after(startDate)) {
                startTime = DateUtil.dateFormatStr(dailySaleVo.getBeginTime(), DateUtil.DATE_FORMAT_DD);
            }
            long sub = DateUtil.getTimeSpan(dailySaleVo.getBeginTime(), endDate, null);
            Long l = sub / (1000 * 3600 * 24);
            total = l.intValue();
        }
        List<Date> xAxis = StatisticsTimeUtil.getTimeSpace(startTime, endTime, "日");
        List<StatisticsTimeDaoParam> timeSpaceParam = StatisticsTimeUtil.buidParam(xAxis);
        List<StatisticsTimeDaoParam> statisticsTimeDaoParams = timeSpaceParam.subList(0, timeSpaceParam.size() - 2);
        if (dailySaleVo.getShopId() == null) {
            dailySaleVo.setShopId(user.getShopId());
        }
        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);
        return AjaxResult.buildSuccessInstance(result, total);
    }
}
zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml
@@ -804,11 +804,18 @@
        <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 sum(total) shouldPay from sys_order
                where STATU = '已付款' and <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]>
                <if test="shopId != null">
                    and shop_id=#{shopId}
                </if>
                ) shouldPay,
            (select IFNULL(sum(amount),0) from sys_order_flow
            where <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]> and pay_method!='欠款'
            <if test="shopId != null">
                and shop_id=#{shopId}
            </if>
                where <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime}]]> and pay_method!='欠款'
                <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}]]>
@@ -932,7 +939,7 @@
        from sys_order_flow
        where <![CDATA[ create_time > #{item.beginTime} and create_time < #{item.endTime} ]]>
        <if test="shopId != null">
            and a.shop_id=#{shopId}
            and shop_id=#{shopId}
        </if>
        group by paymethod
    </sql>
zq-erp/src/main/resources/templates/views/admin/hive/statistics/daily-sale-list.html
@@ -53,9 +53,9 @@
                        data-width="30px">序号</th>
                    <th data-field="dataTime">日期</th>
                    <th data-field="shopName">门店名称</th>
                    <th data-field="totalPay">应收金额</th>
                    <th data-field="shouldPay" data-formatter="shouldPayFormat">应收金额</th>
                    <th data-field="totalPay">实收金额</th>
                    <th data-field="hisConsume">折扣金额</th>
                    <th data-field="shouldPay" data-formatter="zkAmountFormat">折扣金额</th>
                    <th data-field="perCustomCnt">客单数</th>
                    <th data-field="customGoodsCnt">客品数</th>
                    <th data-field="cost">成本</th>
@@ -79,8 +79,8 @@
    <script type="text/javascript">
        var myGrid;
        var initParam = {
                format : "yyyy-mm-dd hh:ii", //默认显示年与日,如果想显示十分秒:"yyyy-mm-dd hh:ii:ss"
                minView: "hour",     //"month",只显示年月日的选择,不会再跳转去选择时分秒;如果想要选择时分秒的:"hour"
                format : "yyyy-mm-dd", //默认显示年与日,如果想显示十分秒:"yyyy-mm-dd hh:ii:ss"
                minView: "month",     //"month",只显示年月日的选择,不会再跳转去选择时分秒;如果想要选择时分秒的:"hour"
            }
         MTools.ininDatetimepicker(initParam);
        //限制结束时间不小于开始时间
@@ -111,6 +111,14 @@
        });
        function shouldPayFormat(value, row, index) {
            return row.shouldPay + row.refund;
        }
        function zkAmountFormat(value, row, index) {
            return row.shouldPay + row.refund - row.arrears - row.totalPay;
        }
        function footCountTitle(data) {
            return "<b>合计</b>";
        };