123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- <?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.xlk.mapper.ChannelCustomerMapper">
-
- <select id="getProfileList" resultType="com.yunzhi.marketing.xlk.entity.ChannelCustomer">
- SELECT
- t.*,
- s.building_name,
- IFNULL( m.`name`, m.nickname ) AS recommend_person_name,
- IFNULL( m.tel, m.phone ) AS recommend_phone
- FROM
- xlk_channel_customer t
- LEFT JOIN ta_building s ON t.building_id = s.building_id
- INNER JOIN ta_person m ON t.recommend_person = m.person_id
- WHERE
- t.org_id = #{orgId}
- <if test="institutionIds != null and institutionIds.size > 0">
- AND t.institution_id in
- <foreach collection="institutionIds" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="buildingId != null and buildingId != ''">
- AND t.building_id = #{buildingId}
- </if>
- <if test="name != null and name != ''">
- AND t.`name` LIKE CONCAT( '%', #{name}, '%' )
- </if>
- <if test="phone != null and phone != ''">
- AND t.phone LIKE CONCAT( '%', #{phone}, '%' )
- </if>
- <if test="recommendPersonName != null and recommendPersonName != ''">
- AND m.nickname LIKE CONCAT( '%', #{recommendPersonName}, '%' )
- </if>
- <if test="recommendPhone != null and recommendPhone != ''">
- AND m.phone LIKE CONCAT( '%', #{recommendPhone}, '%' )
- </if>
- <if test="status != null and status != ''">
- AND t.`status` = #{status}
- </if>
- <if test="status == null or status == ''">
- AND t.`status` > -1
- </if>
- <if test="type == 'customer'">
- AND t.channel_id is null
- </if>
- <if test="type == 'channel'">
- AND t.channel_id is not null
- </if>
- ORDER BY
- t.create_date DESC
- </select>
- <select id="getRanklist" resultType="com.yunzhi.marketing.po.CustomerRankListVO">
- SELECT
- COUNT(1) as number,
- t.recommend_person,
- p.`name`,
- p.avatarurl
- FROM
- xlk_channel_customer t
- INNER JOIN xlk_customer_visit v on t.customer_id = v.customer_id
- LEFT JOIN ta_person p on t.recommend_person = p.person_id
- WHERE t.channel_id = #{params.channelId}
- <if test="params.startDate != null or params.endDate != null">
- AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
- </if>
- <if test="params.startDate == null or params.endDate == null">
- AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
- </if>
- GROUP BY t.recommend_person
- ORDER BY number desc
- LIMIT 3
- </select>
-
- <select id="getCustomersIRecommended" resultType="com.yunzhi.marketing.po.MineRecommendCustomerPO">
- SELECT
- a.*,
- b.avatarurl ,
- ifnull(c.`status`, 1) as customer_status,
- if(c.customer_id is null, "report", "customer") as type,
- IF(a.recommend_person_type = 'broker', m.expiration_days, d.expiration_date) as expiration_date,
- d.building_name
- FROM
- xlk_channel_customer a
- LEFT JOIN ta_person b ON a.person_id = b.person_id
- left join ta_recommend_customer c on a.customer_id = c.customer_id
- LEFT JOIN ta_building d on a.building_id = d.building_id
- LEFT JOIN bk_agreement m ON a.building_id = m.building_id
- WHERE
- a.recommend_person = #{params.personId}
- and a.org_id = #{params.orgId}
- <if test="params.status != null and params.status !=''">
- and c.status = #{params.status}
- </if>
- <if test="params.name != null and params.name !=''">
- and a.name like CONCAT('%',#{params.name}, '%')
- </if>
- <if test="params.startDate != null and params.startDate != null">
- AND a.create_date >= #{params.startDate}
- </if>
- <if test="params.endDate != null and params.endDate != null">
- AND (a.visit_date <= #{params.endDate} or a.preparatory_date <= #{params.endDate} or a.signed_date <= #{params.endDate} or a.commission_date <= #{params.endDate})
- </if>
- ORDER BY
- a.create_date desc
- </select>
- <select id="getNewCustomer" resultType="java.lang.Integer">
- SELECT
- COUNT(1)
- FROM
- xlk_channel_customer t
- WHERE t.channel_id = #{params.channelId}
- <if test="params.startDate != null or params.endDate != null">
- AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
- </if>
- <if test="params.startDate == null or params.endDate == null">
- AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
- </if>
- </select>
- <select id="getSuccessCustomer" resultType="java.lang.Integer">
- SELECT
- COUNT(1)
- FROM
- xlk_channel_customer t
- LEFT join ta_recommend_customer r on t.customer_id = r.customer_id
- WHERE t.channel_id = #{params.channelId}
- and r.`status` in (4,5)
- <if test="params.startDate != null or params.endDate != null">
- AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
- </if>
- <if test="params.startDate == null or params.endDate == null">
- AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
- </if>
- </select>
- <select id="getNewCustomerDetail" resultType="com.yunzhi.marketing.xlk.vo.CustomerDetailVO">
- SELECT
- <if test="params.type == 'day'">
- date_format( t.create_date, '%Y-%m-%d' ) as coordinate,
- </if>
- <if test="params.type == 'month'">
- date_format( t.create_date, '%Y-%m' ) as coordinate,
- </if>
- COUNT(1) as customerNum
- FROM
- xlk_channel_customer t
- WHERE t.channel_id = #{params.channelId}
- <if test="params.startDate != null or params.endDate != null">
- AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
- </if>
- <if test="params.startDate == null or params.endDate == null">
- AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
- </if>
- <if test="params.type == 'day'">
- group by date_format( t.create_date, '%Y-%m-%d' )
- </if>
- <if test="params.type == 'month'">
- group by date_format( t.create_date, '%Y-%m' )
- </if>
- </select>
- <select id="getSuccessCustomerDetail" resultType="com.yunzhi.marketing.xlk.vo.CustomerDetailVO">
- SELECT
- <if test="params.type == 'day'">
- date_format( t.create_date, '%Y-%m-%d' ) as coordinate,
- </if>
- <if test="params.type == 'month'">
- date_format( t.create_date, '%Y-%m' ) as coordinate,
- </if>
- COUNT(1) as customerNum
- FROM
- xlk_channel_customer t
- LEFT join ta_recommend_customer r on t.customer_id = r.customer_id
- WHERE t.channel_id = #{params.channelId}
- and r.`status` in (4,5)
- <if test="params.startDate != null or params.endDate != null">
- AND t.create_date BETWEEN #{params.startDate} and #{params.endDate}
- </if>
- <if test="params.startDate == null or params.endDate == null">
- AND t.create_date BETWEEN DATE_SUB(now(),INTERVAL 7 DAY) and now()
- </if>
- <if test="params.type == 'day'">
- group by date_format( t.create_date, '%Y-%m-%d' )
- </if>
- <if test="params.type == 'month'">
- group by date_format( t.create_date, '%Y-%m' )
- </if>
- </select>
- <select id="getMoreInfoById" resultType="com.yunzhi.marketing.xlk.entity.ChannelCustomer">
- SELECT
- t.*,
- s.channel_name,
- IFNULL(m.`name`, m.nickname) as recommend_person_name
- FROM
- xlk_channel_customer t
- LEFT JOIN ta_channel s ON t.channel_id = s.channel_id
- LEFT JOIN ta_person m ON m.person_id = t.recommend_person
- WHERE 1 = 1
- <if test="channelCustomerId != null and channelCustomerId != ''">
- AND t.channel_customer_id = #{channelCustomerId}
- </if>
- <if test="customerId != null and customerId != ''">
- AND t.customer_id = #{customerId}
- </if>
- </select>
- <select id="getRecommendedOrExpired" resultType="com.yunzhi.marketing.xlk.entity.ChannelCustomer">
- SELECT
- t.*
- FROM
- xlk_channel_customer t
- LEFT JOIN xlk_building_channel s ON t.building_id = s.building_id
- AND s.channel_id IS NOT NULL
- AND t.channel_id = s.channel_id
- LEFT JOIN bk_agreement m ON t.building_id = s.building_id
- AND s.channel_id IS NULL
- WHERE
- t.building_id = #{buildingId}
- AND t.phone = #{phone}
- AND (
- t.`status` = 2
- OR (
- t.`status` = 1
- AND IFNULL( s.expiration_date, IFNULL( m.expiration_days, 0 ) ) <= TIMESTAMPDIFF( DAY, t.create_date, now( ) )
- )
- )
- </select>
- <select id="getPageByBroker" resultType="com.yunzhi.marketing.xlk.entity.ChannelCustomer">
- SELECT
- t.channel_customer_id,
- t.create_date,
- t.org_id,
- t.building_id,
- fun_mix_str ( t.phone, 4 ) AS phone,
- t.`name`,
- t.picture,
- t.sex,
- t.person_id,
- t.`status`,
- t.channel_id,
- t.recommend_person,
- t.realty_consultant,
- t.remark,
- t.customer_id,
- t.visit_date,
- t.preparatory_date,
- t.signed_date,
- t.commission_date,
- t.institution_id,
- t.recommend_person_type,
- t.total_commission,
- t.unsettled_commission,
- t.settled_commission,
- s.building_name
- FROM
- xlk_channel_customer t
- INNER JOIN ta_building s ON t.building_id = s.building_id
- WHERE
- t.recommend_person = #{recommendPerson}
- <if test="name != null and name != ''">
- AND t.`name` LIKE CONCAT( '%', #{name}, '%' )
- </if>
- <if test="phone != null and phone != ''">
- AND t.phone LIKE CONCAT( '%', #{phone}, '%' )
- </if>
- AND t.`status` = 2
- -- AND t.`status` > -1
- ORDER BY
- t.create_date DESC
- </select>
- </mapper>
|