PayOrderMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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.station.mapper.PayOrderMapper">
  6. <resultMap type="PayOrder" id="PayOrderResult">
  7. <result property="orderId" column="order_id" />
  8. <result property="orderNo" column="order_no" />
  9. <result property="stationId" column="station_id" />
  10. <result property="stationName" column="station_name" />
  11. <result property="status" column="status" />
  12. <result property="consumerId" column="consumer_id" />
  13. <result property="consumer" column="consumer" />
  14. <result property="oilGun" column="oil_gun" />
  15. <result property="oilName" column="oil_name" />
  16. <result property="oilPirce" column="oil_pirce" />
  17. <result property="oilType" column="oil_type" />
  18. <result property="orderLiters" column="order_liters" />
  19. <result property="amt" column="amt" />
  20. <result property="receivableAmt" column="receivable_amt" />
  21. <result property="discountAmt" column="discount_amt" />
  22. <result property="discountCouponAmt" column="discount_coupon_amt" />
  23. <result property="discountCoupon" column="discount_coupon" />
  24. <result property="wxAmt" column="wx_amt" />
  25. <result property="zfbAmt" column="zfb_amt" />
  26. <result property="posAmt" column="pos_amt" />
  27. <result property="xjAmt" column="xj_amt" />
  28. <result property="didiAppAmt" column="didi_app_amt" />
  29. <result property="tyAppAmt" column="ty_app_amt" />
  30. <result property="otherAmt" column="other_amt" />
  31. <result property="dzkAmt" column="dzk_amt" />
  32. <result property="score" column="score" />
  33. <result property="memberAmt" column="member_amt" />
  34. <result property="printCount" column="print_count" />
  35. <result property="payType" column="pay_type" />
  36. <result property="payWay" column="pay_way" />
  37. <result property="oilPersonnel" column="oil_personnel" />
  38. <result property="payDate" column="pay_date" />
  39. <result property="createdDate" column="created_date" />
  40. <result property="orderType" column="order_type" />
  41. <result property="cyAmt" column="cy_amt" />
  42. <result property="qyAmt" column="qy_amt" />
  43. </resultMap>
  44. <sql id="selectPayOrderVo">
  45. select order_id, order_no, station_id, station_name, status, consumer_id, consumer, oil_gun, oil_name, oil_pirce, oil_type, order_liters, amt, receivable_amt, discount_amt, discount_coupon_amt, discount_coupon, wx_amt, zfb_amt, pos_amt, xj_amt, didi_app_amt, ty_app_amt, other_amt, dzk_amt, score, member_amt, print_count, pay_type, pay_way, oil_personnel, pay_date, created_date, order_type from pay_order
  46. </sql>
  47. <select id="selectPayOrderList" parameterType="PayOrder" resultMap="PayOrderResult">
  48. <include refid="selectPayOrderVo"/>
  49. <where>
  50. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  51. <if test="stationId != null "> and station_id = #{stationId}</if>
  52. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  53. <if test="status != null and status != ''"> and status = #{status}</if>
  54. <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
  55. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  56. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  57. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  58. <if test="oilPirce != null and oilPirce != ''"> and oil_pirce = #{oilPirce}</if>
  59. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  60. <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
  61. <if test="amt != null "> and amt = #{amt}</if>
  62. <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
  63. <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
  64. <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
  65. <if test="discountCoupon != null and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
  66. <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
  67. <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
  68. <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
  69. <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
  70. <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
  71. <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
  72. <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
  73. <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
  74. <if test="score != null "> and score = #{score}</if>
  75. <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
  76. <if test="printCount != null "> and print_count = #{printCount}</if>
  77. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  78. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  79. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  80. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  81. </if>
  82. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  83. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  84. </if>
  85. <!-- <if test="payDate != null "> and pay_date = #{payDate}</if>-->
  86. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  87. <if test="payDate != null "> and pay_date = #{payDate}</if>
  88. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  89. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  90. </where>
  91. ORDER BY created_date DESC
  92. </select>
  93. <select id="selectPayOrderById" parameterType="Long" resultMap="PayOrderResult">
  94. <include refid="selectPayOrderVo"/>
  95. where order_id = #{orderId}
  96. </select>
  97. <select id="selectDaySources" parameterType="Long" resultMap="PayOrderResult">
  98. SELECT SUM(amt) as amt,sum(order_liters) as order_liters
  99. from pay_order
  100. <where>
  101. <if test="createdDate != null "> and created_date like concat(#{createdDate}, '%') </if>
  102. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  103. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  104. </if>
  105. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  106. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  107. </if>
  108. </where>
  109. </select>
  110. <select id="selectOilTypeSources" parameterType="Long" resultMap="PayOrderResult">
  111. SELECT SUM(amt) as amt,sum(order_liters) as order_liters, oil_type
  112. from pay_order
  113. <where>
  114. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  115. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  116. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  117. </if>
  118. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  119. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  120. </if>
  121. </where>
  122. GROUP BY oil_type
  123. </select>
  124. <select id="selectOverViewData" parameterType="Long" resultMap="PayOrderResult">
  125. SELECT SUM(wx_amt) as wx_amt,sum(zfb_amt) as zfb_amt, sum(pos_amt) as pos_amt, sum(xj_amt) as xj_amt,sum(didi_app_amt) as didi_app_amt,sum(ty_app_amt) as ty_app_amt,sum(other_amt) as other_amt,sum(member_amt) as member_amt
  126. from pay_order
  127. <where>
  128. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  129. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  130. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  131. </if>
  132. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  133. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  134. </if>
  135. </where>
  136. </select>
  137. <select id="selectDayReport" parameterType="Long" resultMap="PayOrderResult">
  138. SELECT date_format( b.pay_date, '%Y-%m-%d' ) as pay_date,sum(b.amt) as amt,sum(b.qyamt) as qy_amt, sum(b.cyamt) as cy_amt,sum(b.order_liters) as order_liters ,count(b.order_no) order_no ,sum(b.member_amt) as menber_amt
  139. from (SELECT a.*,(SELECT sum(amt) as qyamt from pay_order where order_no=a.order_no and oil_type=2) as qyamt , (SELECT sum(amt) as qyamt from pay_order where order_no=a.order_no and oil_type=1) as cyamt
  140. from pay_order a) b
  141. GROUP BY date_format( pay_date, '%Y-%m-%d' )
  142. </select>
  143. <insert id="insertPayOrder" parameterType="PayOrder" useGeneratedKeys="true" keyProperty="orderId">
  144. insert into pay_order
  145. <trim prefix="(" suffix=")" suffixOverrides=",">
  146. <if test="orderNo != null">order_no,</if>
  147. <if test="stationId != null">station_id,</if>
  148. <if test="stationName != null">station_name,</if>
  149. <if test="status != null">status,</if>
  150. <if test="consumerId != null">consumer_id,</if>
  151. <if test="consumer != null">consumer,</if>
  152. <if test="oilGun != null">oil_gun,</if>
  153. <if test="oilName != null">oil_name,</if>
  154. <if test="oilPirce != null">oil_pirce,</if>
  155. <if test="oilType != null">oil_type,</if>
  156. <if test="orderLiters != null">order_liters,</if>
  157. <if test="amt != null">amt,</if>
  158. <if test="receivableAmt != null">receivable_amt,</if>
  159. <if test="discountAmt != null">discount_amt,</if>
  160. <if test="discountCouponAmt != null">discount_coupon_amt,</if>
  161. <if test="discountCoupon != null">discount_coupon,</if>
  162. <if test="wxAmt != null">wx_amt,</if>
  163. <if test="zfbAmt != null">zfb_amt,</if>
  164. <if test="posAmt != null">pos_amt,</if>
  165. <if test="xjAmt != null">xj_amt,</if>
  166. <if test="didiAppAmt != null">didi_app_amt,</if>
  167. <if test="tyAppAmt != null">ty_app_amt,</if>
  168. <if test="otherAmt != null">other_amt,</if>
  169. <if test="dzkAmt != null">dzk_amt,</if>
  170. <if test="score != null">score,</if>
  171. <if test="memberAmt != null">member_amt,</if>
  172. <if test="printCount != null">print_count,</if>
  173. <if test="payType != null">pay_type,</if>
  174. <if test="payWay != null">pay_way,</if>
  175. <if test="oilPersonnel != null">oil_personnel,</if>
  176. <if test="payDate != null">pay_date,</if>
  177. <if test="createdDate != null">created_date,</if>
  178. <if test="orderType != null">order_type,</if>
  179. </trim>
  180. <trim prefix="values (" suffix=")" suffixOverrides=",">
  181. <if test="orderNo != null">#{orderNo},</if>
  182. <if test="stationId != null">#{stationId},</if>
  183. <if test="stationName != null">#{stationName},</if>
  184. <if test="status != null">#{status},</if>
  185. <if test="consumerId != null">#{consumerId},</if>
  186. <if test="consumer != null">#{consumer},</if>
  187. <if test="oilGun != null">#{oilGun},</if>
  188. <if test="oilName != null">#{oilName},</if>
  189. <if test="oilPirce != null">#{oilPirce},</if>
  190. <if test="oilType != null">#{oilType},</if>
  191. <if test="orderLiters != null">#{orderLiters},</if>
  192. <if test="amt != null">#{amt},</if>
  193. <if test="receivableAmt != null">#{receivableAmt},</if>
  194. <if test="discountAmt != null">#{discountAmt},</if>
  195. <if test="discountCouponAmt != null">#{discountCouponAmt},</if>
  196. <if test="discountCoupon != null">#{discountCoupon},</if>
  197. <if test="wxAmt != null">#{wxAmt},</if>
  198. <if test="zfbAmt != null">#{zfbAmt},</if>
  199. <if test="posAmt != null">#{posAmt},</if>
  200. <if test="xjAmt != null">#{xjAmt},</if>
  201. <if test="didiAppAmt != null">#{didiAppAmt},</if>
  202. <if test="tyAppAmt != null">#{tyAppAmt},</if>
  203. <if test="otherAmt != null">#{otherAmt},</if>
  204. <if test="dzkAmt != null">#{dzkAmt},</if>
  205. <if test="score != null">#{score},</if>
  206. <if test="memberAmt != null">#{memberAmt},</if>
  207. <if test="printCount != null">#{printCount},</if>
  208. <if test="payType != null">#{payType},</if>
  209. <if test="payWay != null">#{payWay},</if>
  210. <if test="oilPersonnel != null">#{oilPersonnel},</if>
  211. <if test="payDate != null">#{payDate},</if>
  212. <if test="createdDate != null">#{createdDate},</if>
  213. <if test="orderType != null">#{orderType},</if>
  214. </trim>
  215. </insert>
  216. <update id="updatePayOrder" parameterType="PayOrder">
  217. update pay_order
  218. <trim prefix="SET" suffixOverrides=",">
  219. <if test="orderNo != null">order_no = #{orderNo},</if>
  220. <if test="stationId != null">station_id = #{stationId},</if>
  221. <if test="stationName != null">station_name = #{stationName},</if>
  222. <if test="status != null">status = #{status},</if>
  223. <if test="consumerId != null">consumer_id = #{consumerId},</if>
  224. <if test="consumer != null">consumer = #{consumer},</if>
  225. <if test="oilGun != null">oil_gun = #{oilGun},</if>
  226. <if test="oilName != null">oil_name = #{oilName},</if>
  227. <if test="oilPirce != null">oil_pirce = #{oilPirce},</if>
  228. <if test="oilType != null">oil_type = #{oilType},</if>
  229. <if test="orderLiters != null">order_liters = #{orderLiters},</if>
  230. <if test="amt != null">amt = #{amt},</if>
  231. <if test="receivableAmt != null">receivable_amt = #{receivableAmt},</if>
  232. <if test="discountAmt != null">discount_amt = #{discountAmt},</if>
  233. <if test="discountCouponAmt != null">discount_coupon_amt = #{discountCouponAmt},</if>
  234. <if test="discountCoupon != null">discount_coupon = #{discountCoupon},</if>
  235. <if test="wxAmt != null">wx_amt = #{wxAmt},</if>
  236. <if test="zfbAmt != null">zfb_amt = #{zfbAmt},</if>
  237. <if test="posAmt != null">pos_amt = #{posAmt},</if>
  238. <if test="xjAmt != null">xj_amt = #{xjAmt},</if>
  239. <if test="didiAppAmt != null">didi_app_amt = #{didiAppAmt},</if>
  240. <if test="tyAppAmt != null">ty_app_amt = #{tyAppAmt},</if>
  241. <if test="otherAmt != null">other_amt = #{otherAmt},</if>
  242. <if test="dzkAmt != null">dzk_amt = #{dzkAmt},</if>
  243. <if test="score != null">score = #{score},</if>
  244. <if test="memberAmt != null">member_amt = #{memberAmt},</if>
  245. <if test="printCount != null">print_count = #{printCount},</if>
  246. <if test="payType != null">pay_type = #{payType},</if>
  247. <if test="payWay != null">pay_way = #{payWay},</if>
  248. <if test="oilPersonnel != null">oil_personnel = #{oilPersonnel},</if>
  249. <if test="payDate != null">pay_date = #{payDate},</if>
  250. <if test="createdDate != null">created_date = #{createdDate},</if>
  251. <if test="orderType != null">order_type = #{orderType},</if>
  252. </trim>
  253. where order_id = #{orderId}
  254. </update>
  255. <delete id="deletePayOrderById" parameterType="Long">
  256. delete from pay_order where order_id = #{orderId}
  257. </delete>
  258. <delete id="deletePayOrderByIds" parameterType="String">
  259. delete from pay_order where order_id in
  260. <foreach item="orderId" collection="array" open="(" separator="," close=")">
  261. #{orderId}
  262. </foreach>
  263. </delete>
  264. </mapper>