123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- <?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.yunzhi.marketing.center.taUser.mapper.TaUserMapper">
-
- <select id="getPageList" resultType="map">
- SELECT
- t.user_id AS userId,
- t.org_id AS orgId,
- t.user_name AS userName,
- t.login_name AS loginName,
- t.phone,
- t.avatar,
- t.create_date AS createDate,
- t.status,
- o.NAME AS orgName,
- o.address,
- o.logo,
- o.remark,
- m.miniapp_id AS miniappId,
- m.secret,
- m.token,
- m.NAME AS miniappName,
- m.qr_code AS qrCode,
- t.exp_date as expire_date,
- m.org_id
- FROM
- ta_user t
- LEFT JOIN ta_org o ON t.org_id = o.org_id
- LEFT JOIN ta_miniapp m ON o.org_id = m.org_id
- left join ta_channel_app_relation n on o.org_id = n.org_id
- left join ta_channel_proxy z on z.channel_id = n.channel_id
- WHERE
- t.is_admin =1 AND ifnull(t.not_show, 0) != 1
- <if test="channelId != null and channelId != ''">
- and n.channel_id = #{channelId}
- </if>
- <if test="miniAppName != null and miniAppName != ''">
- and m.name like CONCAT('%', #{miniAppName}, '%')
- </if>
- </select>
-
- <select id="getTagsList" resultType="com.yunzhi.marketing.center.taUser.entity.TaTags">
- SELECT
- t.*
- FROM
- ta_tag_user u
- LEFT JOIN ta_tags t ON u.tag_id = t.tag_id
- AND t.org_id = #{orgId}
- WHERE
- u.user_id = #{userId}
- </select>
-
- <select id="getUserList" resultType="com.yunzhi.marketing.center.taUser.entity.TaUser">
- SELECT
- *
- FROM
- ta_user
- WHERE
- org_id = #{orgId}
- and phone = #{phone}
- </select>
- <select id="seleUserList" resultType="com.yunzhi.marketing.center.taUser.entity.TaUser">
- SELECT
- t.*,
- b.building_id,
- d.person_id as consultant_person_id,
- if(d.person_id is not null,1,0) as mini_status
- FROM
- ta_user t
- LEFT JOIN ta_person_building b ON t.user_id = b.user_id
- LEFT JOIN ta_person d on t.user_id = d.user_id
- WHERE
- t.org_id = #{taUser.orgId} AND (t.is_admin != 1 or t.is_admin is null)
- <if test="taUser.userName != null and taUser.userName != ''">
- and t.user_name like CONCAT('%', #{taUser.userName}, '%')
- </if>
- <if test="taUser.phone != null and taUser.phone != ''">
- and t.phone like CONCAT('%', #{taUser.phone}, '%')
- </if>
- <if test="taUser.status != null and taUser.status != ''">
- and t.status = #{taUser.status}
- </if>
- <if test="taUser.jobNumber != null and taUser.jobNumber != ''">
- and t.job_number like CONCAT('%', #{taUser.jobNumber}, '%')
- </if>
- <if test="taUser.isConsultant != null">
- and t.is_consultant = #{taUser.isConsultant}
- </if>
- <if test="taUser.miniStatus == 0">
- and d.person_id is null
- </if>
- <if test="taUser.miniStatus != null and taUser.miniStatus != '' and taUser.miniStatus == 1">
- and d.person_id is not null
- </if>
- <if test="taUser.buildingId != null and taUser.buildingId != ''">
- and b.building_id = #{taUser.buildingId}
- </if>
- <if test="personBuildingList != null and personBuildingList.size > 0">
- AND b.building_id in
- <foreach collection="personBuildingList" item="personBuilding" open="(" close=")" separator=",">
- #{personBuilding.buildingId}
- </foreach>
- </if>
- GROUP BY user_id
- order by t.weight desc, create_date desc
- </select>
-
- <select id="validateWeight" resultType="integer">
- select count(*) from ta_user t
- LEFT JOIN ta_person_building a on t.user_id = a.user_id
- where 1=1
- <if test="weight != null and weight != ''">
- and t.weight = #{weight}
- </if>
- <if test="buildingIds != null and buildingIds.size() > 0 ">
- and a.building_id in
- <foreach collection="buildingIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="buildingId != null and buildingId != '' ">
- and a.building_id = #{buildingId}
- </if>
- <if test="userId != null and userId != ''">
- and t.user_id != #{userId}
- </if>
- </select>
-
- <select id="getAdminByAppID" resultType="com.yunzhi.marketing.center.taUser.entity.TaUser">
- SELECT
- m.*
- FROM
- ta_miniapp t
- JOIN ta_user m USING (org_id)
- WHERE
- t.miniapp_id = #{appid}
- AND m.is_admin = 1
- </select>
-
- <select id="getBuildingIdsOf" resultType="java.lang.String">
- select building_id from ta_person_building
- where user_id = #{userId}
- <if test="buildingId != null and buildingId != ''">
- and building_id = #{buildingId}
- </if>
- </select>
-
- <select id="getUserByPerson" resultType="com.yunzhi.marketing.center.taUser.entity.TaUser">
- SELECT
- t.*
- FROM
- ta_user t
- INNER JOIN ta_person s ON s.org_id = #{orgId} AND s.user_id = t.user_id
- WHERE
- t.org_id = #{orgId}
- AND s.person_id = #{personId}
- AND t.status > -1
- Limit 1
- </select>
-
- <select id="selectPageList" resultType="com.yunzhi.marketing.center.taUser.entity.TaUserVO">
- SELECT
- s.person_id as user_id,
- t.user_id as real_user_id,
- t.*
- FROM
- ta_user t
- INNER JOIN ta_person s ON s.user_id = t.user_id
- where
- t.is_consultant = 1
- and t.status = 1
- <if test="idLists != null and idLists.size() > 0 ">
- and t.user_id in
- <foreach collection="idLists" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
-
- </mapper>
|