CustomerPointsMapper.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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, blog_openid, mina_openid, 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="getCustomerPointsInfoByMinaOpenId" 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="minaOpenId !=null and minaOpenId !=''">
  47. mina_openid = #{minaOpenId}
  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="blogOpenId !=null">
  62. blog_openid,
  63. </if>
  64. <if test="minaOpenId !=null">
  65. mina_openid,
  66. </if>
  67. <if test="mobilePhone !=null">
  68. mobile_phone,
  69. </if>
  70. <if test="customerName !=null">
  71. customer_name,
  72. </if>
  73. <if test="points !=null">
  74. points,
  75. </if>
  76. <if test="consumptionPoints !=null">
  77. consumption_points,
  78. </if>
  79. <if test="accumulatePoints !=null">
  80. accumulate_points,
  81. </if>
  82. <if test="invalidPoints !=null">
  83. invalid_points,
  84. </if>
  85. <if test="recentConsumptionDate !=null">
  86. recent_consumption_date,
  87. </if>
  88. <if test="stationId !=null">
  89. station_id,
  90. </if>
  91. <if test="stationName !=null">
  92. station_name,
  93. </if>
  94. <if test="createTime !=null">
  95. create_time,
  96. </if>
  97. </trim>
  98. <trim prefix="values (" suffix=")" suffixOverrides=",">
  99. <if test="unionId !=null">
  100. #{unionId},
  101. </if>
  102. <if test="blogOpenId !=null">
  103. #{blogOpenId},
  104. </if>
  105. <if test="minaOpenId !=null">
  106. #{minaOpenId},
  107. </if>
  108. <if test="mobilePhone !=null">
  109. #{mobilePhone},
  110. </if>
  111. <if test="customerName !=null">
  112. #{customerName},
  113. </if>
  114. <if test="points !=null">
  115. #{points},
  116. </if>
  117. <if test="consumptionPoints !=null">
  118. #{consumptionPoints},
  119. </if>
  120. <if test="accumulatePoints !=null">
  121. #{accumulatePoints},
  122. </if>
  123. <if test="invalidPoints !=null">
  124. #{invalidPoints},
  125. </if>
  126. <if test="recentConsumptionDate !=null">
  127. #{recentConsumptionDate},
  128. </if>
  129. <if test="stationId !=null">
  130. #{stationId},
  131. </if>
  132. <if test="stationName !=null">
  133. #{stationName},
  134. </if>
  135. <if test="createTime !=null">
  136. #{createTime},
  137. </if>
  138. </trim>
  139. </insert>
  140. <!--更新客户积分表-->
  141. <update id="updateCustomerPointsInfo" parameterType="com.platform.yijia.pojo.CustomerPoints">
  142. UPDATE
  143. customer_points
  144. <set>
  145. <if test="blogOpenId !=null">
  146. blog_openid =#{blogOpenId},
  147. </if>
  148. <if test="minaOpenId !=null">
  149. mina_openid =#{minaOpenId},
  150. </if>
  151. <if test="mobilePhone !=null">
  152. mobile_phone=#{mobilePhone},
  153. </if>
  154. <if test="customerName !=null">
  155. customer_name =#{customerName},
  156. </if>
  157. <if test="points !=null">
  158. points =#{points},
  159. </if>
  160. <if test="consumptionPoints !=null">
  161. consumption_points =#{consumptionPoints},
  162. </if>
  163. <if test="accumulatePoints !=null">
  164. accumulate_points =#{accumulatePoints},
  165. </if>
  166. <if test="invalidPoints !=null">
  167. invalid_points =#{invalidPoints},
  168. </if>
  169. <if test="recentConsumptionDate !=null">
  170. recent_consumption_date =#{recentConsumptionDate},
  171. </if>
  172. <if test="stationId !=null">
  173. station_id =#{stationId},
  174. </if>
  175. <if test="stationName !=null">
  176. station_name =#{stationName},
  177. </if>
  178. <if test="createTime !=null">
  179. create_time =#{createTime},
  180. </if>
  181. <if test="unionId !=null and unionId !=''">
  182. union_id = #{unionId},
  183. </if>
  184. </set>
  185. <where>
  186. <if test="stationId !='' and stationId != null" >
  187. station_id = #{stationId}
  188. </if>
  189. <!-- <if test="unionId !=null and unionId !=''">-->
  190. <!-- AND union_id = #{unionId}-->
  191. <!-- </if>-->
  192. <if test="blogOpenId !=null and blogOpenId !=''">
  193. AND blog_openid = #{blogOpenId}
  194. </if>
  195. <if test="minaOpenId !=null and minaOpenId !=''">
  196. AND mina_openid = #{minaOpenId}
  197. </if>
  198. </where>
  199. </update>
  200. <!--判断是否存在-->
  201. <select id="isExistCustomerPointsInfo" resultType="int" parameterType="com.platform.yijia.pojo.CustomerPoints">
  202. SELECT
  203. COUNT(id)
  204. FROM
  205. customer_points
  206. <where>
  207. <if test="stationId !='' and stationId != null" >
  208. station_id = #{stationId}
  209. </if>
  210. <if test="blogOpenId !=null and blogOpenId !=''">
  211. AND blog_openid = #{blogOpenId}
  212. </if>
  213. <if test="minaOpenId !=null and minaOpenId !=''">
  214. AND mina_openid = #{minaOpenId}
  215. </if>
  216. </where>
  217. </select>
  218. </mapper>