CustomerElectronicCardMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.customer.mapper.CustomerElectronicCardMapper">
  6. <resultMap type="CustomerElectronicCard" id="CustomerElectronicCardResult">
  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="customerNo" column="customer_no" />
  12. <result property="customerName" column="customer_name" />
  13. <result property="mobilePhone" column="mobile_phone" />
  14. <result property="amt" column="amt" />
  15. <result property="cardOilsType" column="card_oils_type" />
  16. <result property="stationId" column="station_id" />
  17. <result property="stationName" column="station_name" />
  18. <result property="createTime" column="create_time" />
  19. <result property="recentlyTime" column="recently_time" />
  20. <result property="num" column="num" />
  21. <result property="czamt" column="czamt" />
  22. <result property="xfamt" column="xfamt" />
  23. <result property="cardnum" column="cardnum" />
  24. <result property="cumamt" column="cumamt" />
  25. <result property="cumnum" column="cumnum" />
  26. </resultMap>
  27. <sql id="selectCustomerElectronicCardVo">
  28. select id, union_id, blog_openid, mina_openid, customer_no, customer_name, mobile_phone, amt, card_oils_type, station_id, station_name, create_time, recently_time from customer_electronic_card
  29. </sql>
  30. <select id="selectCustomerElectronicCardList" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
  31. <include refid="selectCustomerElectronicCardVo"/>
  32. <where>
  33. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  34. <if test="blogOpenid != null and blogOpenid != ''"> and blog_openid = #{blogOpenid}</if>
  35. <if test="minaOpenid != null and minaOpenid != ''"> and mina_openid = #{minaOpenid}</if>
  36. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  37. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  38. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
  39. <if test="amt != null "> and amt = #{amt}</if>
  40. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  41. <if test="stationId != null "> and station_id = #{stationId}</if>
  42. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  43. <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</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. </select>
  53. <select id="selectCustomerElectronicCardById" parameterType="Long" resultMap="CustomerElectronicCardResult">
  54. <include refid="selectCustomerElectronicCardVo"/>
  55. where id = #{id}
  56. </select>
  57. <insert id="insertCustomerElectronicCard" parameterType="CustomerElectronicCard" useGeneratedKeys="true" keyProperty="id">
  58. insert into customer_electronic_card
  59. <trim prefix="(" suffix=")" suffixOverrides=",">
  60. <if test="unionId != null">union_id,</if>
  61. <if test="blogOpenid != null">blog_openid,</if>
  62. <if test="minaOpenid != null">mina_openid,</if>
  63. <if test="customerNo != null">customer_no,</if>
  64. <if test="customerName != null">customer_name,</if>
  65. <if test="mobilePhone != null">mobile_phone,</if>
  66. <if test="amt != null">amt,</if>
  67. <if test="cardOilsType != null">card_oils_type,</if>
  68. <if test="stationId != null">station_id,</if>
  69. <if test="stationName != null">station_name,</if>
  70. <if test="createTime != null">create_time,</if>
  71. <if test="recentlyTime != null">recently_time,</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="customerNo != null">#{customerNo},</if>
  78. <if test="customerName != null">#{customerName},</if>
  79. <if test="mobilePhone != null">#{mobilePhone},</if>
  80. <if test="amt != null">#{amt},</if>
  81. <if test="cardOilsType != null">#{cardOilsType},</if>
  82. <if test="stationId != null">#{stationId},</if>
  83. <if test="stationName != null">#{stationName},</if>
  84. <if test="createTime != null">#{createTime},</if>
  85. <if test="recentlyTime != null">#{recentlyTime},</if>
  86. </trim>
  87. </insert>
  88. <update id="updateCustomerElectronicCard" parameterType="CustomerElectronicCard">
  89. update customer_electronic_card
  90. <trim prefix="SET" suffixOverrides=",">
  91. <if test="unionId != null">union_id = #{unionId},</if>
  92. <if test="blogOpenid != null">blog_openid = #{blogOpenid},</if>
  93. <if test="minaOpenid != null">mina_openid = #{minaOpenid},</if>
  94. <if test="customerNo != null">customer_no = #{customerNo},</if>
  95. <if test="customerName != null">customer_name = #{customerName},</if>
  96. <if test="mobilePhone != null">mobile_phone = #{mobilePhone},</if>
  97. <if test="amt != null">amt = #{amt},</if>
  98. <if test="cardOilsType != null">card_oils_type = #{cardOilsType},</if>
  99. <if test="stationId != null">station_id = #{stationId},</if>
  100. <if test="stationName != null">station_name = #{stationName},</if>
  101. <if test="createTime != null">create_time = #{createTime},</if>
  102. <if test="recentlyTime != null">recently_time = #{recentlyTime},</if>
  103. </trim>
  104. where id = #{id}
  105. </update>
  106. <delete id="deleteCustomerElectronicCardById" parameterType="Long">
  107. delete from customer_electronic_card where id = #{id}
  108. </delete>
  109. <delete id="deleteCustomerElectronicCardByIds" parameterType="String">
  110. delete from customer_electronic_card where id in
  111. <foreach item="id" collection="array" open="(" separator="," close=")">
  112. #{id}
  113. </foreach>
  114. </delete>
  115. <select id="listSum" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
  116. SELECT count(DISTINCT union_id) as num,sum(amt) as amt
  117. from customer_electronic_card
  118. <where>
  119. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  120. <if test="blogOpenid != null and blogOpenid != ''"> and blog_openid = #{blogOpenid}</if>
  121. <if test="minaOpenid != null and minaOpenid != ''"> and mina_openid = #{minaOpenid}</if>
  122. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  123. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  124. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
  125. <if test="amt != null "> and amt = #{amt}</if>
  126. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  127. <if test="stationId != null "> and station_id = #{stationId}</if>
  128. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  129. <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
  130. <if test="stationIdList != null ">
  131. and station_id in
  132. <foreach item="item" index="index" collection="stationIdList"
  133. open="(" separator="," close=")">
  134. #{item}
  135. </foreach>
  136. </if>
  137. </where>
  138. </select>
  139. <select id="listHYData" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
  140. SELECT sum(amt) as amt,count(DISTINCT union_id ) as num
  141. from customer_electronic_card
  142. <where>
  143. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  144. <if test="blogOpenid != null and blogOpenid != ''"> and blog_openid = #{blogOpenid}</if>
  145. <if test="minaOpenid != null and minaOpenid != ''"> and mina_openid = #{minaOpenid}</if>
  146. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  147. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  148. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
  149. <if test="amt != null "> and amt = #{amt}</if>
  150. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  151. <if test="stationId != null "> and station_id = #{stationId}</if>
  152. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  153. <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
  154. <if test="stationIdList != null ">
  155. and station_id in
  156. <foreach item="item" index="index" collection="stationIdList"
  157. open="(" separator="," close=")">
  158. #{item}
  159. </foreach>
  160. </if>
  161. </where>
  162. </select>
  163. <select id="listJRHYData" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
  164. SELECT count(DISTINCT union_id ) as num from customer_electronic_card
  165. <where>
  166. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  167. <if test="blogOpenid != null and blogOpenid != ''"> and blog_openid = #{blogOpenid}</if>
  168. <if test="minaOpenid != null and minaOpenid != ''"> and mina_openid = #{minaOpenid}</if>
  169. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  170. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  171. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
  172. <if test="amt != null "> and amt = #{amt}</if>
  173. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  174. <if test="stationId != null "> and station_id = #{stationId}</if>
  175. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  176. <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
  177. <if test="stationIdList != null ">
  178. and station_id in
  179. <foreach item="item" index="index" collection="stationIdList"
  180. open="(" separator="," close=")">
  181. #{item}
  182. </foreach>
  183. </if>
  184. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  185. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  186. </if>
  187. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  188. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  189. </if>
  190. </where>
  191. </select>
  192. <!--存储过程
  193. CALL selectCard();
  194. CALL selectCard(#{pageNo,mode=IN},#{pageSetting,mode=IN});-->
  195. <select id="selectCard" parameterType="CustomerElectronicCard" statementType="CALLABLE" resultMap="CustomerElectronicCardResult">
  196. CALL selectCard(#{strSql,mode=IN},#{pageNo,mode=IN},#{pageSetting,mode=IN});
  197. </select>
  198. <!--存储过程-->
  199. <select id="selectCardPage" parameterType="CustomerElectronicCard" statementType="CALLABLE" resultMap="CustomerElectronicCardResult">
  200. CALL selectCardPage(#{strSql,mode=IN});
  201. </select>
  202. </mapper>