CustomerPointsMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.platform.yijia.dao.CustomerPointsMapper">
  4. <!--返回结果-->
  5. <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.CustomerPoints">
  6. <id column="id" jdbcType="INTEGER" property="id" />
  7. <result column="union_id" jdbcType="VARCHAR" property="unionId" />
  8. <result column="blog_openid" jdbcType="VARCHAR" property="blogOpenId" />
  9. <result column="mina_openid" jdbcType="VARCHAR" property="minaOpenId" />
  10. <result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone" />
  11. <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
  12. <result column="points" jdbcType="INTEGER" property="points" />
  13. <result column="consumption_points" jdbcType="INTEGER" property="consumptionPoints" />
  14. <result column="accumulate_points" jdbcType="INTEGER" property="accumulatePoints" />
  15. <result column="invalid_points" jdbcType="INTEGER" property="invalidPoints" />
  16. <result column="recent_consumption_date" jdbcType="TIMESTAMP" property="recentConsumptionDate" />
  17. <result column="station_id" jdbcType="INTEGER" property="stationId" />
  18. <result column="station_name" jdbcType="VARCHAR" property="stationName" />
  19. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  20. </resultMap>
  21. <!--查询列-->
  22. <sql id="Base_Column_List">
  23. id, union_id, mobile_phone, customer_name, points, consumption_points, accumulate_points, invalid_points,
  24. recent_consumption_date, station_id, station_name, create_time
  25. </sql>
  26. <!--查询客户积分信息-->
  27. <select id="getCustomerPointsInfo" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.CustomerPoints">
  28. SELECT
  29. <include refid="Base_Column_List" />
  30. FROM customer_points
  31. <where>
  32. <if test="unionId !=null and unionId !=''">
  33. union_id = #{unionId}
  34. </if>
  35. <if test="stationId !=null and stationId !=''">
  36. AND station_id = #{stationId}
  37. </if>
  38. </where>
  39. </select>
  40. <!--根据小程序用户的openId查询客户积分信息-->
  41. <select id="getCustomerPointsInfoByUnionId" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.CustomerPoints">
  42. SELECT
  43. <include refid="Base_Column_List" />
  44. FROM customer_points
  45. <where>
  46. <if test="unionId !=null and unionId !=''">
  47. union_id = #{unionId}
  48. </if>
  49. <if test="stationId !=null and stationId !=''">
  50. AND station_id = #{stationId}
  51. </if>
  52. </where>
  53. </select>
  54. <!--插入客户积分表-->
  55. <insert id="insertCustomerPointsInfo" parameterType="com.platform.yijia.pojo.CustomerPoints">
  56. INSERT INTO customer_points
  57. <trim prefix="(" suffix=")" suffixOverrides=",">
  58. <if test="unionId !=null">
  59. union_id,
  60. </if>
  61. <if test="mobilePhone !=null">
  62. mobile_phone,
  63. </if>
  64. <if test="customerName !=null">
  65. customer_name,
  66. </if>
  67. <if test="points !=null">
  68. points,
  69. </if>
  70. <if test="consumptionPoints !=null">
  71. consumption_points,
  72. </if>
  73. <if test="accumulatePoints !=null">
  74. accumulate_points,
  75. </if>
  76. <if test="invalidPoints !=null">
  77. invalid_points,
  78. </if>
  79. <if test="recentConsumptionDate !=null">
  80. recent_consumption_date,
  81. </if>
  82. <if test="stationId !=null">
  83. station_id,
  84. </if>
  85. <if test="stationName !=null">
  86. station_name,
  87. </if>
  88. <if test="createTime !=null">
  89. create_time,
  90. </if>
  91. </trim>
  92. <trim prefix="values (" suffix=")" suffixOverrides=",">
  93. <if test="unionId !=null">
  94. #{unionId},
  95. </if>
  96. <if test="mobilePhone !=null">
  97. #{mobilePhone},
  98. </if>
  99. <if test="customerName !=null">
  100. #{customerName},
  101. </if>
  102. <if test="points !=null">
  103. #{points},
  104. </if>
  105. <if test="consumptionPoints !=null">
  106. #{consumptionPoints},
  107. </if>
  108. <if test="accumulatePoints !=null">
  109. #{accumulatePoints},
  110. </if>
  111. <if test="invalidPoints !=null">
  112. #{invalidPoints},
  113. </if>
  114. <if test="recentConsumptionDate !=null">
  115. #{recentConsumptionDate},
  116. </if>
  117. <if test="stationId !=null">
  118. #{stationId},
  119. </if>
  120. <if test="stationName !=null">
  121. #{stationName},
  122. </if>
  123. <if test="createTime !=null">
  124. #{createTime},
  125. </if>
  126. </trim>
  127. </insert>
  128. <!--更新客户积分表-->
  129. <update id="updateCustomerPointsInfo" parameterType="com.platform.yijia.pojo.CustomerPoints">
  130. UPDATE
  131. customer_points
  132. <set>
  133. <if test="mobilePhone !=null">
  134. mobile_phone=#{mobilePhone},
  135. </if>
  136. <if test="customerName !=null">
  137. customer_name =#{customerName},
  138. </if>
  139. <if test="points !=null">
  140. points =#{points},
  141. </if>
  142. <if test="consumptionPoints !=null">
  143. consumption_points =#{consumptionPoints},
  144. </if>
  145. <if test="accumulatePoints !=null">
  146. accumulate_points =#{accumulatePoints},
  147. </if>
  148. <if test="invalidPoints !=null">
  149. invalid_points =#{invalidPoints},
  150. </if>
  151. <if test="recentConsumptionDate !=null">
  152. recent_consumption_date =#{recentConsumptionDate},
  153. </if>
  154. <if test="stationId !=null">
  155. station_id =#{stationId},
  156. </if>
  157. <if test="stationName !=null">
  158. station_name =#{stationName},
  159. </if>
  160. <if test="createTime !=null">
  161. create_time =#{createTime},
  162. </if>
  163. <if test="unionId !=null and unionId !=''">
  164. union_id = #{unionId},
  165. </if>
  166. </set>
  167. <where>
  168. <if test="stationId !='' and stationId != null" >
  169. station_id = #{stationId}
  170. </if>
  171. <if test="unionId !=null and unionId !=''">
  172. AND union_id = #{unionId}
  173. </if>
  174. </where>
  175. </update>
  176. <!--判断是否存在-->
  177. <select id="isExistCustomerPointsInfo" resultType="int" parameterType="com.platform.yijia.pojo.CustomerPoints">
  178. SELECT
  179. COUNT(id)
  180. FROM
  181. customer_points
  182. <where>
  183. <if test="stationId !='' and stationId != null" >
  184. station_id = #{stationId}
  185. </if>
  186. <if test="unionId !=null and unionId !=''">
  187. AND union_id = #{unionId}
  188. </if>
  189. </where>
  190. </select>
  191. </mapper>