CustomerMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. c.company_id,
  27. c.short_name,
  28. c.homepage,
  29. c.scale_id,
  30. c.fax,
  31. c.tel_area_code,
  32. c.tel,
  33. c.remark,
  34. c.xm_country_name
  35. from customer c
  36. ${ew.customSqlSegment}
  37. </select>
  38. <select id="getPage" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  39. select
  40. c.id,
  41. c.customer_code,
  42. c.code,
  43. c.country_id,
  44. c.province_id,
  45. c.city_id,
  46. c.address,
  47. c.zip_code,
  48. c.name,
  49. c.status,
  50. c.source,
  51. c.user_id,
  52. c.create_user,
  53. c.create_time,
  54. c.update_user,
  55. c.update_time,
  56. c.tag,
  57. c.company_id,
  58. c.short_name,
  59. c.homepage,
  60. c.scale_id,
  61. c.fax,
  62. c.tel_area_code,
  63. c.tel,
  64. c.xm_country_name
  65. from customer c
  66. ${ew.customSqlSegment}
  67. </select>
  68. <select id="sourceStock" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  69. SELECT
  70. COUNT(*) count,
  71. ifnull(c.source,-1) source,
  72. ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
  73. FROM
  74. customer c
  75. ${ew.customSqlSegment}
  76. </select>
  77. <select id="sourceIncrement" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  78. SELECT
  79. COUNT(*) count,
  80. ifnull(c.source,-1) source,
  81. ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
  82. FROM
  83. customer c
  84. ${ew.customSqlSegment}
  85. </select>
  86. <select id="getFollowUp" resultType="com.fjhx.customer.entity.customer.vo.CustomerFollowRecordsVo">
  87. SELECT t1.*
  88. FROM ((SELECT id,
  89. amount,
  90. create_time `date`,
  91. NULL AS contractCode,
  92. code,
  93. 10 AS type,
  94. NULL AS content,
  95. create_user
  96. FROM bytesailing_sale.sale_quotation sq
  97. WHERE sq.buy_corporation_id = #{id}
  98. and sq.tenant_id = #{tenantId}
  99. and sq.del_flag = 0)
  100. UNION
  101. (SELECT id,
  102. amount,
  103. create_time `date`,
  104. CODE AS contractCode,
  105. null as code,
  106. 20 AS type,
  107. NULL AS content,
  108. create_user
  109. FROM bytesailing_sale.contract c
  110. WHERE c.status = 30
  111. and c.buy_corporation_id = #{id}
  112. and c.tenant_id = #{tenantId}
  113. and c.del_flag = 0)
  114. UNION
  115. (SELECT id,
  116. NULL AS amount,
  117. `date`,
  118. NULL AS contractCode,
  119. null as code,
  120. 30 AS type,
  121. content,
  122. create_user
  123. FROM customer_follow_records cfr
  124. WHERE cfr.customer_id = #{id})) t1
  125. ORDER BY t1.date DESC LIMIT 3
  126. </select>
  127. <select id="sourceCount" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
  128. SELECT
  129. COUNT( 1 ) AS `count`,
  130. dcd.dict_key AS `source`
  131. FROM
  132. customer c
  133. JOIN bytesailing_base.dict_tenant_data dcd ON FIND_IN_SET( dcd.dict_key, c.source )
  134. <where>
  135. ${ew.sqlSegment}
  136. </where>
  137. GROUP BY
  138. dcd.dict_key
  139. </select>
  140. </mapper>