CrmCustomerAssistMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.crm.mapper.CrmCustomerAssistMapper">
  6. <resultMap type="CrmCustomerAssist" id="CrmCustomerAssistResult">
  7. <result property="id" column="id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="companyUserId" column="company_user_id" />
  10. <result property="companyUserName" column="company_user_name" />
  11. <result property="customerId" column="customer_id" />
  12. <result property="createTime" column="create_time" />
  13. <result property="rate" column="rate" />
  14. </resultMap>
  15. <sql id="selectCrmCustomerAssistVo">
  16. select id, company_id, company_user_id,company_user_name, customer_id, create_time,rate from crm_customer_assist
  17. </sql>
  18. <select id="selectCrmCustomerAssistList" parameterType="CrmCustomerAssist" resultMap="CrmCustomerAssistResult">
  19. <include refid="selectCrmCustomerAssistVo"/>
  20. <where>
  21. <if test="companyId != null "> and company_id = #{companyId}</if>
  22. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  23. <if test="companyUserName != null and companyUserName != ''"> and company_user_name = #{companyUserName}</if>
  24. <if test="customerId != null "> and customer_id = #{customerId}</if>
  25. </where>
  26. </select>
  27. <select id="selectCrmCustomerAssistById" parameterType="Long" resultMap="CrmCustomerAssistResult">
  28. <include refid="selectCrmCustomerAssistVo"/>
  29. where id = #{id}
  30. </select>
  31. <select id="selectCompanyUserNameByCustomerId" resultType="java.lang.String">
  32. select CONCAT(company_user_name, '(', company_user_id, ')','分佣:',rate,'%') AS assistUser
  33. from crm_customer_assist
  34. where customer_id = #{customerId}
  35. </select>
  36. <select id="selectCustomerIdByCompanyUserId" resultType="java.lang.Long">
  37. SELECT customer_id FROM crm_customer_assist where company_user_id = #{companyUserId}
  38. </select>
  39. <select id="selectCompanyUserIdByCustomerId" resultType="java.lang.Long">
  40. select company_user_id from crm_customer_assist where customer_id = #{customerId} and create_time &lt; #{createTime}
  41. </select>
  42. <select id="selectByCustomerId" resultType="com.fs.crm.domain.CrmCustomerAssist">
  43. <include refid="selectCrmCustomerAssistVo"/>
  44. where customer_id = #{customerId}
  45. </select>
  46. <insert id="insertCrmCustomerAssist" parameterType="CrmCustomerAssist" useGeneratedKeys="true" keyProperty="id">
  47. insert into crm_customer_assist
  48. <trim prefix="(" suffix=")" suffixOverrides=",">
  49. <if test="companyId != null">company_id,</if>
  50. <if test="companyUserId != null">company_user_id,</if>
  51. <if test="companyUserName != null">company_user_name,</if>
  52. <if test="customerId != null">customer_id,</if>
  53. <if test="createTime != null">create_time,</if>
  54. <if test="rate != null">rate,</if>
  55. </trim>
  56. <trim prefix="values (" suffix=")" suffixOverrides=",">
  57. <if test="companyId != null">#{companyId},</if>
  58. <if test="companyUserId != null">#{companyUserId},</if>
  59. <if test="companyUserName != null">#{companyUserName},</if>
  60. <if test="customerId != null">#{customerId},</if>
  61. <if test="createTime != null">#{createTime},</if>
  62. <if test="rate != null">#{rate},</if>
  63. </trim>
  64. </insert>
  65. <update id="updateCrmCustomerAssist" parameterType="CrmCustomerAssist">
  66. update crm_customer_assist
  67. <trim prefix="SET" suffixOverrides=",">
  68. <if test="companyId != null">company_id = #{companyId},</if>
  69. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  70. <if test="companyUserName != null">company_user_name = #{companyUserName},</if>
  71. <if test="customerId != null">customer_id = #{customerId},</if>
  72. <if test="createTime != null">create_time = #{createTime},</if>
  73. <if test="rate != null">rate = #{rate},</if>
  74. </trim>
  75. where id = #{id}
  76. </update>
  77. <delete id="deleteCrmCustomerAssistById" parameterType="Long">
  78. delete from crm_customer_assist where id = #{id}
  79. </delete>
  80. <delete id="deleteCrmCustomerAssistByIds" parameterType="String">
  81. delete from crm_customer_assist where id in
  82. <foreach item="id" collection="array" open="(" separator="," close=")">
  83. #{id}
  84. </foreach>
  85. </delete>
  86. <delete id="removeByCustomer">
  87. delete from crm_customer_assist where customer_id in
  88. <foreach collection="maps.customerIds" item="customerId" open="(" separator="," close=")">
  89. #{customerId}
  90. </foreach>
  91. <if test="maps.companyUserId != null">
  92. and company_user_id = #{maps.companyUserId}
  93. </if>
  94. </delete>
  95. <delete id="deleteCrmCustomerAssistByCustomerId">
  96. delete from crm_customer_assist where customer_id = #{customerId}
  97. </delete>
  98. </mapper>