CustomerPointsMapper.xml 6.4 KB

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