wzy
2021-01-14 eab8cea0dbf3104da6cbb117a604853e5d9f14a0
modify
5 files modified
170 ■■■■■ changed files
zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java 20 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/app/vo/BusinessesDataShowVo.java 50 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/dao/SysBusinessDataDao.java 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml 92 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java
@@ -15,10 +15,7 @@
import com.matrix.system.hive.bean.SysBusinessData;
import com.matrix.system.hive.dao.SysBusinessDataDao;
import com.matrix.system.hive.service.imp.DataAnalysisCustomerServiceImpl;
import com.matrix.system.hiveErp.analysUtil.Caculate;
import com.matrix.system.hiveErp.analysUtil.SeriesVo;
import com.matrix.system.hiveErp.analysUtil.StatisticsParamVo;
import com.matrix.system.hiveErp.analysUtil.StatisticsTimeDaoParam;
import com.matrix.system.hiveErp.analysUtil.*;
import com.matrix.system.hiveErp.dao.TjVipSumDao;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -29,10 +26,7 @@
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * @author wzy
@@ -219,4 +213,14 @@
        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);
    }
}
zq-erp/src/main/java/com/matrix/system/app/vo/BusinessesDataShowVo.java
@@ -1,5 +1,6 @@
package com.matrix.system.app.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -75,6 +76,47 @@
    @ApiModelProperty(value = "服务时长")
    private String timeLength;
    /**
     * 当天销售总数量
     */
    @ApiModelProperty(hidden = true)
    private Integer totalSaleCnt;
    /**
     * 家居产品成本
     */
    @ApiModelProperty(hidden = true)
    private String goodsCost;
    /**
     * 除家具产品以外成本
     */
    @ApiModelProperty(hidden = true)
    private String otherCost;
    public Integer getTotalSaleCnt() {
        return totalSaleCnt;
    }
    public void setTotalSaleCnt(Integer totalSaleCnt) {
        this.totalSaleCnt = totalSaleCnt;
    }
    public String getGoodsCost() {
        return goodsCost;
    }
    public void setGoodsCost(String goodsCost) {
        this.goodsCost = goodsCost;
    }
    public String getOtherCost() {
        return otherCost;
    }
    public void setOtherCost(String otherCost) {
        this.otherCost = otherCost;
    }
    public String getDataTime() {
        return dataTime;
@@ -181,7 +223,7 @@
    }
    public String getCustomGoodsCnt() {
        return customGoodsCnt;
        return new BigDecimal(totalSaleCnt).divide(new BigDecimal(perCustomCnt), 2, BigDecimal.ROUND_DOWN).toPlainString();
    }
    public void setCustomGoodsCnt(String customGoodsCnt) {
@@ -197,7 +239,7 @@
    }
    public String getCost() {
        return cost;
        return new BigDecimal(goodsCost).add(new BigDecimal(otherCost)).toPlainString();
    }
    public void setCost(String cost) {
@@ -205,7 +247,7 @@
    }
    public String getGrossProfit() {
        return grossProfit;
        return new BigDecimal(totalPay).subtract(new BigDecimal(getCost())).toPlainString();
    }
    public void setGrossProfit(String grossProfit) {
@@ -213,7 +255,7 @@
    }
    public String getGrossProfitRate() {
        return grossProfitRate;
        return new BigDecimal(getGrossProfit()).divide(new BigDecimal(totalPay), 2, BigDecimal.ROUND_DOWN).toPlainString();
    }
    public void setGrossProfitRate(String grossProfitRate) {
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.hiveErp.analysUtil.StatisticsTimeDaoParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -50,4 +51,7 @@
    int selectApiBusinessDataTotal(@Param("record") SysBusinessData data);
    
    List<BusinessesDataShowVo> selectDemo(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
    List<BusinessesDataShowVo> selectDemo2();
}
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
@@ -221,7 +221,11 @@
        sysOrder.getItems().forEach(sysOrderItem -> {
            sysOrderItem.setOrderId(sysOrder.getId());
            // 取负数
            sysOrderItem.setCount(-sysOrderItem.getCount());
            orderItemDao.insert(sysOrderItem);
            // 调整回来
            sysOrderItem.setCount(-sysOrderItem.getCount());
        });
        return sysOrder;
zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml
@@ -620,7 +620,7 @@
    </select>
    <select id="selectDemo" 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 where shop_id=34 and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00')]]> totalPay,
        (select sum(amount) from sys_order_flow where shop_id=34 and pay_method not in ('储值卡', '欠款') and flow_type != '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00')]]> cashPay,
@@ -640,8 +640,94 @@
        (select count(1) from sys_order where shop_id=34 and STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00' ]]>) perCustomCnt,
        (select sum(b.COUNT) from sys_order a inner join sys_order_item b on a.ID=b.ORDER_ID
        where a.SHOP_ID=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00' ]]>) totalSaleCnt
        from dual;
                    where a.SHOP_ID=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00' ]]>) totalSaleCnt,
                (select sum(e.count * d.GOODS_PRICE) 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.shop_id=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00']]>
                ) goodsCost,
                (select sum(b.COUNT * IFNULL(c.price, 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 != '家居产品'
                    where a.shop_id=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00']]>
                ) otherCost
            from dual
        </foreach>
    </select>
    <select id="selectDemo2" resultType="com.matrix.system.app.vo.BusinessesDataShowVo">
        select
            (select sum(amount) from sys_order_flow where shop_id=34 and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00')]]> totalPay,
            (select sum(amount) from sys_order_flow where shop_id=34 and pay_method not in ('储值卡', '欠款') and flow_type != '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00')]]> cashPay,
            (select sum(amount) from sys_order_flow where shop_id=34 and pay_method = '储值卡' and flow_type != '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) cardPay,
                                                        (select sum(amount) from sys_order_flow where shop_id=34 and pay_method = '欠款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) arrearsPay,
                                                                                                    (select sum(amount) from sys_order_flow where shop_id=34 and pay_method not in ('储值卡', '欠款') and flow_type = '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) refundCashPay,
                                                                                                                                                (select sum(amount) from sys_order_flow where shop_id=34 and pay_method in ('储值卡') and flow_type = '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) refundCardPay,
                                                                                                                                                                                            (select sum(a.amount) 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 a.shop_id=34 and <![CDATA[ a.create_time > '2021-01-13 00:00:00' and a.create_time < '2021-01-14 00:00:00']]> ) productAchieve,
            (select sum(a.amount) 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 a.shop_id=34 and <![CDATA[ a.create_time > '2021-01-13 00:00:00' and a.create_time < '2021-01-14 00:00:00']]> ) cardAchieve,
            (select sum(amount) from sys_order_flow where shop_id=34 and flow_type = '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) refund,
                                                        (select count(1) from sys_order where shop_id=34 and STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00' ]]>) perCustomCnt,
                                                                                            (select sum(b.COUNT) from sys_order a inner join sys_order_item b on a.ID=b.ORDER_ID
        where a.SHOP_ID=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00' ]]>) totalSaleCnt,
            (select sum(e.count * d.GOODS_PRICE) 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.shop_id=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00']]>
            ) goodsCost,
            (select sum(b.COUNT * IFNULL(c.price, 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 != '家居产品'
        where a.shop_id=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00']]>
            ) otherCost
        from dual
        union all
        select
            (select sum(amount) from sys_order_flow where shop_id=34 and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00')]]> totalPay,
            (select sum(amount) from sys_order_flow where shop_id=34 and pay_method not in ('储值卡', '欠款') and flow_type != '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00')]]> cashPay,
            (select sum(amount) from sys_order_flow where shop_id=34 and pay_method = '储值卡' and flow_type != '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) cardPay,
                                                        (select sum(amount) from sys_order_flow where shop_id=34 and pay_method = '欠款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) arrearsPay,
                                                                                                    (select sum(amount) from sys_order_flow where shop_id=34 and pay_method not in ('储值卡', '欠款') and flow_type = '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) refundCashPay,
                                                                                                                                                (select sum(amount) from sys_order_flow where shop_id=34 and pay_method in ('储值卡') and flow_type = '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) refundCardPay,
                                                                                                                                                                                            (select sum(a.amount) 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 a.shop_id=34 and <![CDATA[ a.create_time > '2021-01-13 00:00:00' and a.create_time < '2021-01-14 00:00:00']]> ) productAchieve,
            (select sum(a.amount) 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 a.shop_id=34 and <![CDATA[ a.create_time > '2021-01-13 00:00:00' and a.create_time < '2021-01-14 00:00:00']]> ) cardAchieve,
            (select sum(amount) from sys_order_flow where shop_id=34 and flow_type = '退款' and <![CDATA[ create_time > '2021-01-13 00:00:00' and create_time < '2021-01-14 00:00:00' ]]>) refund,
                                                        (select count(1) from sys_order where shop_id=34 and STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00' ]]>) perCustomCnt,
                                                                                            (select sum(b.COUNT) from sys_order a inner join sys_order_item b on a.ID=b.ORDER_ID
        where a.SHOP_ID=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00' ]]>) totalSaleCnt,
            (select sum(e.count * d.GOODS_PRICE) 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.shop_id=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00']]>
            ) goodsCost,
            (select sum(b.COUNT * IFNULL(c.price, 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 != '家居产品'
        where a.shop_id=34 and a.STATU in ('已付款', '欠款') and <![CDATA[ORDER_TIME > '2021-01-13 00:00:00' and ORDER_TIME < '2021-01-14 00:00:00']]>
            ) otherCost
        from dual
    </select>
</mapper>