CustomerLabelMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.yijia.label.mapper.CustomerLabelMapper">
  6. <resultMap type="CustomerLabel" id="CustomerLabelResult">
  7. <result property="id" column="id" />
  8. <result property="phone" column="phone" />
  9. <result property="labelId" column="label_id" />
  10. <result property="stationId" column="station_id" />
  11. <result property="createBy" column="create_by" />
  12. <result property="createTime" column="create_time" />
  13. <result property="updateBy" column="update_by" />
  14. <result property="updateTime" column="update_time" />
  15. <result property="delFlag" column="del_flag" />
  16. <result property="customerName" column="customer_name" />
  17. </resultMap>
  18. <sql id="selectCustomerLabelVo">
  19. select id, phone, label_id, station_id, create_by, create_time, update_by, update_time, del_flag from customer_label
  20. </sql>
  21. <select id="selectCustomerLabelList" parameterType="CustomerLabel" resultMap="CustomerLabelResult">
  22. <include refid="selectCustomerLabelVo"/>
  23. <where>
  24. <if test="phone != null and phone != ''"> and phone like concat('%', #{phone}, '%')</if>
  25. <if test="labelId != null "> and label_id = #{labelId}</if>
  26. <if test="stationId != null "> and station_id = #{stationId}</if>
  27. <if test="delFlag != null "> and del_flag = #{delFlag}</if>
  28. </where>
  29. </select>
  30. <select id="selectNotCustomerLabelInfo" parameterType="CustomerLabel" resultMap="CustomerLabelResult">
  31. SELECT DISTINCT(phone_number) as phone,customer_name
  32. from customer_manage m
  33. join app_user_info a on a.mobile_phone =m.phone_number
  34. <where>
  35. <if test="stationId != null "> and m.station_id = #{stationId}</if>
  36. <if test="phone != null and phone != ''"> and m.phone_number like concat('%', #{phone}, '%')</if>
  37. </where>
  38. and phone_number not in
  39. ( select phone from customer_label b
  40. <where>
  41. <if test="labelId != null "> and label_id != #{labelId}</if>
  42. <if test="delFlag != null "> and del_flag = #{delFlag}</if>
  43. </where> )
  44. </select>
  45. <select id="selectCustomerLabelById" parameterType="Integer" resultMap="CustomerLabelResult">
  46. <include refid="selectCustomerLabelVo"/>
  47. where id = #{id}
  48. </select>
  49. <select id="selectCustomerLabelInfo" parameterType="CustomerLabel" resultMap="CustomerLabelResult">
  50. <include refid="selectCustomerLabelVo"/>
  51. <where>
  52. <if test="phone != null and phone != ''"> and phone = #{phone}</if>
  53. <if test="labelId != null "> and label_id = #{labelId}</if>
  54. <if test="stationId != null "> and station_id = #{stationId}</if>
  55. <if test="delFlag != null "> and del_flag = #{delFlag}</if>
  56. </where>
  57. limit 1
  58. </select>
  59. <insert id="insertCustomerLabel" parameterType="CustomerLabel" useGeneratedKeys="true" keyProperty="id">
  60. insert into customer_label
  61. <trim prefix="(" suffix=")" suffixOverrides=",">
  62. <if test="phone != null">phone,</if>
  63. <if test="labelId != null">label_id,</if>
  64. <if test="stationId != null">station_id,</if>
  65. <if test="createBy != null">create_by,</if>
  66. <if test="createTime != null">create_time,</if>
  67. <if test="updateBy != null">update_by,</if>
  68. <if test="updateTime != null">update_time,</if>
  69. <if test="delFlag != null">del_flag,</if>
  70. </trim>
  71. <trim prefix="values (" suffix=")" suffixOverrides=",">
  72. <if test="phone != null">#{phone},</if>
  73. <if test="labelId != null">#{labelId},</if>
  74. <if test="stationId != null">#{stationId},</if>
  75. <if test="createBy != null">#{createBy},</if>
  76. <if test="createTime != null">#{createTime},</if>
  77. <if test="updateBy != null">#{updateBy},</if>
  78. <if test="updateTime != null">#{updateTime},</if>
  79. <if test="delFlag != null">#{delFlag},</if>
  80. </trim>
  81. </insert>
  82. <update id="updateCustomerLabel" parameterType="CustomerLabel">
  83. update customer_label
  84. <trim prefix="SET" suffixOverrides=",">
  85. <if test="phone != null">phone = #{phone},</if>
  86. <if test="labelId != null">label_id = #{labelId},</if>
  87. <if test="stationId != null">station_id = #{stationId},</if>
  88. <if test="createBy != null">create_by = #{createBy},</if>
  89. <if test="createTime != null">create_time = #{createTime},</if>
  90. <if test="updateBy != null">update_by = #{updateBy},</if>
  91. <if test="updateTime != null">update_time = #{updateTime},</if>
  92. <if test="delFlag != null">del_flag = #{delFlag},</if>
  93. </trim>
  94. where id = #{id}
  95. </update>
  96. <delete id="deleteCustomerLabelById" parameterType="Integer">
  97. delete from customer_label where id = #{id}
  98. </delete>
  99. <delete id="deleteCustomerLabelByIds" parameterType="String">
  100. delete from customer_label where id in
  101. <foreach item="id" collection="array" open="(" separator="," close=")">
  102. #{id}
  103. </foreach>
  104. </delete>
  105. </mapper>