123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- <?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.huiju.estateagents.mapper.TaPersonMapper">
- <select id="selectCardList" resultType="java.util.HashMap">
- SELECT
- t.person_id AS id,
- t.name,
- t.company,
- t.department,
- t.post,
- t.tel AS phone,
- t.avatarurl AS avatar,
- t.photo
- FROM
- ta_person t
- WHERE
- t.person_type = #{personType}
- AND t.status = #{status}
- ORDER BY
- t.create_date DESC
- </select>
-
- <select id="selectBuildingConsultants" resultType="java.util.HashMap">
- SELECT
- t.person_id AS id,
- t.name,
- t.company,
- t.department,
- t.post,
- t.tel AS phone,
- t.avatarurl AS avatar,
- t.photo
- FROM
- ta_person t
- JOIN ta_person_building s USING (person_id)
- WHERE
- s.building_id = #{buildingId}
- AND t.person_type = #{personType}
- AND t. STATUS = #{status}
- ORDER BY
- t.create_date DESC
- </select>
-
- <select id="getSalesExecutive" resultType="com.huiju.estateagents.entity.TaPerson">
- SELECT
- *
- FROM
- ta_person t
- WHERE
- t.person_type = 'Sales Executive'
- AND t.status = 1
- LIMIT 1
- </select>
-
- <select id="getPersonByOpenId" resultType="com.huiju.estateagents.entity.TaPerson">
- SELECT
- *
- FROM
- ta_person t
- WHERE
- t.mini_openid = #{openId}
- AND IFNULL(t.status, 0) > -1
- </select>
-
- <update id="setFieldIncrement">
- UPDATE ta_person
- SET ${field} = IFNULL(${field}, 0) + #{increment}
- WHERE person_id = #{personId}
- </update>
-
- <select id="selectCustomer" resultType="com.huiju.estateagents.entity.TaPerson">
- SELECT
- a.*,
- b.event as event,
- b.activity as activity,
- b.data as data,
- (select b.visit_time FROM ta_person_visit_record b where a.person_id = b.person_id ORDER BY b.visit_time desc LIMIT 1) as visitTime
- FROM
- ta_person a
- LEFT JOIN ta_person_visit_record b ON a.person_id = b.person_id
- WHERE
- a.person_type IS NULL
- ORDER BY create_date desc
- </select>
-
- <select id="getById" resultType="com.huiju.estateagents.entity.TaPerson">
- SELECT
- a.*
- FROM
- ta_person a
- WHERE
- a.person_id = #{personId}
- </select>
-
- <select id="getUserProjects" resultType="java.lang.String">
- SELECT
- b.building_name
- FROM
- ta_person_building a
- LEFT JOIN ta_building b ON a.building_id = b.building_id
- WHERE a.person_id = #{personId}
- </select>
-
- <select id="selectByIdPerson" resultType="com.huiju.estateagents.entity.TaPerson">
- select * from ta_person where mini_openid = #{openid};
-
- </select>
-
- <select id="getConsultantByName" resultType="java.lang.String">
- select person_id from ta_person where name like CONCAT('%',#{name}, '%')
- </select>
-
- <select id="getConsultantByTel" resultType="java.lang.String">
- select person_id from ta_person where tel = #{tel}
- </select>
-
- <select id="selectCardListofMine" resultType="java.util.HashMap">
- SELECT
- t.person_id AS id,
- t.name,
- t.company,
- t.department,
- t.post,
- t.tel AS phone,
- t.avatarurl AS avatar,
- t.photo
- FROM
- ta_person t
- WHERE
- t.person_type = #{personType}
- AND t.status = #{status}
- <if test="personIds != null">
- and t.person_id in
- <foreach collection="personIds" item="personIds" index="index" open="(" close=")" separator=",">
- #{ordersId}
- </foreach>
- </if>
- ORDER BY
- t.create_date DESC
- </select>
-
-
- <select id="selectRecentlyCount" resultType="integer" >
- SELECT
- SUM(activity_count) as activity_count
- FROM
- (
- SELECT
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
- FROM
- sequence a
- WHERE
- <if test="startDate == null or endDate == null">
- a.rownum <![CDATA[ <= ]]> 7
- </if>
- <if test="startDate != null or endDate != null">
- a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
- </if>
- ) AS temp_date
- LEFT JOIN (
- SELECT
- COUNT(1) as activity_count,
- tpvr.visit_time AS visit_time
- FROM
- ta_person tp
- INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
- where ifnull(tp.person_type, '') != #{personType}
- ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
- </select>
-
-
- <select id="selectUserBehavior" resultType="com.huiju.estateagents.po.PersonPO">
- SELECT
- *
- FROM
- (
- SELECT
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
- FROM
- sequence a
- WHERE
- <if test="startDate == null or endDate == null">
- a.rownum <![CDATA[ <= ]]> 7
- </if>
- <if test="startDate != null or endDate != null">
- a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
- </if>
- ) AS temp_date
- LEFT JOIN (
- SELECT
- COUNT(1) as activityCount,
- tpvr.visit_time AS visitTime,
- tbet.type_name as activity
- FROM
- ta_person tp
- INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
- INNER JOIN td_biz_event_type tbet ON tpvr.event_type = tbet.type_id
- where ifnull(tp.person_type, '') != #{personType}
- GROUP BY tpvr.activity
- ) AS temp ON temp_date.date = DATE_FORMAT( temp.visitTime , '%Y-%m-%d' )
- </select>
-
- <select id="selectActiveUserCount" resultType="map">
- SELECT
- *
- FROM
- (
- SELECT
- <if test="dateType == 'day'.toString()">
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
- </if>
- <if test="dateType == 'week'.toString()">
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum WEEK ), '%Y-%m-%d' ) AS date
- </if>
- <if test="dateType == 'month'.toString()">
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum MONTH ), '%Y-%m-%d' ) AS date
- </if>
- FROM
- sequence a
- WHERE
- <if test="startDate == null or endDate == null">
- a.rownum <![CDATA[ <= ]]> 7
- </if>
- <if test="startDate != null or endDate != null">
- a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
- </if>
- ) AS temp_date
- LEFT JOIN (
- SELECT
- COUNT(1) as activity_count,
- tpvr.visit_time AS visit_time
- FROM
- ta_person tp
- INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
- where ifnull(tp.person_type, '') != #{personType}
- ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
- </select>
-
- <select id="selectNewsUserCount" resultType="map">
- SELECT
- authorization_count_table.date as date,
- authorization_count_table.authorization_count as authorization_count,
- user_count_table.user_count as user_count
- FROM
- (
- SELECT
- *
- FROM
- (
- SELECT
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
- FROM
- sequence a
- WHERE
- <if test="startDate == null or endDate == null">
- a.rownum <![CDATA[ <= ]]> 7
- </if>
- <if test="startDate != null or endDate != null">
- a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
- </if>
- ) AS temp_date
- LEFT JOIN (
- SELECT
- COUNT(1) as authorization_count,
- tpvr.visit_time AS visit_time
- FROM
- ta_person tp
- INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
- where ifnull(tp.person_type, '') != #{personType}
- and tp.phone is NOT NULL
- ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
- ) as authorization_count_table
- ,
- (SELECT
- *
- FROM
- (
- SELECT
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
- FROM
- sequence a
- WHERE
- <if test="startDate == null or endDate == null">
- a.rownum <![CDATA[ <= ]]> 7
- </if>
- <if test="startDate != null or endDate != null">
- a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
- </if>
- ) AS temp_date
- LEFT JOIN (
- SELECT
- COUNT(1) as user_count,
- tpvr.visit_time AS visit_time
- FROM
- ta_person tp
- INNER JOIN ta_person_visit_record tpvr ON tp.person_id = tpvr.person_id
- where ifnull(tp.person_type, '') != #{personType}
- ) AS temp ON temp_date.date = DATE_FORMAT( temp.visit_time , '%Y-%m-%d' )
-
- ) as user_count_table
- GROUP BY date
- </select>
-
- <select id="selectUserSourcePie" resultType="integer">
- select count(1)
- FROM ta_person
- WHERE ifnull(person_type, '') != #{personType}
- <if test="recommendPersonType != null and recommendPersonType != ''">
- and recommend_person_type = #{recommendPersonType}
- </if>
- </select>
-
- <select id="selectUserSourceColumnar" resultType="map">
- SELECT
- tpf.from_name as from_name,
- (
- SELECT
- COUNT(1)
- FROM ta_person tps
- LEFT JOIN td_person_from tpfs
- ON tps.from_code = tpfs.from_code
- WHERE tpfs.from_code = tpf.from_code and tps.phone is NOT NULL
- and ifnull(tps.person_type, '') != #{personType}
- <if test="startDate != null or endDate != null">
- and tps.create_date BETWEEN #{startDate} and #{endDate}
- </if>
- <if test="startDate == null or endDate == null">
- and tps.create_date BETWEEN DATE_SUB( tps.create_date, INTERVAL 7 DAY ) and now()
- </if>
- ) as registered,
- (
- SELECT
- COUNT(1)
- FROM ta_person tps
- LEFT JOIN td_person_from tpfs
- ON tps.from_code = tpfs.from_code
- WHERE tpfs.from_code = tpf.from_code
- and ifnull(tps.person_type, '') != #{personType}
- <if test="startDate != null or endDate != null">
- and tps.create_date BETWEEN #{startDate} and #{endDate}
- </if>
- <if test="startDate == null or endDate == null">
- and tps.create_date BETWEEN DATE_SUB( tps.create_date, INTERVAL 7 DAY ) and now()
- </if>
- ) as user_count
-
- FROM td_person_from tpf
- LEFT JOIN ta_person tp
- ON tp.from_code = tpf.from_code
- where ifnull(tp.person_type, '') != #{personType}
- GROUP BY tpf.from_code
- </select>
-
- <select id="selectUserSourceData" resultType="map">
- select
- *
- FROM
- (
- SELECT
- DATE_FORMAT( DATE_SUB( now( ), INTERVAL a.rownum DAY ), '%Y-%m-%d' ) AS date
- FROM
- sequence a
- WHERE
- <if test="startDate == null or endDate == null">
- a.rownum <![CDATA[ <= ]]> 7
- </if>
- <if test="startDate != null or endDate != null">
- a.rownum <![CDATA[ <= ]]> datediff(#{endDate}, #{startDate})
- </if>
- ) AS temp_date
- LEFT JOIN
- (
- SELECT
- COUNT(1) as count,
- tps.create_date as create_date,
- tpfs.from_code as from_code,
- tpfs.from_name as from_name
- FROM ta_person tps
- LEFT JOIN td_person_from tpfs
- ON tps.from_code = tpfs.from_code
- WHERE tpfs.from_code = tps.from_code
- and ifnull(tps.person_type, '') != #{personType}
- GROUP BY tpfs.from_code
- ) as user_count
- ON DATE_FORMAT(user_count.create_date,'%Y-%m-%d') = temp_date.date
- </select>
-
- </mapper>
|