CustomerCardRecordConsumptionMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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.CustomerCardRecordConsumptionMapper">
  6. <resultMap type="CustomerCardRecordConsumption" id="CustomerCardRecordConsumptionResult">
  7. <result property="id" column="id" />
  8. <result property="orderNo" column="order_no" />
  9. <result property="unionId" column="union_id" />
  10. <result property="customerNo" column="customer_no" />
  11. <result property="customerName" column="customer_name" />
  12. <result property="usageType" column="usage_type" />
  13. <result property="payType" column="pay_type" />
  14. <result property="cardOilsType" column="card_oils_type" />
  15. <result property="amt" column="amt" />
  16. <result property="createTime" column="create_time" />
  17. <result property="payDate" column="pay_date" />
  18. <result property="balance" column="balance" />
  19. <result property="stationId" column="station_id" />
  20. <result property="stationName" column="station_name" />
  21. <result property="status" column="status" />
  22. </resultMap>
  23. <sql id="selectCustomerCardRecordConsumptionVo">
  24. select id, order_no, union_id, customer_no, customer_name, usage_type, pay_type, card_oils_type, amt, create_time, balance,station_id, station_name, status
  25. from customer_card_record_consumption a
  26. </sql>
  27. <select id="selectCustomerCardRecordConsumptionList" parameterType="CustomerCardRecordConsumption" resultMap="CustomerCardRecordConsumptionResult">
  28. <!-- <include refid="selectCustomerCardRecordConsumptionVo"/>-->
  29. select a.id, a.order_no, a.union_id, a.customer_no, a.customer_name, a.usage_type, a.pay_type, a.card_oils_type, a.amt, a.create_time, a.balance,a.station_id,
  30. a.station_name, a.status,b.pay_date
  31. from customer_card_record_consumption a join pay_order b on a.order_no=b.order_no
  32. <where>
  33. <if test="orderNo != null and orderNo != ''"> and a.order_no = #{orderNo}</if>
  34. <if test="unionId != null and unionId != ''"> and a.union_id = #{unionId}</if>
  35. <if test="customerNo != null and customerNo != ''"> and a.customer_no = #{customerNo}</if>
  36. <if test="customerName != null and customerName != ''"> and a.customer_name like concat('%', #{customerName}, '%')</if>
  37. <if test="usageType != null and usageType != ''"> and a.usage_type = #{usageType}</if>
  38. <if test="payType != null and payType != ''"> and a.pay_type = #{payType}</if>
  39. <if test="cardOilsType != null and cardOilsType != ''"> and a.card_oils_type = #{cardOilsType}</if>
  40. <if test="amt != null "> and a.amt = #{amt}</if>
  41. <if test="balance != null "> and a.balance = #{balance}</if>
  42. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  43. <if test="stationName != null and stationName != ''"> and a.station_name like concat('%', #{stationName}, '%')</if>
  44. <if test="status != null and status != ''"> and a.status = #{status}</if>
  45. <if test="stationIdList != null ">
  46. and a.station_id in
  47. <foreach item="item" index="index" collection="stationIdList"
  48. open="(" separator="," close=")">
  49. #{item}
  50. </foreach>
  51. </if>
  52. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  53. AND date_format(a.create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  54. </if>
  55. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  56. AND date_format(a.create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  57. </if>
  58. </where>
  59. order by id desc
  60. </select>
  61. <select id="selectCustomerCardRecordConsumptionById" parameterType="Long" resultMap="CustomerCardRecordConsumptionResult">
  62. <include refid="selectCustomerCardRecordConsumptionVo"/>
  63. where id = #{id}
  64. </select>
  65. <insert id="insertCustomerCardRecordConsumption" parameterType="CustomerCardRecordConsumption" useGeneratedKeys="true" keyProperty="id">
  66. insert into customer_card_record_consumption
  67. <trim prefix="(" suffix=")" suffixOverrides=",">
  68. <if test="orderNo != null">order_no,</if>
  69. <if test="unionId != null">union_id,</if>
  70. <if test="customerNo != null">customer_no,</if>
  71. <if test="customerName != null">customer_name,</if>
  72. <if test="usageType != null">usage_type,</if>
  73. <if test="payType != null">pay_type,</if>
  74. <if test="cardOilsType != null">card_oils_type,</if>
  75. <if test="amt != null">amt,</if>
  76. <if test="balance != null">balance,</if>
  77. <if test="createTime != null">create_time,</if>
  78. <if test="stationId != null">station_id,</if>
  79. <if test="stationName != null">station_name,</if>
  80. <if test="status != null">status,</if>
  81. </trim>
  82. <trim prefix="values (" suffix=")" suffixOverrides=",">
  83. <if test="orderNo != null">#{orderNo},</if>
  84. <if test="unionId != null">#{unionId},</if>
  85. <if test="customerNo != null">#{customerNo},</if>
  86. <if test="customerName != null">#{customerName},</if>
  87. <if test="usageType != null">#{usageType},</if>
  88. <if test="payType != null">#{payType},</if>
  89. <if test="cardOilsType != null">#{cardOilsType},</if>
  90. <if test="amt != null">#{amt},</if>
  91. <if test="balance != null">#{balance},</if>
  92. <if test="createTime != null">#{createTime},</if>
  93. <if test="stationId != null">#{stationId},</if>
  94. <if test="stationName != null">#{stationName},</if>
  95. <if test="status != null">#{status},</if>
  96. </trim>
  97. </insert>
  98. <update id="updateCustomerCardRecordConsumption" parameterType="CustomerCardRecordConsumption">
  99. update customer_card_record_consumption
  100. <trim prefix="SET" suffixOverrides=",">
  101. <if test="orderNo != null">order_no = #{orderNo},</if>
  102. <if test="unionId != null">union_id = #{unionId},</if>
  103. <if test="customerNo != null">customer_no = #{customerNo},</if>
  104. <if test="customerName != null">customer_name = #{customerName},</if>
  105. <if test="usageType != null">usage_type = #{usageType},</if>
  106. <if test="payType != null">pay_type = #{payType},</if>
  107. <if test="cardOilsType != null">card_oils_type = #{cardOilsType},</if>
  108. <if test="amt != null">amt = #{amt},</if>
  109. <if test="createTime != null">create_time = #{createTime},</if>
  110. <if test="balance != null">balance = #{balance},</if>
  111. <if test="stationId != null">station_id = #{stationId},</if>
  112. <if test="stationName != null">station_name = #{stationName},</if>
  113. <if test="status != null">status = #{status},</if>
  114. </trim>
  115. where id = #{id}
  116. </update>
  117. <delete id="deleteCustomerCardRecordConsumptionById" parameterType="Long">
  118. delete from customer_card_record_consumption where id = #{id}
  119. </delete>
  120. <delete id="deleteCustomerCardRecordConsumptionByIds" parameterType="String">
  121. delete from customer_card_record_consumption where id in
  122. <foreach item="id" collection="array" open="(" separator="," close=")">
  123. #{id}
  124. </foreach>
  125. </delete>
  126. <select id="xfAmtQuery" parameterType="CustomerCardRecordConsumption" resultMap="CustomerCardRecordConsumptionResult">
  127. SELECT sum(amt) as amt from customer_card_record_consumption
  128. <where>
  129. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  130. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  131. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  132. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  133. <if test="usageType != null and usageType != ''"> and usage_type = #{usageType}</if>
  134. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  135. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  136. <if test="amt != null "> and amt = #{amt}</if>
  137. <if test="balance != null "> and balance = #{balance}</if>
  138. <if test="stationId != null "> and station_id = #{stationId}</if>
  139. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  140. <if test="status != null and status != ''"> and status = #{status}</if>
  141. <if test="stationIdList != null ">
  142. and station_id in
  143. <foreach item="item" index="index" collection="stationIdList"
  144. open="(" separator="," close=")">
  145. #{item}
  146. </foreach>
  147. </if>
  148. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  149. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  150. </if>
  151. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  152. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  153. </if>
  154. </where>
  155. </select>
  156. <select id="listXdata" parameterType="CustomerCardRecordConsumption" resultMap="CustomerCardRecordConsumptionResult">
  157. SELECT date_format(create_time,'%Y-%m-%d') as create_time from customer_card_record_consumption
  158. <where>
  159. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  160. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  161. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  162. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  163. <if test="usageType != null and usageType != ''"> and usage_type = #{usageType}</if>
  164. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  165. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  166. <if test="amt != null "> and amt = #{amt}</if>
  167. <if test="balance != null "> and balance = #{balance}</if>
  168. <if test="stationId != null "> and station_id = #{stationId}</if>
  169. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  170. <if test="status != null and status != ''"> and status = #{status}</if>
  171. <if test="stationIdList != null ">
  172. and station_id in
  173. <foreach item="item" index="index" collection="stationIdList"
  174. open="(" separator="," close=")">
  175. #{item}
  176. </foreach>
  177. </if>
  178. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  179. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  180. </if>
  181. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  182. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  183. </if>
  184. </where>
  185. union
  186. SELECT date_format(create_time,'%Y-%m-%d') as create_time from customer_card_record_recharge
  187. <where>
  188. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  189. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  190. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  191. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  192. <if test="usageType != null and usageType != ''"> and usage_type = #{usageType}</if>
  193. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  194. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  195. <if test="amt != null "> and amt = #{amt}</if>
  196. <if test="balance != null "> and balance = #{balance}</if>
  197. <if test="stationId != null "> and station_id = #{stationId}</if>
  198. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  199. <if test="status != null and status != ''"> and status = #{status}</if>
  200. <if test="stationIdList != null ">
  201. and station_id in
  202. <foreach item="item" index="index" collection="stationIdList"
  203. open="(" separator="," close=")">
  204. #{item}
  205. </foreach>
  206. </if>
  207. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  208. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  209. </if>
  210. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  211. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  212. </if>
  213. </where>
  214. order by date_format(create_time,'%Y-%m-%d')
  215. </select>
  216. <select id="listQydataXF" parameterType="CustomerCardRecordConsumption" resultMap="CustomerCardRecordConsumptionResult">
  217. SELECT date_format(create_time,'%Y-%m-%d') as create_time,sum(amt) as amt
  218. from customer_card_record_consumption
  219. <where>
  220. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  221. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  222. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  223. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  224. <if test="usageType != null and usageType != ''"> and usage_type = #{usageType}</if>
  225. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  226. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  227. <if test="amt != null "> and amt = #{amt}</if>
  228. <if test="balance != null "> and balance = #{balance}</if>
  229. <if test="stationId != null "> and station_id = #{stationId}</if>
  230. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  231. <if test="status != null and status != ''"> and status = #{status}</if>
  232. <if test="stationIdList != null ">
  233. and station_id in
  234. <foreach item="item" index="index" collection="stationIdList"
  235. open="(" separator="," close=")">
  236. #{item}
  237. </foreach>
  238. </if>
  239. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  240. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  241. </if>
  242. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  243. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  244. </if>
  245. </where>
  246. GROUP BY date_format(create_time,'%Y-%m-%d')
  247. </select>
  248. <select id="listXFData" parameterType="CustomerCardRecordConsumption" resultMap="CustomerCardRecordConsumptionResult">
  249. SELECT sum(amt) as amt from customer_card_record_consumption
  250. <where>
  251. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  252. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  253. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  254. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  255. <if test="usageType != null and usageType != ''"> and usage_type = #{usageType}</if>
  256. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  257. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  258. <if test="amt != null "> and amt = #{amt}</if>
  259. <if test="balance != null "> and balance = #{balance}</if>
  260. <if test="stationId != null "> and station_id = #{stationId}</if>
  261. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  262. <if test="status != null and status != ''"> and status = #{status}</if>
  263. <if test="stationIdList != null ">
  264. and station_id in
  265. <foreach item="item" index="index" collection="stationIdList"
  266. open="(" separator="," close=")">
  267. #{item}
  268. </foreach>
  269. </if>
  270. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  271. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  272. </if>
  273. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  274. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  275. </if>
  276. </where>
  277. </select>
  278. </mapper>