CustomerPointsMapper.xml 6.5 KB

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