CustomerPointsRecordMapper.xml 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.integral.mapper.CustomerPointsRecordMapper">
  6. <resultMap type="CustomerPointsRecord" id="CustomerPointsRecordResult">
  7. <result property="id" column="id" />
  8. <result property="unionId" column="union_id" />
  9. <result property="customerName" column="customer_name" />
  10. <result property="recordType" column="record_type" />
  11. <result property="integral" column="integral" />
  12. <result property="createTime" column="create_time" />
  13. <result property="stationId" column="station_id" />
  14. <result property="stationName" column="station_name" />
  15. <result property="orderNo" column="order_no" />
  16. </resultMap>
  17. <sql id="selectCustomerPointsRecordVo">
  18. select id, union_id, customer_name, record_type, integral, create_time, station_id, d.dept_name as station_name,order_no
  19. from customer_points_record p join sys_dept d on p.station_id = d.dept_id
  20. </sql>
  21. <select id="selectCustomerPointsRecordList" parameterType="CustomerPointsRecord" resultMap="CustomerPointsRecordResult">
  22. <include refid="selectCustomerPointsRecordVo"/>
  23. <where>
  24. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  25. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  26. <if test="recordType != null and recordType != ''"> and record_type = #{recordType}</if>
  27. <if test="integral != null "> and integral = #{integral}</if>
  28. <if test="stationId != null "> and station_id = #{stationId}</if>
  29. <if test="stationIdList != null ">
  30. and station_id in
  31. <foreach item="item" index="index" collection="stationIdList"
  32. open="(" separator="," close=")">
  33. #{item}
  34. </foreach>
  35. </if>
  36. </where>
  37. order by id desc
  38. </select>
  39. <select id="selectCustomerPointsRecordById" parameterType="Long" resultMap="CustomerPointsRecordResult">
  40. <include refid="selectCustomerPointsRecordVo"/>
  41. where id = #{id}
  42. </select>
  43. <insert id="insertCustomerPointsRecord" parameterType="CustomerPointsRecord" useGeneratedKeys="true" keyProperty="id">
  44. insert into customer_points_record
  45. <trim prefix="(" suffix=")" suffixOverrides=",">
  46. <if test="unionId != null">union_id,</if>
  47. <if test="customerName != null">customer_name,</if>
  48. <if test="recordType != null">record_type,</if>
  49. <if test="integral != null">integral,</if>
  50. <if test="createTime != null">create_time,</if>
  51. <if test="stationId != null">station_id,</if>
  52. <if test="orderNo != null">order_no,</if>
  53. </trim>
  54. <trim prefix="values (" suffix=")" suffixOverrides=",">
  55. <if test="unionId != null">#{unionId},</if>
  56. <if test="customerName != null">#{customerName},</if>
  57. <if test="recordType != null">#{recordType},</if>
  58. <if test="integral != null">#{integral},</if>
  59. <if test="createTime != null">#{createTime},</if>
  60. <if test="stationId != null">#{stationId},</if>
  61. <if test="orderNo != null">#{orderNo},</if>
  62. </trim>
  63. </insert>
  64. <update id="updateCustomerPointsRecord" parameterType="CustomerPointsRecord">
  65. update customer_points_record
  66. <trim prefix="SET" suffixOverrides=",">
  67. <if test="unionId != null">union_id = #{unionId},</if>
  68. <if test="customerName != null">customer_name = #{customerName},</if>
  69. <if test="recordType != null">record_type = #{recordType},</if>
  70. <if test="integral != null">integral = #{integral},</if>
  71. <if test="createTime != null">create_time = #{createTime},</if>
  72. <if test="stationId != null">station_id = #{stationId},</if>
  73. <if test="orderNo != null">order_no = #{orderNo},</if>
  74. </trim>
  75. where id = #{id}
  76. </update>
  77. <delete id="deleteCustomerPointsRecordById" parameterType="Long">
  78. delete from customer_points_record where id = #{id}
  79. </delete>
  80. <delete id="deleteCustomerPointsRecordByIds" parameterType="String">
  81. delete from customer_points_record where id in
  82. <foreach item="id" collection="array" open="(" separator="," close=")">
  83. #{id}
  84. </foreach>
  85. </delete>
  86. </mapper>