123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- <?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 in ('estate agent', 'channel 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 like concat(concat("%",#{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,
- (select tpp.name from ta_share_person_from tspf left join ta_person tpp on tspf.share_person = tpp.person_id where tspf.building_id = #{building} and tspf.is_first_time = 1 and a.person_id = tspf.person_id) as sharePersonName
- 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 a.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 like CONCAT('%',#{name}, '%')
- </if>
- <if test="tel != null and tel!=''">
- and a.phone like CONCAT('%',#{tel}, '%')
- </if>
- <if test="consultName != null and consultName !=''">
- and b.name like CONCAT('%',#{consultName}, '%')
- </if>
- <if test="consultTel != null and consultTel !=''">
- and b.tel like CONCAT('%',#{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="status != null and status !=''">
- and a.status = #{status}
- </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 like CONCAT('%',#{name}, '%')
- </if>
- <if test="tel != null and tel!=''">
- and b.phone like CONCAT('%',#{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>
- <if test="consultTel != null and consultTel !=''">
- and b.tel like CONCAT('%',#{consultTel}, '%')
- </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,
- c.nickname as recommend,
- c.phone as recommendTel,
- if(a.verify_status = 0, '未通过', if(a.verify_status = 1, '已通过', if(a.verify_status = 2, '已驳回', ''))) as verifyStatusName
- 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
- a.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,
- if(ifnull(tc.channel_name, '') != '', '渠道经纪人', '独立经纪人') as personType,
- tc.channel_name as channelName,
- (
- SELECT
- count( 1 )
- FROM
- ta_recommend_customer tarc
- LEFT JOIN ta_person tp ON tarc.recommend_person = tp.person_id
- WHERE
- tarc.recommend_person = a.person_id and ifnull(tp.person_type, '') = 'customer'
- ) AS recommedCount,
- (
- SELECT
- count( 1 )
- FROM
- ta_recommend_customer tarc
- LEFT JOIN ta_person tp ON tarc.recommend_person = tp.person_id
- WHERE
- tarc.recommend_person = a.person_id and ifnull(tp.person_type, '') in ('channel agent', 'estate agent')
- ) AS agentCount
- 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>
- ifnull(a.person_type, '') in ('channel agent', 'estate agent')
- and a.status >0
- <if test="orgId != null">
- and a.org_id = #{orgId}
- </if>
-
- </where>
-
- ORDER BY
- a.create_date DESC
- limit #{pageCode}, #{pageSize}
- </select>
-
-
- <select id="getPublicCustomerExportListCount" resultType="Integer">
- SELECT
- count(1)
- 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 like CONCAT('%',#{name}, '%')
- </if>
- <if test="tel != null and tel!=''">
- and b.phone like CONCAT('%',#{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>
- <if test="consultTel != null and consultTel !=''">
- and b.tel like CONCAT('%',#{consultTel}, '%')
- </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="getPublicCustomerExportList" resultType="com.huiju.estateagents.excel.PublicCustomerExport">
- SELECT
- b.nickname as nickname,
- b.phone as phone,
- if(b.sex = 1, '男', if(b.sex = 2, '女', '未知')) as sex
- 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 like CONCAT('%',#{name}, '%')
- </if>
- <if test="tel != null and tel!=''">
- and b.phone like CONCAT('%',#{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>
- <if test="consultTel != null and consultTel !=''">
- and b.tel like CONCAT('%',#{consultTel}, '%')
- </if>
- and NOT EXISTS ( select * from ta_recommend_customer a where a.recommend_person = b.person_id)
- </where>
- order by b.create_date desc
- limit #{pageCode}, #{pageSize}
- </select>
-
- <select id="getCustomerExportListCount" resultType="Integer" >
- SELECT
- count(1)
- 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 like CONCAT('%',#{name}, '%')
- </if>
- <if test="tel != null and tel!=''">
- and a.phone like CONCAT('%',#{tel}, '%')
- </if>
- <if test="consultName != null and consultName !=''">
- and b.name like CONCAT('%',#{consultName}, '%')
- </if>
- <if test="consultTel != null and consultTel !=''">
- and b.tel like CONCAT('%',#{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="status != null and status !=''">
- and a.status = #{status}
- </if>
- <if test="sex != null and sex !=''">
- and a.sex = #{sex}
- </if>
- </where>
- order by a.create_date desc
- </select>
-
-
- <select id="getCustomerExportList" resultType="com.huiju.estateagents.excel.PrivateCustomerExport">
- SELECT
- a.name AS name,
- a.phone as phone,
- 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
- 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 like CONCAT('%',#{name}, '%')
- </if>
- <if test="tel != null and tel!=''">
- and a.phone like CONCAT('%',#{tel}, '%')
- </if>
- <if test="consultName != null and consultName !=''">
- and b.name like CONCAT('%',#{consultName}, '%')
- </if>
- <if test="consultTel != null and consultTel !=''">
- and b.tel like CONCAT('%',#{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="status != null and status !=''">
- and a.status = #{status}
- </if>
- <if test="sex != null and sex !=''">
- and a.sex = #{sex}
- </if>
- </where>
- order by a.create_date desc
- limit #{pageCode}, #{pageSize}
- </select>
-
- </mapper>
|