CustomerPointsMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.CustomerPointsMapper">
  6. <resultMap type="CustomerPoints" id="CustomerPointsResult">
  7. <result property="id" column="id" />
  8. <result property="unionId" column="union_id" />
  9. <result property="mobilePhone" column="mobile_phone" />
  10. <result property="points" column="points" />
  11. <result property="consumptionPoints" column="consumption_points" />
  12. <result property="accumulatePoints" column="accumulate_points" />
  13. <result property="invalidPoints" column="invalid_points" />
  14. <result property="recentConsumptionDate" column="recent_consumption_date" />
  15. <result property="stationId" column="station_id" />
  16. <result property="stationName" column="station_name" />
  17. <result property="customerName" column="customer_name" />
  18. </resultMap>
  19. <sql id="selectCustomerPointsVo">
  20. select p.id,p.union_id,p.mobile_phone,p.points,p.customer_name, p.consumption_points,
  21. p.accumulate_points, p.invalid_points, p.recent_consumption_date,p.station_id,
  22. d.dept_name as station_name
  23. from customer_points p join sys_dept d on p.station_id = d.dept_id
  24. </sql>
  25. <select id="selectCustomerPointsList" parameterType="CustomerPoints" resultMap="CustomerPointsResult">
  26. <include refid="selectCustomerPointsVo"/>
  27. <where>
  28. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  29. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone like concat('%', #{mobilePhone}, '%')</if>
  30. and points != 0
  31. <if test="consumptionPoints != null"> and consumption_points = #{consumptionPoints}</if>
  32. <if test="accumulatePoints != null "> and accumulate_points = #{accumulatePoints}</if>
  33. <if test="invalidPoints != null "> and invalid_points = #{invalidPoints}</if>
  34. <if test="recentConsumptionDate != null "> and recent_consumption_date = #{recentConsumptionDate}</if>
  35. <if test="stationId != null "> and station_id = #{stationId}</if>
  36. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  37. <if test="stationIdList != null ">
  38. and station_id in
  39. <foreach item="item" index="index" collection="stationIdList"
  40. open="(" separator="," close=")">
  41. #{item}
  42. </foreach>
  43. </if>
  44. </where>
  45. order by recent_consumption_date desc
  46. </select>
  47. <select id="selectCustomerPointsById" parameterType="Long" resultMap="CustomerPointsResult">
  48. <include refid="selectCustomerPointsVo"/>
  49. where id = #{id}
  50. </select>
  51. <insert id="insertCustomerPoints" parameterType="CustomerPoints" useGeneratedKeys="true" keyProperty="id">
  52. insert into customer_points
  53. <trim prefix="(" suffix=")" suffixOverrides=",">
  54. <if test="unionId != null">union_id,</if>
  55. <if test="mobilePhone != null">mobile_phone,</if>
  56. <if test="points != null">points,</if>
  57. <if test="consumptionPoints != null">consumption_points,</if>
  58. <if test="accumulatePoints != null">accumulate_points,</if>
  59. <if test="invalidPoints != null">invalid_points,</if>
  60. <if test="recentConsumptionDate != null">recent_consumption_date,</if>
  61. <if test="stationId != null">station_id,</if>
  62. </trim>
  63. <trim prefix="values (" suffix=")" suffixOverrides=",">
  64. <if test="unionId != null">#{unionId},</if>
  65. <if test="mobilePhone != null">#{mobilePhone},</if>
  66. <if test="points != null">#{points},</if>
  67. <if test="consumptionPoints != null">#{consumptionPoints},</if>
  68. <if test="accumulatePoints != null">#{accumulatePoints},</if>
  69. <if test="invalidPoints != null">#{invalidPoints},</if>
  70. <if test="recentConsumptionDate != null">#{recentConsumptionDate},</if>
  71. <if test="stationId != null">#{stationId},</if>
  72. </trim>
  73. </insert>
  74. <update id="updateCustomerPoints" parameterType="CustomerPoints">
  75. update customer_points
  76. <trim prefix="SET" suffixOverrides=",">
  77. <if test="unionId != null">union_id = #{unionId},</if>
  78. <if test="mobilePhone != null">mobile_phone = #{mobilePhone},</if>
  79. <if test="points != null">points = #{points},</if>
  80. <if test="consumptionPoints != null">consumption_points = #{consumptionPoints},</if>
  81. <if test="accumulatePoints != null">accumulate_points = #{accumulatePoints},</if>
  82. <if test="invalidPoints != null">invalid_points = #{invalidPoints},</if>
  83. <if test="recentConsumptionDate != null">recent_consumption_date = #{recentConsumptionDate},</if>
  84. <if test="stationId != null">station_id = #{stationId},</if>
  85. <if test="stationName != null">station_name = #{stationName},</if>
  86. </trim>
  87. where id = #{id}
  88. </update>
  89. <delete id="deleteCustomerPointsById" parameterType="Long">
  90. delete from customer_points where id = #{id}
  91. </delete>
  92. <delete id="deleteCustomerPointsByIds" parameterType="String">
  93. delete from customer_points where id in
  94. <foreach item="id" collection="array" open="(" separator="," close=")">
  95. #{id}
  96. </foreach>
  97. </delete>
  98. </mapper>