From eab8cea0dbf3104da6cbb117a604853e5d9f14a0 Mon Sep 17 00:00:00 2001
From: wzy <wzy19931122ai@163.com>
Date: Thu, 14 Jan 2021 23:20:18 +0800
Subject: [PATCH] modify
---
zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java | 20 +++--
zq-erp/src/main/java/com/matrix/system/app/vo/BusinessesDataShowVo.java | 50 +++++++++++-
zq-erp/src/main/java/com/matrix/system/hive/dao/SysBusinessDataDao.java | 6 +
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java | 4 +
zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml | 120 +++++++++++++++++++++++++----
5 files changed, 170 insertions(+), 30 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 3363c1e..6eb5827 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
@@ -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);
+ }
}
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 218f8d1..7806b4f 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
@@ -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) {
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 0aefeb4..f528c9d 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.hiveErp.analysUtil.StatisticsTimeDaoParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@@ -49,5 +50,8 @@
List<BusinessesDataShowVo> selectApiBusinessDataInPage(@Param("record") SysBusinessData data,@Param("pageVo") PaginationVO pageVo);
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();
}
\ 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 7137616..21f8bde 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
@@ -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;
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 14e3086..3bb7a6c 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysBusinessDataDao.xml
@@ -620,28 +620,114 @@
</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,
+ (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
+ </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
+ (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
+ (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 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
- from dual;
+ (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>
\ No newline at end of file
--
Gitblit v1.9.1