| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.cyksj.mapper.corp.CorpUserFollowRelationMapper">
- <select id="selectCorpCustomers" resultType="java.lang.String">
- select group_concat(cf.name)
- from (select id
- from corp_user
- where unionid = #{unionid} limit 1) cu
- inner join corp_user_auth ca on ca.corp_user_id = cu.id and wx_corp_id = #{wxCorpId}
- inner join corp_user_follow_relation cfr on cfr.corp_user_id = ca.external_userid
- inner join corp_follow cf on cf.userid = cfr.follow_id and cf.wx_corp_id = #{wxCorpId}
- </select>
- <select id="selectCorpUserFollowRelationByTagIds" resultType="com.cyksj.model.dto.CorpUserFollowRelationDto">
- select cufr.corp_user_id,
- any_value(cufr.follow_id) as follow_id,
- any_value(cu.user_id) as user_id
- from (select
- relation_id from `corp_user_tag`
- where tag_id in
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>) cut left join `corp_user_follow_relation` cufr on cufr.id = cut.relation_id
- left join `corp_user_auth` ca on ca.external_userid = cufr.corp_user_id
- left join `corp_user` cu on cu.id = ca.corp_user_id
- where cufr.wx_corp_id = #{wxCorpId}
- <choose>
- <when test="userScope == 2">
- and cu.user_id != 0
- </when>
- <when test="userScope == 3">
- and cu.user_id = 0
- </when>
- </choose>
- and ca.wx_corp_id = #{wxCorpId}
- <if test="followIds != null and followIds.size() > 0">
- and cufr.follow_id in
- <foreach collection="followIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- group by cufr.corp_user_id
- </select>
- <select id="selectCorpUserFollowRelation" resultType="com.cyksj.model.dto.CorpUserFollowRelationDto">
- select cufr.corp_user_id,
- any_value(cufr.follow_id) as follow_id,
- any_value(cu.user_id) as user_id
- from `corp_user_follow_relation` cufr left join `corp_user_auth` ca on ca.external_userid = cufr.corp_user_id
- left join `corp_user` cu on cu.id = ca.corp_user_id
- where cufr.wx_corp_id = #{wxCorpId}
- and ca.wx_corp_id = #{wxCorpId}
- <if test="followIds != null and followIds.size() > 0">
- and cufr.follow_id in
- <foreach collection="followIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- group by cufr.corp_user_id
- </select>
- <select id="selectCorpUserNotUnderTagIds" resultType="com.cyksj.model.dto.CorpUserFollowRelationDto">
- select cufr.corp_user_id,
- any_value(cufr.follow_id) as follow_id,
- any_value(cu.user_id) as user_id
- from corp_user cu inner join corp_user_auth ca on ca.corp_user_id = cu.id
- and ca.wx_corp_id = #{wxCorpId}
- <choose>
- <when test="userScope == 2">
- and cu.user_id != 0
- </when>
- <when test="userScope == 3">
- and cu.user_id = 0
- </when>
- </choose>
- inner join corp_user_follow_relation cufr on cufr.corp_user_id = ca.external_userid
- and cufr.wx_corp_id = #{wxCorpId}
- <if test="followIds != null and followIds.size() > 0">
- and cufr.follow_id in
- <foreach collection="followIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="list != null and list.size() > 0">
- and not exists (select s.corp_user_id from (select corp_user_id from corp_user_follow_relation cufr inner
- join `corp_user_tag` ct on ct.relation_id = cufr.id and ct.tag_id in
- <foreach collection="list" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- group by cufr.corp_user_id) s where s.corp_user_id = cufr.corp_user_id limit 1)
- </if>
- group by cufr.corp_user_id
- </select>
- </mapper>
|