CustomerMapper.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.fjhx.customer.mapper.customer.CustomerMapper">
  4. <update id="customerAllocation">
  5. update customer set user_id = #{userId},update_time = now() where id = #{id}
  6. </update>
  7. <select id="getList" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  8. select
  9. c.id,
  10. c.customer_code,
  11. c.code,
  12. c.country_id,
  13. c.province_id,
  14. c.city_id,
  15. c.address,
  16. c.zip_code,
  17. c.name,
  18. c.status,
  19. c.source,
  20. c.user_id,
  21. c.create_user,
  22. c.create_time,
  23. c.update_user,
  24. c.update_time,
  25. c.tag
  26. from customer c
  27. ${ew.customSqlSegment}
  28. </select>
  29. <select id="getPage" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  30. select
  31. c.id,
  32. c.customer_code,
  33. c.code,
  34. c.country_id,
  35. c.province_id,
  36. c.city_id,
  37. c.address,
  38. c.zip_code,
  39. c.name,
  40. c.status,
  41. c.source,
  42. c.user_id,
  43. c.create_user,
  44. c.create_time,
  45. c.update_user,
  46. c.update_time,
  47. c.tag
  48. from customer c
  49. LEFT JOIN customer_user cu ON cu.customer_id = c.id
  50. ${ew.customSqlSegment}
  51. </select>
  52. <select id="sourceStock" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  53. SELECT
  54. COUNT(*) count,
  55. ifnull(c.source,-1) source,
  56. ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
  57. FROM
  58. customer c
  59. ${ew.customSqlSegment}
  60. </select>
  61. <select id="sourceIncrement" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  62. SELECT
  63. COUNT(*) count,
  64. ifnull(c.source,-1) source,
  65. ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
  66. FROM
  67. customer c
  68. ${ew.customSqlSegment}
  69. </select>
  70. <select id="getFollowUp" resultType="com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo">
  71. SELECT t1.*
  72. FROM ((SELECT id,
  73. amount,
  74. create_time `date`,
  75. NULL AS contractCode,
  76. code,
  77. 10 AS type,
  78. NULL AS content,
  79. create_user
  80. FROM bytesailing_sale.sale_quotation sq
  81. WHERE sq.buy_corporation_id = #{id}
  82. and sq.tenant_id = #{tenantId}
  83. and sq.del_flag = 0)
  84. UNION
  85. (SELECT id,
  86. amount,
  87. create_time `date`,
  88. CODE AS contractCode,
  89. null as code,
  90. 20 AS type,
  91. NULL AS content,
  92. create_user
  93. FROM bytesailing_sale.contract c
  94. WHERE c.status = 30
  95. and c.buy_corporation_id = #{id}
  96. and c.tenant_id = #{tenantId}
  97. and c.del_flag = 0)
  98. UNION
  99. (SELECT id,
  100. NULL AS amount,
  101. `date`,
  102. NULL AS contractCode,
  103. null as code,
  104. 30 AS type,
  105. content,
  106. create_user
  107. FROM customer_follow_records cfr
  108. WHERE cfr.customer_id = #{id})) t1
  109. ORDER BY t1.date DESC LIMIT 3
  110. </select>
  111. </mapper>