123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- <?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.TaRecommendCustomerMapper">
- <select id="getMyCutsomerNum" resultType="int">
- SELECT
- count(*) AS total
- FROM
- ta_recommend_customer t
- WHERE
- t.recommend_person = #{personId}
- AND t.status > -1
- </select>
- <select id="getCustomerPersonId" resultType="java.lang.String">
- SELECT
- person_id
- FROM
- ta_customer_person
- WHERE
- customer_id = #{customerId}
- </select>
-
- <select id="getCustomerDetail" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
- SELECT
- a.*,
- (select c.visit_time FROM ta_person_visit_record c where c.person_id = #{personId} ORDER BY c.visit_time desc LIMIT 1) as visitTime,
- (SELECT SUM(d.visit_duration) FROM ta_person_visit_record d WHERE d.person_id= #{personId}) as duration
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_person_visit_record c ON a.person_id = c.person_id
- where a.customer_id = #{customerId}
- GROUP BY a.customer_id
- </select>
-
- <select id="getRecCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
- SELECT
- a.*,
- a.customer_id as customerId,
- c.phone as recommendTel,
- c.nickname as recommendName
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_person c on a.recommend_person = c.person_id
- <where>
- a.status > 0
- and a.report_recommend_status = 2
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
- <if test="building != null and building !=''">
- and a.building_id = #{building}
- </if>
- <if test="name != null and name !=''">
- and a.name = #{name}
- </if>
- <if test="tel != null and tel!=''">
- and a.phone = #{tel}
- </if>
- <if test="consultName != null and consultName !=''">
- and c.nickname like CONCAT('%',#{consultName}, '%')
- </if>
- <if test="consultTel != null and consultTel !=''">
- and c.phone = #{consultTel}
- </if>
- <if test="entryType != null and entryType !=''">
- and a.entry_type = #{entryType}
- </if>
- <if test="verifyStatus != null and verifyStatus !=''">
- and a.verify_status = #{verifyStatus}
- </if>
- <if test="sex != null and sex !=''">
- and a.sex = #{sex}
- </if>
- </where>
- order by a.create_date desc
- </select>
-
- <select id="getIndependentAgents" resultType="com.huiju.estateagents.entity.TaPerson">
- SELECT
- a.*,
- tc.channel_name as channelName
- FROM
- ta_person a
- left join ta_channel_person tcp on a.person_id = tcp.person_id
- left join ta_channel tc on tc.channel_id = tcp.channel_id
- <where>
- a.person_type = 'estate agent'
- and a.status >0
- <if test="name != null and name !=''">
- and a.nickname = #{name}
- </if>
- <if test="tel != null and tel!=''">
- and a.phone = #{tel}
- </if>
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
-
- </where>
-
- ORDER BY
- create_date DESC
- </select>
-
- <select id="getRepCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
- SELECT
- a.*,
- a.customer_id AS customerId,
- b.NAME AS consultantName,
- b.tel AS consultTel
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
- <where>
- a.status > 0
- and a.report_recommend_status = 1
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
- <if test="building != null and building !=''">
- and a.building_id = #{building}
- </if>
- <if test="name != null and name !=''">
- and a.name = #{name}
- </if>
- <if test="tel != null and tel!=''">
- and a.phone = #{tel}
- </if>
- <if test="consultName != null and consultName !=''">
- and b.name like CONCAT('%',#{consultName}, '%')
- </if>
- <if test="consultTel != null and consultTel !=''">
- and b.tel = #{consultTel}
- </if>
- <if test="entryType != null and entryType !=''">
- and a.entry_type = #{entryType}
- </if>
- <if test="verifyStatus != null and verifyStatus !=''">
- and a.verify_status = #{verifyStatus}
- </if>
- <if test="sex != null and sex !=''">
- and a.sex = #{sex}
- and a.org_id = #{orgid}
- </if>
- </where>
- order by a.create_date desc
- </select>
- <select id="getCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
- SELECT
- a.*,
- a.customer_id as customerId,
- b.name as consultantName,
- b.tel as consultTel,
- c.nickname as recommendName,
- c.tel as recommendTel
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
- LEFT JOIN ta_person c on a.recommend_person = c.person_id
- <where>
- a.status > 0
- and realty_consultant is not null
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
- <if test="building != null and building !=''">
- and a.building_id = #{building}
- </if>
- <if test="name != null and name !=''">
- and a.name = #{name}
- </if>
- <if test="tel != null and tel!=''">
- and a.phone = #{tel}
- </if>
- <if test="consultName != null and consultName !=''">
- and b.name like CONCAT('%',#{consultName}, '%')
- </if>
- <if test="consultTel != null and consultTel !=''">
- and b.tel = #{consultTel}
- </if>
- <if test="entryType != null and entryType !=''">
- and a.entry_type = #{entryType}
- </if>
- <if test="verifyStatus != null and verifyStatus !=''">
- and a.verify_status = #{verifyStatus}
- </if>
- <if test="sex != null and sex !=''">
- and a.sex = #{sex}
- </if>
- </where>
- order by a.create_date desc
- </select>
- <select id="getCustomerById" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
- SELECT
- a.*,
- b.name as consultantName
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
- WHERE a.customer_id = #{customerId}
- </select>
-
- <select id="getPublicCustomerList" resultType="com.huiju.estateagents.entity.TaPerson">
- SELECT
- b.*
- FROM
- ta_person b
- <where>
- b.status > 0
- AND IFNULL(b.person_type, '') in ('estate agent', 'customer')
- <if test="name != null and name !=''">
- and b.nickname = #{name}
- </if>
- <if test="tel != null and tel!=''">
- and b.phone = #{tel}
- </if>
- <if test="entryType != null and entryType !=''">
- and b.entry_type = #{entryType}
- </if>
- <if test="sex != null and sex !=''">
- and b.sex = #{sex}
- </if>
- <if test="orgId != null">
- and b.org_id = #{orgId}
- </if>
- and NOT EXISTS ( select * from ta_recommend_customer a where a.recommend_person = b.person_id)
- </where>
- order by b.create_date desc
- </select>
-
- <select id="getRecCustomerExport" resultType="com.huiju.estateagents.excel.ExcelRecommendCustomer">
- SELECT
- a.name as name,
- a.phone as phone,
- a.intention as intention,
- a.create_date as createDate,
- if(a.sex = 1, '男',if(a.sex = 2, '女', '未知')) as sex,
- concat(c.nickname, c.phone) as recommend
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_person c on a.recommend_person = c.person_id
- <where>
- a.status > 0
- and a.report_recommend_status = 2
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
- </where>
- order by a.create_date desc
- limit #{pageCode}, #{pageSize}
- </select>
-
- <select id="getRecCustomerExportCount" resultType="java.lang.Integer">
- SELECT
- count(*)
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_person c on a.recommend_person = c.person_id
- <where>
- a.status > 0
- and a.report_recommend_status = 2
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
- </where>
- </select>
-
- <select id="getRepCustomerReportCount" resultType="java.lang.Integer">
- SELECT
- count(*)
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
- <where>
- a.status > 0
- and a.report_recommend_status = 1
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
- </where>
- </select>
-
- <select id="getRepCustomerReportExport" resultType="com.huiju.estateagents.excel.ReporRecommendCustomer" >
- SELECT
- a.name as name,
- a.phone as phone,
- a.intention as intention,
- if(a.sex = 1, '男',if(a.sex = 2, '女', '未知')) as sex,
- b.NAME AS consultantName,
- b.tel AS consultTel
- FROM
- ta_recommend_customer a
- LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
- <where>
- a.status > 0
- and a.report_recommend_status = 1
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
- </where>
- order by a.create_date desc
- limit #{pageCode}, #{pageSize}
- </select>
-
-
- <select id="getIndependentAgentsCount" resultType="java.lang.Integer">
- SELECT
- count(*)
- FROM
- ta_person a
- left join ta_channel_person tcp on a.person_id = tcp.person_id
- left join ta_channel tc on tc.channel_id = tcp.channel_id
- <where>
- a.person_type = 'estate agent'
- and a.status >0
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
- </where>
-
- ORDER BY
- create_date DESC
- </select>
-
- <select id="getIndependentAgentsExport" resultType="com.huiju.estateagents.excel.AgentsRecommendCustomer">
- SELECT
- a.nickname as nickname,
- a.phone as phone,
- if(a.gender = '1', '男', if(a.gender = '2', '女', '未知')) as gender,
- a.personType as personType,
- if(ifnull(tc.channel_name, '') != '', '渠道经纪人', '独立经纪人') as channelName
- FROM
- ta_person a
- left join ta_channel_person tcp on a.person_id = tcp.person_id
- left join ta_channel tc on tc.channel_id = tcp.channel_id
- <where>
- a.person_type = 'estate agent'
- and a.status >0
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
-
- </where>
-
- ORDER BY
- a.create_date DESC
- </select>
-
- </mapper>
|