TaRecommendCustomerMapper.xml 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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="building != null and building !=''">
  45. and a.building_id = #{building}
  46. </if>
  47. <if test="name != null and name !=''">
  48. and a.name = #{name}
  49. </if>
  50. <if test="tel != null and tel!=''">
  51. and a.phone = #{tel}
  52. </if>
  53. <if test="consultName != null and consultName !=''">
  54. and c.nickname like CONCAT('%',#{consultName}, '%')
  55. </if>
  56. <if test="consultTel != null and consultTel !=''">
  57. and c.phone = #{consultTel}
  58. </if>
  59. <if test="entryType != null and entryType !=''">
  60. and a.entry_type = #{entryType}
  61. </if>
  62. <if test="verifyStatus != null and verifyStatus !=''">
  63. and a.verify_status = #{verifyStatus}
  64. </if>
  65. <if test="sex != null and sex !=''">
  66. and a.sex = #{sex}
  67. </if>
  68. </where>
  69. order by a.create_date desc
  70. </select>
  71. <select id="getIndependentAgents" resultType="com.huiju.estateagents.entity.TaPerson">
  72. SELECT
  73. a.*
  74. FROM
  75. ta_person a
  76. <where>
  77. a.person_type = 'estate agent'
  78. and a.status >0
  79. <if test="name != null and name !=''">
  80. and a.nickname = #{name}
  81. </if>
  82. <if test="tel != null and tel!=''">
  83. and a.phone = #{tel}
  84. </if>
  85. </where>
  86. ORDER BY
  87. create_date DESC
  88. </select>
  89. <select id="getRepCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  90. SELECT
  91. a.*,
  92. a.customer_id AS customerId,
  93. b.NAME AS consultantName,
  94. b.tel AS consultTel
  95. FROM
  96. ta_recommend_customer a
  97. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  98. <where>
  99. a.status > 0
  100. and a.report_recommend_status = 1
  101. <if test="building != null and building !=''">
  102. and a.building_id = #{building}
  103. </if>
  104. <if test="name != null and name !=''">
  105. and a.name = #{name}
  106. </if>
  107. <if test="tel != null and tel!=''">
  108. and a.phone = #{tel}
  109. </if>
  110. <if test="consultName != null and consultName !=''">
  111. and b.name like CONCAT('%',#{consultName}, '%')
  112. </if>
  113. <if test="consultTel != null and consultTel !=''">
  114. and b.tel = #{consultTel}
  115. </if>
  116. <if test="entryType != null and entryType !=''">
  117. and a.entry_type = #{entryType}
  118. </if>
  119. <if test="verifyStatus != null and verifyStatus !=''">
  120. and a.verify_status = #{verifyStatus}
  121. </if>
  122. <if test="sex != null and sex !=''">
  123. and a.sex = #{sex}
  124. </if>
  125. </where>
  126. order by a.create_date desc
  127. </select>
  128. <select id="getCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  129. SELECT
  130. a.*,
  131. a.customer_id as customerId,
  132. b.name as consultantName,
  133. b.tel as consultTel,
  134. c.nickname as recommendName,
  135. c.tel as recommendTel
  136. FROM
  137. ta_recommend_customer a
  138. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  139. LEFT JOIN ta_person c on a.recommend_person = c.person_id
  140. <where>
  141. a.status > 0
  142. <if test="building != null and building !=''">
  143. and a.building_id = #{building}
  144. </if>
  145. <if test="name != null and name !=''">
  146. and a.name = #{name}
  147. </if>
  148. <if test="tel != null and tel!=''">
  149. and a.phone = #{tel}
  150. </if>
  151. <if test="consultName != null and consultName !=''">
  152. and b.name like CONCAT('%',#{consultName}, '%')
  153. </if>
  154. <if test="consultTel != null and consultTel !=''">
  155. and b.tel = #{consultTel}
  156. </if>
  157. <if test="entryType != null and entryType !=''">
  158. and a.entry_type = #{entryType}
  159. </if>
  160. <if test="verifyStatus != null and verifyStatus !=''">
  161. and a.verify_status = #{verifyStatus}
  162. </if>
  163. <if test="sex != null and sex !=''">
  164. and a.sex = #{sex}
  165. </if>
  166. </where>
  167. order by a.create_date desc
  168. </select>
  169. <select id="getCustomerById" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  170. SELECT
  171. a.*,
  172. b.name as consultantName
  173. FROM
  174. ta_recommend_customer a
  175. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  176. WHERE a.customer_id = #{customerId}
  177. </select>
  178. </mapper>