CustomerMapper.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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(),allocation_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. ${ew.customSqlSegment}
  50. </select>
  51. <select id="sourceStock" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  52. SELECT
  53. COUNT(*) count,
  54. ifnull(c.source,-1) source,
  55. ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
  56. FROM
  57. customer c
  58. ${ew.customSqlSegment}
  59. </select>
  60. <select id="sourceIncrement" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  61. SELECT
  62. COUNT(*) count,
  63. ifnull(c.source,-1) source,
  64. ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
  65. FROM
  66. customer c
  67. ${ew.customSqlSegment}
  68. </select>
  69. <select id="getFollowUp" resultType="com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo">
  70. SELECT t1.*
  71. FROM ((SELECT id,
  72. amount,
  73. create_time `date`,
  74. NULL AS contractCode,
  75. code,
  76. 10 AS type,
  77. NULL AS content,
  78. create_user
  79. FROM bytesailing_sale.sale_quotation sq
  80. WHERE sq.buy_corporation_id = #{id}
  81. and sq.tenant_id = #{tenantId}
  82. and sq.del_flag = 0)
  83. UNION
  84. (SELECT id,
  85. amount,
  86. create_time `date`,
  87. CODE AS contractCode,
  88. null as code,
  89. 20 AS type,
  90. NULL AS content,
  91. create_user
  92. FROM bytesailing_sale.contract c
  93. WHERE c.status = 30
  94. and c.buy_corporation_id = #{id}
  95. and c.tenant_id = #{tenantId}
  96. and c.del_flag = 0)
  97. UNION
  98. (SELECT id,
  99. NULL AS amount,
  100. `date`,
  101. NULL AS contractCode,
  102. null as code,
  103. 30 AS type,
  104. content,
  105. create_user
  106. FROM customer_follow_records cfr
  107. WHERE cfr.customer_id = #{id})) t1
  108. ORDER BY t1.date DESC LIMIT 3
  109. </select>
  110. </mapper>