CustomerPointsMapper.xml 6.5 KB

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