From c558c4f1130debfd785c74ff0e963afc6455f196 Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@Admin>
Date: 星期三, 21 十一月 2018 16:30:42 +0800
Subject: [PATCH] Merge branch 'master' into dev1

---
 fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml |  149 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 148 insertions(+), 1 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml b/fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
index 3ec049f..747faab 100644
--- a/fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
+++ b/fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
@@ -15,8 +15,21 @@
 			javaType="com.yeshi.fanli.entity.bus.user.UserInfo">
 			<id column="worker_id" property="id" jdbcType="BIGINT" />
 		</association>
-		
 	</resultMap>
+	
+	<resultMap id="AllResultMap" type="com.yeshi.fanli.entity.bus.user.ThreeSale">
+		<id column="id" property="id" jdbcType="BIGINT" />
+		<result column="state" property="state" jdbcType="BOOLEAN" />
+		<result column="createTime" property="createTime" jdbcType="BIGINT" />
+		<result column="expire" property="expire" jdbcType="INTEGER" />
+		
+		<association property="boss" column="boss_id"
+			select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey" />
+			
+		<association property="worker" column="worker_id"
+			select="com.yeshi.fanli.dao.mybatis.UserInfoMapper.selectByPKey" />
+	</resultMap>
+	
 	<sql id="Base_Column_List">id,boss_id,worker_id,state,expire,createTime</sql>
 	<select id="selectByPrimaryKey" resultMap="BaseResultMap"
 		parameterType="java.lang.Long">
@@ -171,4 +184,138 @@
 			close=")">#{item}</foreach>
 	</update>
 	
+	<select id="listFirstTeamQuery"  resultMap="AllResultMap">
+		 SELECT	*  FROM `yeshi_ec_threesale`
+		 WHERE 1=1
+		  <if test="uid != null">
+		  		AND `boss_id` = #{uid}
+		  </if>
+		 <if test="state == 0">
+		  		AND `state` = 0  AND (expire = 0  OR  expire IS NULL)
+		  </if>
+		  <if test="state == 1">
+		  		AND `state` = 1
+		  </if>
+		  <if test="state ==2">
+			    AND `expire` = 1  <!-- 澶辨晥 -->
+		  </if>
+		  <if test="startTime != null and startTime !='' ">
+		        <![CDATA[AND FROM_UNIXTIME(createTime/1000) >= #{startTime}]]>
+		  </if>
+		  <if test="endTime != null and  endTime !='' ">
+		  		<![CDATA[AND FROM_UNIXTIME(createTime/1000) <= #{endTime}]]>
+		  </if>
+		  ORDER BY createTime DESC
+		  LIMIT ${start},${count}
+	</select>
+	
+	<select id="countFirstTeamQuery"  resultType="java.lang.Long">
+		 SELECT count(id) FROM `yeshi_ec_threesale`
+		 WHERE 1=1
+		  <if test="uid != null">
+		  		AND `boss_id` = #{uid}
+		  </if>
+		 <if test="state == 0">
+			  	AND `state` = 0  AND (expire = 0  OR  expire IS NULL)
+		</if>
+		<if test="state == 1">
+			  	AND `state` = 1
+		 </if>
+		  <if test="state ==2">
+			  AND `expire` = 1  <!-- 澶辨晥 -->
+		  </if>
+		  <if test="startTime != null and startTime !='' ">
+		        <![CDATA[AND FROM_UNIXTIME(createTime/1000) >= #{startTime}]]>
+		  </if>
+		  <if test="endTime != null and  endTime !=''">
+		  		<![CDATA[AND FROM_UNIXTIME(createTime/1000) <= #{endTime}]]>
+		  </if>
+	</select>
+	
+	
+	<select id="listSecondTeamQuery"  resultMap="AllResultMap">
+		SELECT yet.* FROM  (
+			SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts 
+ 				LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
+ 			WHERE  1=1
+	 		  <if test="uid != null">
+			  		AND tf.`boss_id` = #{uid}
+			  </if>
+			   <if test="state == 0">
+			  		AND ts.`state` = 0  AND (ts.expire = 0  OR  ts.expire IS NULL)
+			  </if>
+			  <if test="state == 1">
+			  		AND ts.`state` = 1
+			  </if>
+			   <if test="state ==2">
+			  		AND ts.`expire` = 1  <!-- 澶辨晥 -->
+			  </if>
+			 <if test="startTime != null and startTime !='' ">
+			        <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
+			  </if>
+			  <if test="endTime != null and  endTime !=''">
+			  		<![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
+			  </if>
+			
+ 			 )A LEFT JOIN yeshi_ec_threesale yet ON yet.id = A.id
+		ORDER BY yet.`createtime` DESC 
+		LIMIT ${start},${count}
+	</select>
+	
+	<select id="countSecondTeamQuery" resultType="java.lang.Long" >
+ 		 SELECT COUNT(A.id) FROM (
+ 		  	SELECT DISTINCT(ts.`id`) AS id FROM `yeshi_ec_threesale` ts 
+ 				LEFT JOIN yeshi_ec_threesale tf ON ts.`boss_id`=tf.`worker_id`
+ 			WHERE  1=1
+	 		  <if test="uid != null">
+			  		AND tf.`boss_id` = #{uid}
+			  </if>
+			  <if test="state == 0">
+			  		AND ts.`state` = 0  AND (ts.expire = 0  OR  ts.expire IS NULL)
+			  </if>
+			  <if test="state == 1">
+			  		AND ts.`state` = 1
+			  </if>
+			  <if test="state ==2">
+			  		AND ts.`expire` = 1  <!-- 澶辨晥 -->
+			  </if>
+			  <if test="startTime != null and startTime !='' ">
+			        <![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) >= #{startTime}]]>
+			  </if>
+			   <if test="endTime != null and endTime !=''">
+			  		<![CDATA[AND FROM_UNIXTIME(ts.createTime/1000) <= #{endTime}]]>
+			  </if>
+			)A
+	</select>
+	
+	<select id="listSuperiorQuery"  resultMap="AllResultMap">
+		SELECT * FROM `yeshi_ec_threesale` ts  
+		WHERE ts.`worker_id` = #{uid}
+			 <if test="state == 0">
+			  		AND ts.`state` = 0  AND (ts.expire = 0  OR  ts.expire IS NULL)
+			  </if>
+			  <if test="state == 1">
+			  		AND ts.`state` = 1
+			  </if>
+			<if test="state ==2">
+			  	AND ts.`expire` = 1  <!-- 澶辨晥 -->
+			</if>
+		ORDER BY ts.`createtime` DESC 
+		LIMIT ${start},${count}
+	</select>
+	
+	<select id="countSuperiorQuery" resultType="java.lang.Long" >
+ 		SELECT COUNT(ts.id) FROM `yeshi_ec_threesale` ts  
+		WHERE ts.`worker_id` = #{uid}
+			 <if test="state == 0">
+			  		AND ts.`state` = 0  AND (ts.expire = 0  OR  ts.expire IS NULL)
+			  </if>
+			  <if test="state == 1">
+			  		AND ts.`state` = 1
+			  </if>
+			<if test="state ==2">
+			  	AND ts.`expire` = 1  <!-- 澶辨晥 -->
+			</if>
+	</select>
+	
 </mapper>

--
Gitblit v1.8.0