TaRecommendCustomerMapper.xml 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.huiju.estateagents.mapper.TaRecommendCustomerMapper">
  4. <select id="getMyCutsomerNum" resultType="int">
  5. SELECT
  6. count(*) AS total
  7. FROM
  8. ta_recommend_customer t
  9. WHERE
  10. t.recommend_person = #{personId}
  11. AND t.status &gt; -1
  12. </select>
  13. <select id="getCustomerPersonId" resultType="java.lang.String">
  14. SELECT
  15. person_id
  16. FROM
  17. ta_customer_person
  18. WHERE
  19. customer_id = #{customerId}
  20. </select>
  21. <select id="getCustomerDetail" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  22. SELECT
  23. a.*,
  24. (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,
  25. (SELECT SUM(d.visit_duration) FROM ta_person_visit_record d WHERE d.person_id= #{personId}) as duration
  26. FROM
  27. ta_recommend_customer a
  28. LEFT JOIN ta_person_visit_record c ON a.person_id = c.person_id
  29. where a.customer_id = #{customerId}
  30. GROUP BY a.customer_id
  31. </select>
  32. <select id="getRecCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  33. SELECT
  34. a.*,
  35. a.customer_id as customerId,
  36. c.phone as recommendTel,
  37. c.nickname as recommendName
  38. FROM
  39. ta_recommend_customer a
  40. LEFT JOIN ta_person c on a.recommend_person = c.person_id
  41. <where>
  42. a.status > 0
  43. and a.report_recommend_status = 2
  44. <if test="orgId != null">
  45. and a.org_id = #{orgId}
  46. </if>
  47. <if test="building != null and building !=''">
  48. and a.building_id = #{building}
  49. </if>
  50. <if test="name != null and name !=''">
  51. and a.name like CONCAT('%',#{name}, '%')
  52. </if>
  53. <if test="tel != null and tel!=''">
  54. and a.phone like CONCAT('%',#{tel}, '%')
  55. </if>
  56. <if test="consultName != null and consultName !=''">
  57. and c.nickname like CONCAT('%',#{consultName}, '%')
  58. </if>
  59. <if test="consultTel != null and consultTel !=''">
  60. and c.phone like CONCAT('%',#{consultTel}, '%')
  61. </if>
  62. <if test="entryType != null and entryType !=''">
  63. and a.entry_type = #{entryType}
  64. </if>
  65. <if test="verifyStatus != null and verifyStatus !=''">
  66. and a.verify_status = #{verifyStatus}
  67. </if>
  68. <if test="sex != null and sex !=''">
  69. and a.sex = #{sex}
  70. </if>
  71. </where>
  72. order by a.create_date desc
  73. </select>
  74. <select id="getIndependentAgents" resultType="com.huiju.estateagents.entity.TaPerson">
  75. SELECT
  76. a.*,
  77. tc.channel_name as channelName
  78. FROM
  79. ta_person a
  80. left join ta_channel_person tcp on a.person_id = tcp.person_id
  81. left join ta_channel tc on tc.channel_id = tcp.channel_id
  82. <where>
  83. a.person_type in ('estate agent', 'channel agent')
  84. and a.status >0
  85. <if test="name != null and name !=''">
  86. and a.nickname = #{name}
  87. </if>
  88. <if test="tel != null and tel!=''">
  89. and a.phone = #{tel}
  90. </if>
  91. <if test="orgId != null">
  92. and a.org_id = #{orgId}
  93. </if>
  94. </where>
  95. ORDER BY
  96. create_date DESC
  97. </select>
  98. <select id="getRepCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  99. SELECT
  100. a.*,
  101. a.customer_id AS customerId,
  102. b.NAME AS consultantName,
  103. b.tel AS consultTel,
  104. c.building_name as intentionName
  105. FROM
  106. ta_recommend_customer a
  107. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  108. LEFT JOIN ta_building c ON a.building_id = c.building_id
  109. <where>
  110. a.status > 0
  111. and a.report_recommend_status = 1
  112. <if test="orgId != null">
  113. and a.org_id = #{orgId}
  114. </if>
  115. <if test="building != null and building !=''">
  116. and a.building_id = #{building}
  117. </if>
  118. <if test="name != null and name !=''">
  119. and a.name = #{name}
  120. </if>
  121. <if test="tel != null and tel!=''">
  122. and a.phone like concat(concat("%",#{tel}),"%")
  123. </if>
  124. <if test="consultName != null and consultName !=''">
  125. and b.name like CONCAT('%',#{consultName}, '%')
  126. </if>
  127. <if test="consultTel != null and consultTel !=''">
  128. and b.tel = #{consultTel}
  129. </if>
  130. <if test="entryType != null and entryType !=''">
  131. and a.entry_type = #{entryType}
  132. </if>
  133. <if test="verifyStatus != null and verifyStatus !=''">
  134. and a.verify_status = #{verifyStatus}
  135. </if>
  136. <if test="sex != null and sex !=''">
  137. and a.sex = #{sex}
  138. and a.org_id = #{orgid}
  139. </if>
  140. </where>
  141. order by a.create_date desc
  142. </select>
  143. <select id="getCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  144. SELECT
  145. a.*,
  146. a.customer_id as customerId,
  147. IFNULL(b.name,d.user_name) as consultantName,
  148. IFNULL(b.tel,d.phone) as consultTel,
  149. c.nickname as recommendName,
  150. c.tel as recommendTel,
  151. IFNULL(c.name,c.nickname) AS sharePersonName
  152. FROM
  153. ta_recommend_customer a
  154. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  155. LEFT JOIN ta_person c on a.recommend_person = c.person_id
  156. LEFT JOIN ta_user d on d.user_id = a.realty_consultant
  157. <where>
  158. a.status > 0
  159. and a.verify_status = 1
  160. and a.realty_consultant is not null
  161. <if test="orgId != null">
  162. and a.org_id = #{orgId}
  163. </if>
  164. <if test="building != null and building !=''">
  165. and a.building_id = #{building}
  166. </if>
  167. <if test="name != null and name !=''">
  168. and a.name like CONCAT('%',#{name}, '%')
  169. </if>
  170. <if test="tel != null and tel!=''">
  171. and a.phone like CONCAT('%',#{tel}, '%')
  172. </if>
  173. <if test="consultName != null and consultName !=''">
  174. and IFNULL(b.name,d.user_name) like CONCAT('%',#{consultName}, '%')
  175. </if>
  176. <if test="consultTel != null and consultTel !=''">
  177. and IFNULL(b.tel,d.phone) like CONCAT('%',#{consultTel}, '%')
  178. </if>
  179. <if test="entryType != null and entryType !=''">
  180. and a.entry_type = #{entryType}
  181. </if>
  182. <if test="verifyStatus != null and verifyStatus !=''">
  183. and a.verify_status = #{verifyStatus}
  184. </if>
  185. <if test="status != null and status !=''">
  186. and a.status = #{status}
  187. </if>
  188. <if test="sex != null and sex !=''">
  189. and a.sex = #{sex}
  190. </if>
  191. </where>
  192. order by a.create_date desc
  193. </select>
  194. <select id="getCustomerById" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  195. SELECT
  196. a.*,
  197. b.name as consultantName
  198. FROM
  199. ta_recommend_customer a
  200. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  201. WHERE a.customer_id = #{customerId}
  202. </select>
  203. <select id="getPublicCustomerList" resultType="com.huiju.estateagents.entity.TaPerson">
  204. SELECT
  205. b.*,
  206. (
  207. SELECT
  208. IF
  209. ( ifnull( tpp.NAME, '' ) != '', tpp.NAME, tpp.nickname )
  210. FROM
  211. ta_share_person_from tspf
  212. LEFT JOIN ta_person tpp ON tspf.share_person = tpp.person_id
  213. WHERE
  214. tspf.is_first_time = 1
  215. AND b.person_id = tspf.person_id
  216. ORDER BY
  217. tspf.create_date ASC
  218. LIMIT 1
  219. ) AS sharePersonName
  220. FROM
  221. ta_person b
  222. <where>
  223. b.status > 0
  224. and b.org_id = #{orgId}
  225. AND IFNULL(b.person_type, '') in ('estate agent', 'customer')
  226. AND b.person_id not IN ( SELECT c.person_id FROM ta_recommend_customer c WHERE c.org_id = #{orgId} AND person_id is not null AND person_id != '' )
  227. <if test="name != null and name !=''">
  228. and b.nickname like CONCAT('%',#{name}, '%')
  229. </if>
  230. <if test="tel != null and tel!=''">
  231. and b.phone like CONCAT('%',#{tel}, '%')
  232. </if>
  233. <if test="entryType != null and entryType !=''">
  234. and b.entry_type = #{entryType}
  235. </if>
  236. <if test="sex != null and sex !=''">
  237. and b.sex = #{sex}
  238. </if>
  239. <if test="consultTel != null and consultTel !=''">
  240. and b.tel like CONCAT('%',#{consultTel}, '%')
  241. </if>
  242. and NOT EXISTS ( select * from ta_recommend_customer a where a.recommend_person = b.person_id)
  243. </where>
  244. order by b.create_date desc
  245. </select>
  246. <select id="getRecCustomerExport" resultType="com.huiju.estateagents.excel.ExcelRecommendCustomer">
  247. SELECT
  248. a.name as name,
  249. a.phone as phone,
  250. a.intention as intention,
  251. a.create_date as createDate,
  252. if(a.sex = 1, '男',if(a.sex = 2, '女', '未知')) as sex,
  253. c.nickname as recommend,
  254. c.phone as recommendTel,
  255. if(a.verify_status = 0, '待审核', if(a.verify_status = 1, '已通过', if(a.verify_status = 2, '未通过', ''))) as verifyStatusName
  256. FROM
  257. ta_recommend_customer a
  258. LEFT JOIN ta_person c on a.recommend_person = c.person_id
  259. <where>
  260. a.status > 0
  261. and a.report_recommend_status = 2
  262. <if test="orgId != null">
  263. and a.org_id = #{orgId}
  264. </if>
  265. </where>
  266. order by a.create_date desc
  267. limit #{pageCode}, #{pageSize}
  268. </select>
  269. <select id="getRecCustomerExportCount" resultType="java.lang.Integer">
  270. SELECT
  271. count(*)
  272. FROM
  273. ta_recommend_customer a
  274. LEFT JOIN ta_person c on a.recommend_person = c.person_id
  275. <where>
  276. a.status > 0
  277. and a.report_recommend_status = 2
  278. <if test="orgId != null">
  279. and a.org_id = #{orgId}
  280. </if>
  281. </where>
  282. </select>
  283. <select id="getRepCustomerReportCount" resultType="java.lang.Integer">
  284. SELECT
  285. count(*)
  286. FROM
  287. ta_recommend_customer a
  288. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  289. LEFT JOIN ta_building c ON a.building_id = c.building_id
  290. <where>
  291. a.status > 0
  292. and a.report_recommend_status = 1
  293. <if test="orgId != null">
  294. and a.org_id = #{orgId}
  295. </if>
  296. <if test="building != null and building !=''">
  297. and a.building_id = #{building}
  298. </if>
  299. <if test="name != null and name !=''">
  300. and a.name = #{name}
  301. </if>
  302. <if test="tel != null and tel!=''">
  303. and a.phone like concat(concat("%",#{tel}),"%")
  304. </if>
  305. <if test="consultName != null and consultName !=''">
  306. and b.name like CONCAT('%',#{consultName}, '%')
  307. </if>
  308. <if test="consultTel != null and consultTel !=''">
  309. and b.tel = #{consultTel}
  310. </if>
  311. <if test="entryType != null and entryType !=''">
  312. and a.entry_type = #{entryType}
  313. </if>
  314. <if test="verifyStatus != null and verifyStatus !=''">
  315. and a.verify_status = #{verifyStatus}
  316. </if>
  317. <if test="sex != null and sex !=''">
  318. and a.sex = #{sex}
  319. and a.org_id = #{orgid}
  320. </if>
  321. </where>
  322. order by a.create_date desc
  323. </select>
  324. <select id="getRepCustomerReportExport" resultType="com.huiju.estateagents.excel.ReporRecommendCustomer" >
  325. SELECT
  326. a.name as name,
  327. a.phone as phone,
  328. c.building_name as intentionName,
  329. if(a.sex = 1, '男',if(a.sex = 2, '女', '未知')) as sex,
  330. b.NAME AS consultantName,
  331. b.tel AS consultTel
  332. FROM
  333. ta_recommend_customer a
  334. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  335. LEFT JOIN ta_building c ON a.building_id = c.building_id
  336. <where>
  337. a.status > 0
  338. and a.report_recommend_status = 1
  339. <if test="orgId != null">
  340. and a.org_id = #{orgId}
  341. </if>
  342. <if test="building != null and building !=''">
  343. and a.building_id = #{building}
  344. </if>
  345. <if test="name != null and name !=''">
  346. and a.name = #{name}
  347. </if>
  348. <if test="tel != null and tel!=''">
  349. and a.phone like concat(concat("%",#{tel}),"%")
  350. </if>
  351. <if test="consultName != null and consultName !=''">
  352. and b.name like CONCAT('%',#{consultName}, '%')
  353. </if>
  354. <if test="consultTel != null and consultTel !=''">
  355. and b.tel = #{consultTel}
  356. </if>
  357. <if test="entryType != null and entryType !=''">
  358. and a.entry_type = #{entryType}
  359. </if>
  360. <if test="verifyStatus != null and verifyStatus !=''">
  361. and a.verify_status = #{verifyStatus}
  362. </if>
  363. <if test="sex != null and sex !=''">
  364. and a.sex = #{sex}
  365. and a.org_id = #{orgid}
  366. </if>
  367. </where>
  368. order by a.create_date desc
  369. limit #{pageCode}, #{pageSize}
  370. </select>
  371. <select id="getIndependentAgentsCount" resultType="java.lang.Integer">
  372. SELECT
  373. count(*)
  374. FROM
  375. ta_person a
  376. left join ta_channel_person tcp on a.person_id = tcp.person_id
  377. left join ta_channel tc on tc.channel_id = tcp.channel_id
  378. <where>
  379. a.person_type = 'estate agent'
  380. and a.status >0
  381. <if test="orgId != null">
  382. and a.org_id = #{orgId}
  383. </if>
  384. </where>
  385. ORDER BY
  386. a.create_date DESC
  387. </select>
  388. <select id="getIndependentAgentsExport" resultType="com.huiju.estateagents.excel.AgentsRecommendCustomer">
  389. SELECT
  390. a.nickname as nickname,
  391. a.phone as phone,
  392. if(a.gender = '1', '男', if(a.gender = '2', '女', '未知')) as gender,
  393. if(ifnull(tc.channel_name, '') != '', '渠道经纪人', '独立经纪人') as personType,
  394. tc.channel_name as channelName,
  395. (
  396. SELECT
  397. count( 1 )
  398. FROM
  399. ta_person tp
  400. WHERE
  401. tp.recommend_agent = a.person_id
  402. ) AS agentCount,
  403. (
  404. SELECT
  405. count( 1 )
  406. FROM
  407. ta_recommend_customer tarc
  408. WHERE
  409. tarc.recommend_person = a.person_id
  410. and tarc.status = 1
  411. and tarc.org_id = #{orgId}
  412. ) AS recommedCount
  413. FROM
  414. ta_person a
  415. left join ta_channel_person tcp on a.person_id = tcp.person_id
  416. left join ta_channel tc on tc.channel_id = tcp.channel_id
  417. <where>
  418. ifnull(a.person_type, '') in ('channel agent', 'estate agent')
  419. and a.status >0
  420. <if test="orgId != null">
  421. and a.org_id = #{orgId}
  422. </if>
  423. </where>
  424. ORDER BY
  425. a.create_date DESC
  426. limit #{pageCode}, #{pageSize}
  427. </select>
  428. <select id="getPublicCustomerExportListCount" resultType="Integer">
  429. SELECT
  430. count(1)
  431. FROM
  432. ta_person b
  433. <where>
  434. b.status > 0
  435. AND IFNULL(b.person_type, '') in ('estate agent', 'customer')
  436. <if test="name != null and name !=''">
  437. and b.nickname like CONCAT('%',#{name}, '%')
  438. </if>
  439. <if test="tel != null and tel!=''">
  440. and b.phone like CONCAT('%',#{tel}, '%')
  441. </if>
  442. <if test="entryType != null and entryType !=''">
  443. and b.entry_type = #{entryType}
  444. </if>
  445. <if test="sex != null and sex !=''">
  446. and b.sex = #{sex}
  447. </if>
  448. <if test="orgId != null">
  449. and b.org_id = #{orgId}
  450. </if>
  451. <if test="consultTel != null and consultTel !=''">
  452. and b.tel like CONCAT('%',#{consultTel}, '%')
  453. </if>
  454. and NOT EXISTS ( select * from ta_recommend_customer a where a.recommend_person = b.person_id)
  455. </where>
  456. order by b.create_date desc
  457. </select>
  458. <select id="getPublicCustomerExportList" resultType="com.huiju.estateagents.excel.PublicCustomerExport">
  459. SELECT
  460. b.nickname as nickname,
  461. b.phone as phone,
  462. if(b.gender = 1, '男', if(b.gender = 2, '女', '未知')) as sex
  463. FROM
  464. ta_person b
  465. <where>
  466. b.status > 0
  467. AND IFNULL(b.person_type, '') in ('estate agent', 'customer')
  468. <if test="name != null and name !=''">
  469. and b.nickname like CONCAT('%',#{name}, '%')
  470. </if>
  471. <if test="tel != null and tel!=''">
  472. and b.phone like CONCAT('%',#{tel}, '%')
  473. </if>
  474. <if test="entryType != null and entryType !=''">
  475. and b.entry_type = #{entryType}
  476. </if>
  477. <if test="sex != null and sex !=''">
  478. and b.sex = #{sex}
  479. </if>
  480. <if test="orgId != null">
  481. and b.org_id = #{orgId}
  482. </if>
  483. <if test="consultTel != null and consultTel !=''">
  484. and b.tel like CONCAT('%',#{consultTel}, '%')
  485. </if>
  486. and NOT EXISTS ( select * from ta_recommend_customer a where a.recommend_person = b.person_id)
  487. </where>
  488. order by b.create_date desc
  489. limit #{pageCode}, #{pageSize}
  490. </select>
  491. <select id="getCustomerExportListCount" resultType="Integer" >
  492. SELECT
  493. count(1)
  494. FROM
  495. ta_recommend_customer a
  496. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  497. LEFT JOIN ta_person c on a.recommend_person = c.person_id
  498. <where>
  499. a.status > 0
  500. and a.verify_status = 1
  501. and realty_consultant is not null
  502. <if test="orgId != null">
  503. and a.org_id = #{orgId}
  504. </if>
  505. <if test="building != null and building !=''">
  506. and a.building_id = #{building}
  507. </if>
  508. <if test="name != null and name !=''">
  509. and a.name like CONCAT('%',#{name}, '%')
  510. </if>
  511. <if test="tel != null and tel!=''">
  512. and a.phone like CONCAT('%',#{tel}, '%')
  513. </if>
  514. <if test="consultName != null and consultName !=''">
  515. and b.name like CONCAT('%',#{consultName}, '%')
  516. </if>
  517. <if test="consultTel != null and consultTel !=''">
  518. and b.tel like CONCAT('%',#{consultTel}, '%')
  519. </if>
  520. <if test="entryType != null and entryType !=''">
  521. and a.entry_type = #{entryType}
  522. </if>
  523. <if test="verifyStatus != null and verifyStatus !=''">
  524. and a.verify_status = #{verifyStatus}
  525. </if>
  526. <if test="status != null and status !=''">
  527. and a.status = #{status}
  528. </if>
  529. <if test="sex != null and sex !=''">
  530. and a.sex = #{sex}
  531. </if>
  532. </where>
  533. order by a.create_date desc
  534. </select>
  535. <select id="getCustomerExportList" resultType="com.huiju.estateagents.excel.PrivateCustomerExport">
  536. SELECT
  537. a.name AS name,
  538. a.phone as phone,
  539. if(a.sex = 1, '男', if(a.sex = 2, '女', '未知')) as sex,
  540. b.name as consultantName,
  541. b.tel as consultTel
  542. FROM
  543. ta_recommend_customer a
  544. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  545. LEFT JOIN ta_person c on a.recommend_person = c.person_id
  546. <where>
  547. a.status > 0
  548. and a.verify_status = 1
  549. and realty_consultant is not null
  550. <if test="orgId != null">
  551. and a.org_id = #{orgId}
  552. </if>
  553. <if test="building != null and building !=''">
  554. and a.building_id = #{building}
  555. </if>
  556. <if test="name != null and name !=''">
  557. and a.name like CONCAT('%',#{name}, '%')
  558. </if>
  559. <if test="tel != null and tel!=''">
  560. and a.phone like CONCAT('%',#{tel}, '%')
  561. </if>
  562. <if test="consultName != null and consultName !=''">
  563. and b.name like CONCAT('%',#{consultName}, '%')
  564. </if>
  565. <if test="consultTel != null and consultTel !=''">
  566. and b.tel like CONCAT('%',#{consultTel}, '%')
  567. </if>
  568. <if test="entryType != null and entryType !=''">
  569. and a.entry_type = #{entryType}
  570. </if>
  571. <if test="verifyStatus != null and verifyStatus !=''">
  572. and a.verify_status = #{verifyStatus}
  573. </if>
  574. <if test="status != null and status !=''">
  575. and a.status = #{status}
  576. </if>
  577. <if test="sex != null and sex !=''">
  578. and a.sex = #{sex}
  579. </if>
  580. </where>
  581. order by a.create_date desc
  582. limit #{pageCode}, #{pageSize}
  583. </select>
  584. <select id="getMyCustStatistics" resultType="java.util.Map">
  585. SELECT
  586. sum( IF ( STATUS = 4, 1, 0 ) ) AS clinchSum,
  587. sum( IF ( STATUS != 4 AND STATUS != 4, 1, 0 ) ) AS followSum
  588. FROM
  589. ta_recommend_customer
  590. WHERE
  591. org_id = #{orgId}
  592. AND ( realty_consultant = #{personId}
  593. <if test="userId != null and userId != ''">
  594. OR realty_consultant = #{userId}
  595. </if>
  596. )
  597. </select>
  598. <select id="getMyCustFollowOrClinch" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  599. SELECT
  600. *
  601. FROM
  602. ta_recommend_customer
  603. WHERE
  604. org_id = #{orgId}
  605. AND ( realty_consultant = #{personId} OR realty_consultant = #{userId} )
  606. <if test="type == 'follow'">
  607. AND STATUS != 4
  608. <if test="name != null and name !=''">
  609. and `name` like CONCAT('%',#{name}, '%')
  610. </if>
  611. <if test="phone != null and phone !=''">
  612. and phone like CONCAT('%',#{phone}, '%')
  613. </if>
  614. <if test="status != null and status !=''">
  615. and status = #{status}
  616. </if>
  617. <if test="startReportDate != null and startReportDate !=''">
  618. and date_format( report_date, '%Y-%m-%d' ) >= #{startReportDate}
  619. </if>
  620. <if test="endReportDate != null and endReportDate !=''">
  621. and date_format( report_date, '%Y-%m-%d' ) &lt;= #{endReportDate}
  622. </if>
  623. <if test="startArrivalDate != null and startArrivalDate !=''">
  624. and date_format( arrival_date, '%Y-%m-%d' ) >= #{startArrivalDate}
  625. </if>
  626. <if test="endArrivalDate != null and endArrivalDate !=''">
  627. and date_format( arrival_date, '%Y-%m-%d' ) &lt;= #{endArrivalDate}
  628. </if>
  629. </if>
  630. <if test="type == 'clinch'">
  631. AND STATUS = 4
  632. </if>
  633. </select>
  634. <select id="getMyCustDetailById" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  635. SELECT
  636. *
  637. FROM
  638. ta_recommend_customer
  639. where customer_id = #{customerId}
  640. </select>
  641. <select id="getCustomerIntentions" resultType="com.huiju.estateagents.entity.PersonIntention">
  642. SELECT
  643. SUM( intention ) AS intention,
  644. building_id,
  645. building_name
  646. FROM
  647. `ta_person_intention_record`
  648. WHERE
  649. person_id = #{personId}
  650. GROUP BY
  651. building_id
  652. ORDER BY
  653. intention DESC
  654. </select>
  655. </mapper>