Browse Source

客户资料查询新增是否面谈筛选

anderx 7 years ago
parent
commit
d44f838b04
1 changed files with 40 additions and 5 deletions
  1. 40 5
      src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

+ 40 - 5
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -1702,14 +1702,17 @@
 			on b.location_province=c.id left join district_glossory c1 
 			on b.location_city=c1.id left join district_glossory c2 
 			on b.location_area=c2.id left join industry_category d on b.industry = d.id
-			<if test="follow ==1">
-			left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 group by uid) e on a.id=e.uid and a.aid=e.aid
+			<if test="follow !=null and follow!=''">
+			left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} group by uid) e on a.id=e.uid and a.aid=e.aid
 			</if>
 			where  a.status=0 
 			and a.information_maintainer = #{aid,jdbcType=VARCHAR}
 			<if test="type !=null and type!=''">
 			and a.`type`=#{type,jdbcType=VARCHAR}
 			</if>
+			<if test="follow ==0">
+			and (e.contact_type !=0 or e.contact_type is null)
+			</if>
 			<if test="follow ==1">
 			and e.contact_type=0
 			</if>
@@ -1756,13 +1759,16 @@
 		select count(0)
 			from user a left join organization_identity b 
 			on a.id=b.uid 
-			<if test="follow ==1">
+			<if test="follow  !=null and follow!=''">
 			left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 group by uid) e on a.id=e.uid and a.aid=e.aid
 			</if>
 			where  a.status=0 and a.information_maintainer = #{aid,jdbcType=VARCHAR}
 			<if test="type !=null and type!=''">
 			and a.`type`=#{type,jdbcType=VARCHAR}
 			</if>
+			<if test="follow ==0">
+			and (e.contact_type !=0 or e.contact_type is null)
+			</if>
 			<if test="follow ==1">
 			and e.contact_type=0
 			</if>
@@ -1833,8 +1839,18 @@ from
 	on b.location_province=c.id left join district_glossory c1 
 	on b.location_city=c1.id left join district_glossory c2 
 	on b.location_area=c2.id left join industry_category d 
-	on b.industry = d.id 
+	on b.industry = d.id  left join( select aid, uid, contact_type from user_follow
+		where aid = #{aid,jdbcType=VARCHAR} group by uid
+	) e on
+	a.id = e.uid
+	and a.aid = e.aid
 	where 1=1 and a.status=0
+	<if test="follow ==0">
+			and (e.contact_type !=0 or e.contact_type is null)
+			</if>
+			<if test="follow ==1">
+			and e.contact_type=0
+			</if>
 		<if test="type !=null and type!=''">
 			and a.`type`=#{type,jdbcType=VARCHAR}
 			</if>
@@ -1891,13 +1907,32 @@ inner join(
 	<select id="selectDepCustomerInformationCount" resultType="java.lang.Integer">
 		select count(0)
 			from user a left join organization_identity b 
-			on a.id=b.uid  inner join (select id
+			on a.id=b.uid left join(
+		select
+			aid,
+			uid,
+			contact_type
+		from
+			user_follow
+		where
+			aid = #{aid,jdbcType=VARCHAR}
+		group by
+			uid
+	) e on
+	a.id = e.uid
+	and a.aid = e.aid inner join (select id
 			from admin
 			where id=   #{aid,jdbcType=VARCHAR}
 			or superior_id=  #{aid,jdbcType=VARCHAR}
 			) y
 			on y.id=a.information_maintainer
 			where 1=1 and a.status=0
+			<if test="follow ==0">
+			and (e.contact_type !=0 or e.contact_type is null)
+			</if>
+			<if test="follow ==1">
+			and e.contact_type=0
+			</if>
 			<if test="type !=null and type!=''">
 			and a.`type`=#{type,jdbcType=VARCHAR}
 			</if>