From 9b55f87ffe20ff8069d8869ea0b43393af6303f0 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Wed, 30 Dec 2020 16:52:32 +0800
Subject: [PATCH] modify
---
zq-erp/src/main/java/com/matrix/system/hiveErp/dao/TjVipSumDao.java | 10 ++
zq-erp/src/main/java/com/matrix/system/app/action/ApiStatisticsAction.java | 62 +++++++++++++-
zq-erp/src/main/java/com/matrix/system/hiveErp/analysUtil/StatisticsParamVo.java | 16 ++++
zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml | 101 +++++++++++++++++++++++++
4 files changed, 181 insertions(+), 8 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 60d4d22..555340e 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
@@ -17,6 +17,7 @@
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
@@ -68,13 +69,60 @@
@ApiOperation(value = "专项 - 营业收入", notes = "专项 - 营业收入")
@PostMapping(value = "/findBusinessInCome")
- public AjaxResult findBusinessInCome(@RequestBody StatisticsParamVo statisticsParam) {
- return dataAnalysisCustomerService.getAnalysisResult(statisticsParam, new Caculate<BigDecimal>() {
- @Override
- public Map<String, BigDecimal> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId, Long companyId) {
- return tjVipSumDao.selectBusinessInCome(timeSpaceParam, shopId, null);
- }
- });
+ public AjaxResult findBusinessInCome(@RequestBody @Validated StatisticsParamVo statisticsParam) {
+ if (statisticsParam.getShopId() != null) {
+ return dataAnalysisCustomerService.getAnalysisResult(statisticsParam, new Caculate<BigDecimal>() {
+ @Override
+ public Map<String, BigDecimal> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId, Long companyId) {
+ switch (statisticsParam.getType()) {
+ case "1" :
+ return tjVipSumDao.selectBusinessInCome(timeSpaceParam, shopId, null);
+ case "2" :
+ return tjVipSumDao.selectCashIncome(timeSpaceParam, shopId, null);
+ case "3" :
+ return tjVipSumDao.selectCardUse(timeSpaceParam, shopId, null);
+ case "4" :
+ return tjVipSumDao.selectHisConsume(timeSpaceParam, shopId, null);
+ case "5" :
+ return tjVipSumDao.selectFreeConsume(timeSpaceParam, shopId, null);
+ case "6" :
+ return tjVipSumDao.selectBusinessInCome(timeSpaceParam, shopId, null);
+ case "7" :
+ return tjVipSumDao.selectBusinessInCome(timeSpaceParam, shopId, null);
+ case "8" :
+ return tjVipSumDao.selectArrears(timeSpaceParam, shopId, null);
+ default :
+ return tjVipSumDao.selectBusinessInCome(timeSpaceParam, shopId, null);
+ }
+ }
+ });
+ } else {
+ return dataAnalysisCustomerService.getCompanyAnalysisResult(statisticsParam, new Caculate<BigDecimal>() {
+ @Override
+ public Map<String, BigDecimal> exec(List<StatisticsTimeDaoParam> timeSpaceParam, Long shopId, Long companyId) {
+ switch (statisticsParam.getType()) {
+ case "1" :
+ return tjVipSumDao.selectBusinessInCome(timeSpaceParam, null, companyId);
+ case "2" :
+ return tjVipSumDao.selectCashIncome(timeSpaceParam, null, companyId);
+ case "3" :
+ return tjVipSumDao.selectCardUse(timeSpaceParam, null, companyId);
+ case "4" :
+ return tjVipSumDao.selectHisConsume(timeSpaceParam, null, companyId);
+ case "5" :
+ return tjVipSumDao.selectFreeConsume(timeSpaceParam, null, companyId);
+ case "6" :
+ return tjVipSumDao.selectBusinessInCome(timeSpaceParam, null, companyId);
+ case "7" :
+ return tjVipSumDao.selectBusinessInCome(timeSpaceParam, null, companyId);
+ case "8" :
+ return tjVipSumDao.selectArrears(timeSpaceParam, null, companyId);
+ default :
+ return tjVipSumDao.selectBusinessInCome(timeSpaceParam, null, companyId);
+ }
+ }
+ });
+ }
}
}
diff --git a/zq-erp/src/main/java/com/matrix/system/hiveErp/analysUtil/StatisticsParamVo.java b/zq-erp/src/main/java/com/matrix/system/hiveErp/analysUtil/StatisticsParamVo.java
index 9ebb408..a4257a3 100644
--- a/zq-erp/src/main/java/com/matrix/system/hiveErp/analysUtil/StatisticsParamVo.java
+++ b/zq-erp/src/main/java/com/matrix/system/hiveErp/analysUtil/StatisticsParamVo.java
@@ -3,6 +3,8 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+import javax.validation.constraints.NotBlank;
+
/**
* 统计查询条件
* @author jyy
@@ -17,17 +19,20 @@
/**
* 开始时间
*/
+ @NotBlank(message = "参数错误")
@ApiModelProperty(value = "开始时间", example = "2020-01")
private String beginTime;
/**
*结束时间
*/
+ @NotBlank(message = "参数错误")
@ApiModelProperty(value = "结束时间", example = "2020-12")
private String endTime;
/**
*统计单位
*/
+ @NotBlank(message = "参数错误")
@ApiModelProperty(value = "统计单位", example = "月")
private String statisticsUnit;
@@ -42,6 +47,17 @@
@ApiModelProperty(value = "门店ID, 不传默认统计整个公司")
private Long shopId;
+ @ApiModelProperty(value = "类型 1-营业收入 2-现金收入 3-余额划扣 4-本金消耗 5-赠送消耗 6-现金退款 7-卡项退款 8-欠款")
+ private String type;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
public String getBeginTime() {
return beginTime;
}
diff --git a/zq-erp/src/main/java/com/matrix/system/hiveErp/dao/TjVipSumDao.java b/zq-erp/src/main/java/com/matrix/system/hiveErp/dao/TjVipSumDao.java
index 065a92d..9ccc077 100644
--- a/zq-erp/src/main/java/com/matrix/system/hiveErp/dao/TjVipSumDao.java
+++ b/zq-erp/src/main/java/com/matrix/system/hiveErp/dao/TjVipSumDao.java
@@ -19,4 +19,14 @@
Map<String, Integer> customerEnterRateCompare(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId);
Map<String, BigDecimal> selectBusinessInCome(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
+
+ Map<String, BigDecimal> selectCashIncome(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
+
+ Map<String, BigDecimal> selectCardUse(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
+
+ Map<String, BigDecimal> selectArrears(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
+
+ Map<String, BigDecimal> selectHisConsume(@Param("list") List<StatisticsTimeDaoParam> timeSpaceParam, @Param("shopId") Long shopId, @Param("companyId") Long companyId);
+
+ Map<String, BigDecimal> selectFreeConsume(@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/TjVipSumDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml
index e3ac372..5c73b36 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml
@@ -77,7 +77,7 @@
where STATU in ('已付款', '欠款')
and <![CDATA[order_time > #{item.beginTime} and order_time < #{item.endTime} ]]>
<if test="companyId != null and companyId != 0">
- and company_id=17
+ and company_id=#{companyId}
</if>
<if test="shopId !=null and shopId !=0 " >
and SHOP_ID = #{shopId}
@@ -88,5 +88,104 @@
from area where id=1
</select>
+ <select id="selectCashIncome" resultType="java.util.TreeMap">
+ select
+ <foreach collection="list" index="index" item="item" separator="," >
+ (
+ select IFNULL(sum(cash_Pay), 0)
+ from sys_order
+ where STATU in ('已付款')
+ and <![CDATA[order_time > #{item.beginTime} and order_time < #{item.endTime} ]]>
+ <if test="companyId != null and companyId != 0">
+ and company_id=#{companyId}
+ </if>
+ <if test="shopId !=null and shopId !=0 " >
+ and SHOP_ID = #{shopId}
+ </if>
+ ) as t${index}
+
+ </foreach>
+ from area where id=1
+ </select>
+
+ <select id="selectCardUse" resultType="java.util.TreeMap">
+ select
+ <foreach collection="list" index="index" item="item" separator="," >
+ (
+ select IFNULL(sum(card_Pay), 0)
+ from sys_order
+ where STATU in ('已付款')
+ and <![CDATA[order_time > #{item.beginTime} and order_time < #{item.endTime} ]]>
+ <if test="companyId != null and companyId != 0">
+ and company_id=#{companyId}
+ </if>
+ <if test="shopId !=null and shopId !=0 " >
+ and SHOP_ID = #{shopId}
+ </if>
+ ) as t${index}
+
+ </foreach>
+ from area where id=1
+ </select>
+
+ <select id="selectArrears" resultType="java.util.TreeMap">
+ select
+ <foreach collection="list" index="index" item="item" separator="," >
+ (
+ select IFNULL(sum(card_Pay), 0)
+ from sys_order
+ where STATU in ('欠款')
+ and <![CDATA[order_time > #{item.beginTime} and order_time < #{item.endTime} ]]>
+ <if test="companyId != null and companyId != 0">
+ and company_id=#{companyId}
+ </if>
+ <if test="shopId !=null and shopId !=0 " >
+ and SHOP_ID = #{shopId}
+ </if>
+ ) as t${index}
+
+ </foreach>
+ from area where id=1
+ </select>
+
+ <select id="selectHisConsume" resultType="java.util.TreeMap">
+ select
+ <foreach collection="list" index="index" item="item" separator="," >
+ (
+ select IFNULL(sum(his_consume), 0)
+ from achieve_new
+ where order_type in ('服务单')
+ and <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime} ]]>
+ <if test="companyId != null and companyId != 0">
+ and company_id=#{companyId}
+ </if>
+ <if test="shopId !=null and shopId !=0 " >
+ and SHOP_ID = #{shopId}
+ </if>
+ ) as t${index}
+
+ </foreach>
+ from area where id=1
+ </select>
+
+ <select id="selectFreeConsume" resultType="java.util.TreeMap">
+ select
+ <foreach collection="list" index="index" item="item" separator="," >
+ (
+ select IFNULL(sum(free_consume), 0)
+ from achieve_new
+ where order_type in ('服务单')
+ and <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime} ]]>
+ <if test="companyId != null and companyId != 0">
+ and company_id=#{companyId}
+ </if>
+ <if test="shopId !=null and shopId !=0 " >
+ and SHOP_ID = #{shopId}
+ </if>
+ ) as t${index}
+ </foreach>
+ from area where id=1
+ </select>
+
</mapper>
--
Gitblit v1.9.1