From 38fffe4319f408b5dc1da23d30512e90b0f4feac Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期五, 04 一月 2019 11:25:45 +0800
Subject: [PATCH] 订单接口筛选统计数据调整

---
 fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml b/fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
index 7c29f49..fa84721 100644
--- a/fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
+++ b/fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -290,6 +290,50 @@
 		DESC
 		LIMIT ${start},${count}
 	</select>
+	
+	<select id="countMoneyGroupOrderNoByUid" resultType="java.util.Map">
+		SELECT COALESCE(SUM(A.moneys),0)AS totalMoney,COUNT(*) AS totalRow FROM 
+			(SELECT COALESCE(SUM(th.`hb_money`),0)AS moneys FROM yeshi_ec_common_order tc
+			LEFT JOIN
+			yeshi_ec_hongbao_order tr ON tr.`ho_order_id` = tc.`co_id`
+			LEFT JOIN
+			yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR
+			th.`hb_pid` = tr.`ho_hongbao_id` )
+			WHERE th.`hb_uid` = #{uid} 	AND th.hb_state = 3 AND (tc.co_state = 1 or tc.co_state = 2)
+			<if test="type != null and type == 1"> <!-- 鑷喘璁㈠崟 -->
+				AND (th.hb_type =1 or th.hb_type =2)
+			</if>
+			<if test="type != null and type == 2"> <!-- 鍒嗕韩璁㈠崟 -->
+				AND (th.`hb_type` = 20 OR th.`hb_type` = 21 OR th.`hb_type` = 22)
+			</if>
+			<if test="type != null and type == 3"> <!-- 閭�璇疯鍗� -->
+				AND (th.`hb_type` = 5 OR th.`hb_type` = 6 OR th.`hb_type` = 7)
+			</if>
+			<if test="orderNo != null">
+				AND tc.co_order_no = #{orderNo}
+			</if>
+			<if test="startTime != null">
+				AND <![CDATA[tc.co_create_time >= #{startTime}]]>
+			</if>
+			<if test="endTime != null">
+				AND <![CDATA[tc.co_create_time <= #{endTime}]]>
+			</if>
+			<if test="day != null and day == 1"> <!-- 浠婂ぉ -->
+				AND TO_DAYS(tc.`co_create_time`) = TO_DAYS(NOW())
+			</if>
+			<if test="day != null and day == 2">  <!-- 鏄ㄥぉ -->
+				AND TO_DAYS(NOW()) - TO_DAYS(tc.`co_create_time`) = 1
+			</if>
+			<if test="day != null and day == 3">  <!-- 鏈湀 -->
+				AND DATE_FORMAT(tc.`co_create_time`,'%Y%m') =
+				DATE_FORMAT(CURDATE(),'%Y%m')
+			</if>
+			<if test="day != null and day == 4">  <!-- 涓婃湀 -->
+				AND PERIOD_DIFF( DATE_FORMAT(NOW(), '%Y%m'),
+				DATE_FORMAT(tc.`co_create_time`, '%Y%m')) = 1
+			</if>
+			GROUP BY tc.`co_order_no`,tc.co_source_type)A
+	</select>
 
 	<select id="countGroupOrderNoByUid" resultType="java.lang.Long">
 		SELECT IFNULL(COUNT(DISTINCT tc.`co_order_no`,tc.`co_source_type`),0)

--
Gitblit v1.8.0