From 810c03ebbb309ee9447f7a3e073b914a216930f4 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 06 九月 2019 16:44:02 +0800
Subject: [PATCH] 订单监控修改

---
 fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml |  197 ++++++++++++++++++++++++++++---------------------
 1 files changed, 113 insertions(+), 84 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 b77ae8c..721a8ee 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
@@ -99,7 +99,7 @@
 		<result column="hb_id" property="hongbaoId" jdbcType="BIGINT" />
 
 		<result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
-		
+
 		<association property="userInfo" column="co_uid"
 			resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap" />
 
@@ -107,8 +107,8 @@
 			resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap" />
 
 	</resultMap>
-	
-	
+
+
 	<resultMap id="ThreeResultMap" type="com.yeshi.fanli.vo.order.CommonOrderVO">
 		<id column="co_id" property="id" jdbcType="BIGINT" />
 		<result column="co_order_no" property="orderNo" jdbcType="VARCHAR" />
@@ -145,14 +145,14 @@
 		<result column="userPortrait" property="userPortrait" jdbcType="VARCHAR" />
 		<result column="hb_id" property="hongbaoId" jdbcType="BIGINT" />
 		<result column="co_trade_id" property="tradeId" jdbcType="VARCHAR" />
-		
-	 	<association property="userInfo" column="co_uid" 
-    	   select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey"/>
-    	   
-    	 <association property="commonOrderGoods" column="co_order_goods_id" 
-    	   select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey"/>
+
+		<association property="userInfo" column="co_uid"
+			select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey" />
+
+		<association property="commonOrderGoods" column="co_order_goods_id"
+			select="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.selectByPrimaryKey" />
 	</resultMap>
-	
+
 	<sql id="Base_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_state_whole_order,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_order_by,co_create_time,co_update_time,co_trade_id
 	</sql>
 	<select id="selectByPrimaryKey" resultMap="BaseResultMap"
@@ -183,48 +183,54 @@
 	<select id="selectBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT *
 		FROM
 		yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and
-		co_trade_id=#{tradeId}  limit 1
+		co_trade_id=#{tradeId} limit 1
 	</select>
-	
+
 	<select id="listBySourceTypeAndTradeId" resultMap="BaseResultMap">SELECT *
 		FROM
 		yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} and
 		co_trade_id=#{tradeId}
 	</select>
-	
-	
-	<select id="listBySourceTypeAndTradeIdList" resultMap="BaseResultMap">SELECT *
+
+
+	<select id="listBySourceTypeAndTradeIdList" resultMap="BaseResultMap">
+		SELECT *
 		FROM
-		yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} 
+		yeshi_ec_common_order co WHERE
+		co.co_source_type=#{sourceType}
 		<if test="tradeIdList!=null">
-			<foreach collection="tradeIdList" item="tradeId" open=" and (" close=")" separator=" or ">
+			<foreach collection="tradeIdList" item="tradeId" open=" and ("
+				close=")" separator=" or ">
 				co.co_trade_id=#{tradeId}
 			</foreach>
 		</if>
 	</select>
-	
-	
-	<select id="listBySourceTypeAndStateAndThirdCrateTime" resultMap="BaseResultMap">SELECT *
+
+
+	<select id="listBySourceTypeAndStateAndThirdCrateTime"
+		resultMap="BaseResultMap">
+		SELECT *
 		FROM
-		yeshi_ec_common_order co WHERE co.co_source_type=#{sourceType} 
-		
+		yeshi_ec_common_order co WHERE
+		co.co_source_type=#{sourceType}
+
 		<if test="state!=null">
 			and co_state=#{state}
 		</if>
-		
+
 		<if test="minTime!=null">
 			and UNIX_TIMESTAMP(co_third_create_time)*1000>=#{minTime}
 		</if>
-		
-		
+
+
 		<if test="maxTime!=null">
-		    and	#{maxTime}>	UNIX_TIMESTAMP(co_third_create_time)*1000
+			and #{maxTime}> UNIX_TIMESTAMP(co_third_create_time)*1000
 		</if>
-		
+
 		order by co_id desc
 		limit #{start},#{count}
 	</select>
-	
+
 
 	<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from
 		yeshi_ec_common_order where co_id = #{id,jdbcType=BIGINT}
@@ -413,7 +419,7 @@
 		MAX(co_settle_time) AS co_settle_time, co_order_by, co_create_time,
 		co_update_time
 	</sql>
-	
+
 	<select id="listUserOrder" resultMap="ResultMap">
 		<!-- 鏌ヨ鐢ㄦ埛璁㈠崟 -->
 		SELECT COALESCE(SUM(hb.`hb_money`),0)AS totalMoney, hb.hb_state AS
@@ -437,11 +443,11 @@
 		<if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
 		<!-- 璁㈠崟鏉ユ簮 -->
 		<if test="source != null">AND co.co_source_type = #{source}</if>
-		
+
 		GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY
 		co.co_third_create_time DESC LIMIT ${start},${count}
 	</select>
-	
+
 	<select id="countUserOrder" resultType="java.lang.Long">
 		<!-- 缁熻鐢ㄦ埛璁㈠崟鏁伴噺 -->
 		SELECT IFNULL(COUNT(ho_id),0) FROM (SELECT ho.ho_id FROM
@@ -462,7 +468,7 @@
 		<if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
 		<!-- 璁㈠崟鏉ユ簮 -->
 		<if test="source != null">AND co.co_source_type = #{source}</if>
-		
+
 		GROUP BY co.`co_order_no`, co.`co_source_type` )A
 	</select>
 	<select id="listOrderGoodsInfo" resultMap="ResultMap"
@@ -480,8 +486,8 @@
 		</foreach>
 		GROUP BY tc.`co_order_no`,tc.`co_order_goods_id`
 	</select>
-	
-	
+
+
 	<select id="countHistoryOrder" resultType="java.util.HashMap">
 		<!-- 缁熻鍘嗗彶璁㈠崟鏁伴噺 -->
 		SELECT SUM(A.self)AS totalSelf,SUM(A.shared)AS
@@ -515,11 +521,11 @@
 		</if>
 		<!-- 璁㈠崟鏉ユ簮 -->
 		<if test="source != null">AND co.co_source_type = #{source}</if>
-		
-		GROUP BY co.`co_order_no`, co.`co_source_type`)YX 
-		
+
+		GROUP BY co.`co_order_no`, co.`co_source_type`)YX
+
 		UNION ALL
-		
+
 		<!-- 鍒嗕韩璁㈠崟 -->
 		SELECT 0 AS self,IFNULL(COUNT(ho_id),0) AS shared,0 AS invite FROM
 		(SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
@@ -527,7 +533,7 @@
 		= 20 ) hb ON hb.hb_id=ho.`ho_hongbao_id`
 		<!-- 鍒嗕韩璁㈠崟 -->
 		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
-		WHERE hb.hb_id IS NOT NULL  and hb.hb_state!=4
+		WHERE hb.hb_id IS NOT NULL and hb.hb_state!=4
 		<if test="day != null and day == 1">
 			<!-- 浠婂ぉ -->
 			AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
@@ -548,11 +554,11 @@
 		</if>
 		<!-- 璁㈠崟鏉ユ簮 -->
 		<if test="source != null">AND co.co_source_type = #{source}</if>
-		
-		GROUP BY co.`co_order_no`, co.`co_source_type`)WQ 
-		
+
+		GROUP BY co.`co_order_no`, co.`co_source_type`)WQ
+
 		UNION ALL
-		
+
 		<!-- 閭�璇疯鍗� -->
 		SELECT 0 AS self,0 AS shared,IFNULL(COUNT(ho_id),0) AS invite FROM
 		(SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
@@ -560,7 +566,8 @@
 		(v2.`hb_type` = 5 OR v2.`hb_type` = 6 OR v2.`hb_type` = 7 OR
 		v2.`hb_type` = 21 OR v2.`hb_type` = 22 ) ) hbp ON
 		hbp.hb_pid=ho.`ho_hongbao_id` LEFT JOIN yeshi_ec_common_order co ON
-		co.`co_id`=ho.`ho_order_id` WHERE hbp.hb_id IS NOT NULL  and hbp.hb_state!=4
+		co.`co_id`=ho.`ho_order_id` WHERE hbp.hb_id IS NOT NULL and
+		hbp.hb_state!=4
 		<if test="day != null and day == 1">
 			<!-- 浠婂ぉ -->
 			AND TO_DAYS(co.`co_third_create_time`) = TO_DAYS(NOW())
@@ -581,11 +588,11 @@
 		</if>
 		<!-- 璁㈠崟鏉ユ簮 -->
 		<if test="source != null">AND co.co_source_type = #{source}</if>
-		
+
 		GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A
 	</select>
-	
-	
+
+
 	<select id="countByUidAndOrderState" resultType="java.util.HashMap">
 		SELECT SUM(A.valid)AS totalValid, SUM(A.proces)AS
 		totalProces,SUM(A.Invalid)AS totalInvite FROM (
@@ -598,13 +605,13 @@
 		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
 		WHERE hb.hb_id IS NOT NULL <![CDATA[AND co.`co_state` <> 3]]>
 		AND (co.`co_state_whole_order` =1 OR co.`co_state_whole_order` = 2)
-			<include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
-			<!-- 璁㈠崟鏉ユ簮 -->
-			<if test="source != null">AND co.co_source_type = #{source}</if>
-		GROUP BY co.`co_order_no`, co.`co_source_type`)YX 
-		
+		<include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
+		<!-- 璁㈠崟鏉ユ簮 -->
+		<if test="source != null">AND co.co_source_type = #{source}</if>
+		GROUP BY co.`co_order_no`, co.`co_source_type`)YX
+
 		UNION ALL
-		
+
 		<!-- 缁存潈璁㈠崟 -->
 		SELECT 0 AS valid,IFNULL(COUNT(ho_id),0) AS proces,0 AS Invalid FROM
 		(SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
@@ -614,12 +621,12 @@
 		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
 		WHERE hb.hb_id IS NOT NULL AND co.`co_state` = 3
 		<include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
-			<!-- 璁㈠崟鏉ユ簮 -->
-			<if test="source != null">AND co.co_source_type = #{source}</if>
-		GROUP BY co.`co_order_no`, co.`co_source_type`)WQ 
-		
+		<!-- 璁㈠崟鏉ユ簮 -->
+		<if test="source != null">AND co.co_source_type = #{source}</if>
+		GROUP BY co.`co_order_no`, co.`co_source_type`)WQ
+
 		UNION ALL
-		
+
 		<!-- 澶辨晥璁㈠崟 -->
 		SELECT 0 AS valid,0 AS proces,IFNULL(COUNT(ho_id),0) AS Invalid FROM
 		(SELECT ho.`ho_id` FROM yeshi_ec_hongbao_order ho LEFT JOIN ( SELECT *
@@ -629,8 +636,8 @@
 		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
 		WHERE hb.hb_id IS NOT NULL AND co.`co_state_whole_order` = 3
 		<include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
-			<!-- 璁㈠崟鏉ユ簮 -->
-			<if test="source != null">AND co.co_source_type = #{source}</if>
+		<!-- 璁㈠崟鏉ユ簮 -->
+		<if test="source != null">AND co.co_source_type = #{source}</if>
 		GROUP BY co.`co_order_no`, co.`co_source_type`)SX )A
 	</select>
 	<select id="countBonusOrderNumber" resultType="java.lang.Long">
@@ -679,7 +686,7 @@
 		IS NOT NULL
 		<include refid="SELECT_PARAM_ORDER_CREATE_TIME" />
 		<if test="day != null and day == 4">AND co.`co_state` = 2</if> <!-- 涓婃湀 :缁熻宸叉敹璐� -->
-		<if test="source != null">AND co.co_source_type = #{source}</if> 
+		<if test="source != null">AND co.co_source_type = #{source}</if>
 		GROUP BY co.`co_order_no`, co.`co_source_type` )A
 	</select>
 	<sql id="SELECT_HONGBAO_STATE">
@@ -750,14 +757,15 @@
 		userPortrait FROM (SELECT hb.hb_id,hb.hb_uid,hb.`hb_money` AS
 		totalMoney, hb.hb_state AS hongBaoState, hb.`hb_type` AS hongBaoType,
 		hb.`hb_get_time` AS accountTime, hb.`hb_pre_get_time` AS
-		preAccountTime, co.*  FROM yeshi_ec_hongbao_order ho LEFT JOIN
-		(SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
+		preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN
+		(SELECT *
+		FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
 		<include refid="SELECT_PARAM_HONGBAO_TYPE" />
 		<!-- 绾㈠寘绫诲瀷 -->
 		<include refid="SELECT_HONGBAO_STATE" />
 		<!-- 绾㈠寘鐘舵�� -->
 		)hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
-		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` 
+		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
 		WHERE hb.hb_id IS NOT NULL
 		<include refid="SELECT_PARAM_ORDER_STATE" />
 		<!-- 璁㈠崟鐘舵�� -->
@@ -774,21 +782,23 @@
 		ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} ) A LEFT
 		JOIN yeshi_ec_user u ON u.id = A.hb_uid
 	</select>
-	
-	
+
+
 	<select id="listQueryWithNoChild" resultMap="ThreeResultMap">
 		SELECT A.*,u.id AS userId,u.`nick_name` AS userName,u.`portrait` AS
 		userPortrait FROM (SELECT hb.hb_id,hb.hb_uid,hb.`hb_money` AS
 		totalMoney, hb.hb_state AS hongBaoState, hb.`hb_type` AS hongBaoType,
 		hb.`hb_get_time` AS accountTime, hb.`hb_pre_get_time` AS
-		preAccountTime, co.*  FROM yeshi_ec_hongbao_order ho LEFT JOIN
-		(SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
+		preAccountTime, co.* FROM yeshi_ec_hongbao_order ho LEFT JOIN
+		(SELECT *
+		FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
 		<include refid="SELECT_PARAM_HONGBAO_TYPE" />
 		<!-- 绾㈠寘绫诲瀷 -->
 		<include refid="SELECT_HONGBAO_STATE" />
 		<!-- 绾㈠寘鐘舵�� -->
 		)hb ON hb.hb_id=ho.`ho_hongbao_id`
-		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` 
+		LEFT JOIN yeshi_ec_common_order co
+		ON co.`co_id`=ho.`ho_order_id`
 		WHERE hb.hb_id IS NOT NULL
 		<include refid="SELECT_PARAM_ORDER_STATE" />
 		<!-- 璁㈠崟鐘舵�� -->
@@ -805,8 +815,8 @@
 		ORDER BY co.co_third_create_time DESC LIMIT ${start},${count} ) A LEFT
 		JOIN yeshi_ec_user u ON u.id = A.hb_uid
 	</select>
-	
-	
+
+
 	<select id="countQuery" resultType="java.lang.Long">
 		SELECT count(ho.ho_id) FROM yeshi_ec_hongbao_order ho LEFT JOIN
 		(SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
@@ -815,8 +825,8 @@
 		<include refid="SELECT_HONGBAO_STATE" />
 		<!-- 绾㈠寘鐘舵�� -->
 		)hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
-		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` 
-		 WHERE hb.hb_id IS NOT NULL
+		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
+		WHERE hb.hb_id IS NOT NULL
 		<include refid="SELECT_PARAM_ORDER_STATE" />
 		<!-- 璁㈠崟鐘舵�� -->
 		<if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
@@ -830,8 +840,8 @@
 		<!-- 璁㈠崟鏉ユ簮 -->
 		<if test="source != null">AND co.co_source_type = #{source}</if>
 	</select>
-	
-	
+
+
 	<select id="countQueryWithNoChild" resultType="java.lang.Long">
 		SELECT count(ho.ho_id) FROM yeshi_ec_hongbao_order ho LEFT JOIN
 		(SELECT * FROM yeshi_ec_hongbao_v2 v2 WHERE 1=1
@@ -840,8 +850,9 @@
 		<include refid="SELECT_HONGBAO_STATE" />
 		<!-- 绾㈠寘鐘舵�� -->
 		)hb ON hb.hb_id=ho.`ho_hongbao_id`
-		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` 
-		 WHERE hb.hb_id IS NOT NULL
+		LEFT JOIN yeshi_ec_common_order co
+		ON co.`co_id`=ho.`ho_order_id`
+		WHERE hb.hb_id IS NOT NULL
 		<include refid="SELECT_PARAM_ORDER_STATE" />
 		<!-- 璁㈠崟鐘舵�� -->
 		<if test="startTime != null and startTime != '' ">AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
@@ -855,10 +866,10 @@
 		<!-- 璁㈠崟鏉ユ簮 -->
 		<if test="source != null">AND co.co_source_type = #{source}</if>
 	</select>
-	
-	
-	
-	
+
+
+
+
 	<select id="getCouponHongbaoByOrderNo" resultMap="ResultMap">
 		SELECT COALESCE(SUM(IF(hb.hb_type=1,hb.`hb_money`,0)),0)AS totalMoney,
 		COALESCE(SUM(IF(hb.hb_type=10,hb.`hb_money`,0)),0)AS couponMoney,
@@ -884,16 +895,34 @@
 		FROM yeshi_ec_hongbao_v2 v2 WHERE v2.`hb_uid`= #{uid} AND <![CDATA[v2.`hb_type`<> 10 ]]>
 		)hb ON IF(hb.hb_pid IS NULL,hb.hb_id,hb.hb_pid)=ho.`ho_hongbao_id`
 		LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id`
-		WHERE hb.hb_id IS NOT NULL AND co.co_order_no = #{orderNo} AND  co.`co_source_type` = #{sourceType}
+		WHERE hb.hb_id IS NOT NULL AND co.co_order_no = #{orderNo} AND
+		co.`co_source_type` = #{sourceType}
 		<if test="orderState != null">
 			AND co.co_state = #{orderState}
 			<!-- 宸叉敹璐� -->
 		</if>
 		GROUP BY co.`co_order_no`, co.`co_source_type`
 	</select>
-	
+
 	<select id="getByOrderNo" resultMap="BaseResultMap">
-		SELECT * FROM yeshi_ec_common_order co 
+		SELECT * FROM
+		yeshi_ec_common_order co
 		WHERE co_uid = #{uid} AND co_order_no=#{orderNo}
 	</select>
+
+
+	<select id="listByUid" resultMap="BaseResultMap">
+		SELECT * FROM yeshi_ec_common_order co
+		WHERE co_uid = #{uid}
+		<if test="stateList!=null">
+			<foreach collection="stateList" separator=" or " open="and ("
+				item="state" close=")">
+				co_state=#{state}
+			</foreach>
+		</if>
+		limit #{start},#{count}
+	</select>
+
+
+
 </mapper>

--
Gitblit v1.8.0