TaRecommendCustomerMapper.xml 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.person_id = #{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 b.person_id = c.person_id ORDER BY c.visit_time desc LIMIT 1) as visitTime,
  25. (SELECT SUM(d.visit_duration) FROM ta_person_visit_record d WHERE b.person_id = d.person_id) as duration
  26. FROM
  27. ta_recommend_customer a
  28. LEFT JOIN ta_customer_person b on a.customer_id = b.customer_id
  29. LEFT JOIN ta_person_visit_record c ON b.person_id = c.person_id
  30. where a.customer_id = #{customerId}
  31. </select>
  32. <select id="getCustomerList" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  33. SELECT
  34. a.*,
  35. b.name as consultantName,
  36. b.tel as consultTel
  37. FROM
  38. ta_recommend_customer a
  39. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  40. <where>
  41. a.status > 0
  42. <if test="building != null and building !=''">
  43. and a.building_id = #{building}
  44. </if>
  45. <if test="name != null and name !=''">
  46. and a.name = #{name}
  47. </if>
  48. <if test="tel != null and tel!=''">
  49. and a.phone = #{tel}
  50. </if>
  51. <if test="consultName != null and consultName !=''">
  52. and b.name like CONCAT('%',#{consultName}, '%')
  53. </if>
  54. <if test="consultTel != null and consultTel !=''">
  55. and b.tel = #{consultTel}
  56. </if>
  57. </where>
  58. </select>
  59. <select id="getCustomerById" resultType="com.huiju.estateagents.entity.TaRecommendCustomer">
  60. SELECT
  61. a.*,
  62. b.name as consultantName
  63. FROM
  64. ta_recommend_customer a
  65. LEFT JOIN ta_person b ON a.realty_consultant = b.person_id
  66. WHERE a.customer_id = #{customerId}
  67. </select>
  68. </mapper>