From 3875ea07f21457da72bcc2c2b7484987d565424d Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Fri, 22 Jan 2021 16:03:51 +0800
Subject: [PATCH] modify

---
 zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml |  232 ++++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 169 insertions(+), 63 deletions(-)

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 16ea29d..119a641 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/TjVipSumDao.xml
@@ -72,15 +72,13 @@
 		select
 		<foreach collection="list" index="index" item="item"   separator=","  >
 			(
-			select IFNULL(sum(ZK_TOTAL), 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}
+			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>
-			<if test="shopId !=null and shopId !=0 " >
-				and SHOP_ID = #{shopId}
+			<if test="companyId != null">
+				and company_id=#{companyId}
 			</if>
 			) as t${index}
 
@@ -92,15 +90,13 @@
 		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}
+			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>
-			<if test="shopId !=null and shopId !=0 " >
-				and SHOP_ID = #{shopId}
+			<if test="companyId != null">
+				and company_id=#{companyId}
 			</if>
 			) as t${index}
 
@@ -112,15 +108,13 @@
 		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}
+			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>
-			<if test="shopId !=null and shopId !=0 " >
-				and SHOP_ID = #{shopId}
+			<if test="companyId != null">
+				and company_id=#{companyId}
 			</if>
 			) as t${index}
 
@@ -132,15 +126,13 @@
 		select
 		<foreach collection="list" index="index" item="item"   separator=","  >
 			(
-			select IFNULL(sum(arrears), 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}
+			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>
-			<if test="shopId !=null and shopId !=0 " >
-				and SHOP_ID = #{shopId}
+			<if test="companyId != null">
+				and company_id=#{companyId}
 			</if>
 			) as t${index}
 
@@ -152,15 +144,13 @@
 		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}
+			select IFNULL(sum(IFNULL(his_consume, 0)),0) from achieve_new
+			where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
+			<if test="shopId != null">
+				and shop_id=#{shopId}
 			</if>
-			<if test="shopId !=null and shopId !=0 " >
-				and SHOP_ID = #{shopId}
+			<if test="companyId != null">
+				and company_id=#{companyId}
 			</if>
 			) as t${index}
 
@@ -172,15 +162,135 @@
 		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">
+			select IFNULL(sum(IFNULL(free_consume, 0)),0) from achieve_new
+			where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
+			<if test="shopId != null">
+				and shop_id=#{shopId}
+			</if>
+			<if test="companyId != null">
 				and company_id=#{companyId}
 			</if>
-			<if test="shopId !=null and shopId !=0 " >
-				and SHOP_ID = #{shopId}
+			) as t${index}
+		</foreach>
+		from area where id=1
+	</select>
+
+	<select id="selectPeopleCnt" resultType="java.util.TreeMap">
+		select
+		<foreach collection="list" index="index" item="item"   separator=","  >
+			(
+			select IFNULL(sum(IFNULL(number_of_people, 0)),0) from achieve_new
+			where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
+			<if test="shopId != null">
+				and shop_id=#{shopId}
+			</if>
+			<if test="companyId != null">
+				and company_id=#{companyId}
+			</if>
+			) as t${index}
+		</foreach>
+		from area where id=1
+	</select>
+
+	<select id="selectProjConsumeCnt" resultType="java.util.TreeMap">
+		select
+		<foreach collection="list" index="index" item="item"   separator=","  >
+			(
+			select IFNULL(sum(IFNULL(proj_num, 0)),0) from achieve_new
+			where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
+			<if test="shopId != null">
+				and shop_id=#{shopId}
+			</if>
+			<if test="companyId != null">
+				and company_id=#{companyId}
+			</if>
+			) as t${index}
+		</foreach>
+		from area where id=1
+	</select>
+
+	<select id="selectTimeLength" resultType="java.util.TreeMap">
+		select
+		<foreach collection="list" index="index" item="item"   separator=","  >
+			(
+			select IFNULL(sum(IFNULL(proj_time, 0)),0) from achieve_new
+			where <![CDATA[datatime > #{item.beginTime} and datatime < #{item.endTime}]]>
+			<if test="shopId != null">
+				and shop_id=#{shopId}
+			</if>
+			<if test="companyId != null">
+				and company_id=#{companyId}
+			</if>
+			) as t${index}
+		</foreach>
+		from area where id=1
+	</select>
+
+	<select id="selectProductAchieve" resultType="java.util.TreeMap">
+		select
+		<foreach collection="list" index="index" item="item"   separator=","  >
+			(
+			select IFNULL(sum(zk_price),0) from sys_order_item a
+			inner join shopping_goods b on a.goods_id=b.id
+			inner join sys_order c on a.ORDER_ID=c.id
+			where b.good_type='家居产品' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]>
+			<if test="shopId != null">
+				and c.shop_id=#{shopId}
+			</if>
+			<if test="companyId != null">
+				and c.company_id=#{companyId}
+			</if>
+			) as t${index}
+		</foreach>
+		from area where id=1
+	</select>
+
+	<select id="selectCardAchieve" resultType="java.util.TreeMap">
+		select
+		<foreach collection="list" index="index" item="item"   separator=","  >
+			(
+			select IFNULL(sum(zk_price),0) from sys_order_item a
+			inner join shopping_goods b on a.goods_id=b.id
+			inner join sys_order c on a.ORDER_ID=c.id
+			where b.good_type!='家居产品' and <![CDATA[ a.create_time > #{item.beginTime} and a.create_time < #{item.endTime}]]>
+			<if test="shopId != null">
+				and c.shop_id=#{shopId}
+			</if>
+			<if test="companyId != null">
+				and c.company_id=#{companyId}
+			</if>
+			) as t${index}
+		</foreach>
+		from area where id=1
+	</select>
+
+	<select id="selectRepayment" resultType="java.util.TreeMap">
+		select
+		<foreach collection="list" index="index" item="item"   separator=","  >
+			(
+			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>
+			<if test="companyId != null">
+				and company_id=#{companyId}
+			</if>
+			) as t${index}
+		</foreach>
+		from area where id=1
+	</select>
+
+	<select id="selectPerCustomCnt" resultType="java.util.TreeMap">
+		select
+		<foreach collection="list" index="index" item="item"   separator=","  >
+			(
+			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>
+			<if test="companyId != null">
+				and company_id=#{companyId}
 			</if>
 			) as t${index}
 		</foreach>
@@ -191,15 +301,13 @@
 		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}
+			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>
-			<if test="shopId !=null and shopId !=0 " >
-				and SHOP_ID = #{shopId}
+			<if test="companyId != null">
+				and company_id=#{companyId}
 			</if>
 			) as t${index}
 
@@ -212,15 +320,13 @@
 		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}
+			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>
-			<if test="shopId !=null and shopId !=0 " >
-				and SHOP_ID = #{shopId}
+			<if test="companyId != null">
+				and company_id=#{companyId}
 			</if>
 			) as t${index}
 

--
Gitblit v1.9.1