PayOrderMapper.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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="receivedAmt" column="received_amt" />
  22. <result property="discountAmt" column="discount_amt" />
  23. <result property="discountCouponAmt" column="discount_coupon_amt" />
  24. <result property="discountCoupon" column="discount_coupon" />
  25. <result property="wxAmt" column="wx_amt" />
  26. <result property="zfbAmt" column="zfb_amt" />
  27. <result property="posAmt" column="pos_amt" />
  28. <result property="xjAmt" column="xj_amt" />
  29. <result property="didiAppAmt" column="didi_app_amt" />
  30. <result property="tyAppAmt" column="ty_app_amt" />
  31. <result property="otherAmt" column="other_amt" />
  32. <result property="dzkAmt" column="dzk_amt" />
  33. <result property="score" column="score" />
  34. <result property="memberNo" column="member_no" />
  35. <result property="memberAmt" column="member_amt" />
  36. <result property="printCount" column="print_count" />
  37. <result property="payType" column="pay_type" />
  38. <result property="payWay" column="pay_way" />
  39. <result property="oilPersonnel" column="oil_personnel" />
  40. <result property="payDate" column="pay_date" />
  41. <result property="createdDate" column="created_date" />
  42. <result property="orderType" column="order_type" />
  43. <result property="carNo" column="car_no" />
  44. <result property="customerPhone" column="customer_phone" />
  45. <result property="customerGrade" column="customer_grade" />
  46. <result property="wxNum" column="wx_num" />
  47. <result property="zfbNum" column="zfb_num" />
  48. <result property="xjNum" column="xj_num" />
  49. <result property="qyAmt" column="qy_amt" />
  50. <result property="cyAmt" column="cy_amt" />
  51. </resultMap>
  52. <sql id="selectPayOrderVo">
  53. 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, received_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_no, member_amt, print_count, pay_type, pay_way, oil_personnel, pay_date, created_date, order_type, car_no, customer_phone, customer_grade from pay_order
  54. </sql>
  55. <select id="selectPayOrderList" parameterType="PayOrder" resultMap="PayOrderResult">
  56. <include refid="selectPayOrderVo"/>
  57. <where>
  58. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  59. <if test="stationId != null "> and station_id = #{stationId}</if>
  60. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  61. <if test="status != null and status != ''"> and status = #{status}</if>
  62. <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
  63. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  64. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  65. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  66. <if test="oilPirce != null "> and oil_pirce = #{oilPirce}</if>
  67. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  68. <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
  69. <if test="amt != null "> and amt = #{amt}</if>
  70. <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
  71. <if test="receivedAmt != null "> and received_amt = #{receivedAmt}</if>
  72. <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
  73. <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
  74. <if test="discountCoupon != null and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
  75. <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
  76. <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
  77. <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
  78. <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
  79. <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
  80. <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
  81. <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
  82. <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
  83. <if test="score != null "> and score = #{score}</if>
  84. <if test="memberNo != null and memberNo != ''"> and member_no = #{memberNo}</if>
  85. <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
  86. <if test="printCount != null "> and print_count = #{printCount}</if>
  87. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  88. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  89. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  90. <if test="payDate != null "> and pay_date = #{payDate}</if>
  91. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  92. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  93. <if test="carNo != null and carNo != ''"> and car_no = #{carNo}</if>
  94. <if test="customerPhone != null and customerPhone != ''"> and customer_phone = #{customerPhone}</if>
  95. <if test="customerGrade != null and customerGrade != ''"> and customer_grade = #{customerGrade}</if>
  96. <if test="likeConsumer != null and likeConsumer != ''"> and consumer like concat('%',#{likeConsumer}, '%')</if>
  97. <if test="likeCarNo != null and likeCarNo != ''"> and car_no like concat('%',#{likeCarNo}, '%') </if>
  98. <if test="likeCustomerPhone != null and likeCustomerPhone != ''"> and customer_phone like concat('%',#{likeCustomerPhone}, '%') </if>
  99. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  100. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  101. </if>
  102. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  103. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  104. </if>
  105. <if test="stationIdList != null ">
  106. and station_id in
  107. <foreach item="item" index="index" collection="stationIdList"
  108. open="(" separator="," close=")">
  109. #{item}
  110. </foreach>
  111. </if>
  112. </where>
  113. order by order_id desc
  114. </select>
  115. <!--查询导出数据-->
  116. <select id="selectPayOrderExport" parameterType="PayOrder" resultMap="PayOrderResult">
  117. select order_no,oil_name,oil_pirce,order_liters, amt,consumer,oil_personnel,oil_gun,pay_type,pay_way
  118. from pay_order
  119. <where>
  120. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  121. <if test="stationId != null "> and station_id = #{stationId}</if>
  122. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  123. <if test="status != null and status != ''"> and status = #{status}</if>
  124. <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
  125. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  126. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  127. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  128. <if test="oilPirce != null "> and oil_pirce = #{oilPirce}</if>
  129. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  130. <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
  131. <if test="amt != null "> and amt = #{amt}</if>
  132. <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
  133. <if test="receivedAmt != null "> and received_amt = #{receivedAmt}</if>
  134. <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
  135. <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
  136. <if test="discountCoupon != null and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
  137. <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
  138. <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
  139. <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
  140. <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
  141. <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
  142. <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
  143. <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
  144. <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
  145. <if test="score != null "> and score = #{score}</if>
  146. <if test="memberNo != null and memberNo != ''"> and member_no = #{memberNo}</if>
  147. <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
  148. <if test="printCount != null "> and print_count = #{printCount}</if>
  149. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  150. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  151. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  152. <if test="payDate != null "> and pay_date = #{payDate}</if>
  153. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  154. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  155. <if test="carNo != null and carNo != ''"> and car_no = #{carNo}</if>
  156. <if test="customerPhone != null and customerPhone != ''"> and customer_phone = #{customerPhone}</if>
  157. <if test="customerGrade != null and customerGrade != ''"> and customer_grade = #{customerGrade}</if>
  158. <if test="stationIdList != null ">
  159. and station_id in
  160. <foreach item="item" index="index" collection="stationIdList"
  161. open="(" separator="," close=")">
  162. #{item}
  163. </foreach>
  164. </if>
  165. </where>
  166. order by order_id desc
  167. </select>
  168. <select id="selectPayOrderById" parameterType="Long" resultMap="PayOrderResult">
  169. <include refid="selectPayOrderVo"/>
  170. where order_id = #{orderId}
  171. </select>
  172. <select id="selectDaySources" parameterType="Long" resultMap="PayOrderResult">
  173. SELECT SUM(amt) as amt,sum(order_liters) as order_liters
  174. from pay_order
  175. <where>
  176. <if test="stationId != null "> and station_id = #{stationId}</if>
  177. <if test="status != null "> and status = #{status}</if>
  178. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  179. <if test="createdDate != null "> and created_date like concat(#{createdDate}, '%') </if>
  180. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  181. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  182. </if>
  183. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  184. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  185. </if>
  186. <if test="stationIdList != null ">
  187. and station_id in
  188. <foreach item="item" index="index" collection="stationIdList"
  189. open="(" separator="," close=")">
  190. #{item}
  191. </foreach>
  192. </if>
  193. </where>
  194. </select>
  195. <select id="selectOilTypeSources" parameterType="Long" resultMap="PayOrderResult">
  196. SELECT SUM(amt) as amt,sum(order_liters) as order_liters, oil_type
  197. from pay_order
  198. <where>
  199. <if test="stationId != null "> and station_id = #{stationId}</if>
  200. <if test="status != null "> and status = #{status}</if>
  201. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  202. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  203. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  204. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  205. </if>
  206. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  207. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  208. </if>
  209. <if test="stationIdList != null ">
  210. and station_id in
  211. <foreach item="item" index="index" collection="stationIdList"
  212. open="(" separator="," close=")">
  213. #{item}
  214. </foreach>
  215. </if>
  216. </where>
  217. GROUP BY oil_type
  218. </select>
  219. <select id="dayOilTypeSources" parameterType="Long" resultMap="PayOrderResult">
  220. SELECT oil_name,GROUP_CONCAT(DISTINCT oil_gun) as oil_gun,sum(order_liters) as order_liters,SUM(receivable_amt) as receivable_amt,
  221. sum(discount_amt) as discount_amt,sum(discount_coupon_amt) as discount_coupon_amt,sum(amt) as amt,
  222. sum(member_amt) as member_amt,sum(wx_amt) as wx_amt,sum(zfb_amt) as zfb_amt
  223. from pay_order
  224. <where>
  225. <if test="stationId != null "> and station_id = #{stationId}</if>
  226. <if test="status != null "> and status = #{status}</if>
  227. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  228. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  229. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  230. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  231. </if>
  232. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  233. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  234. </if>
  235. <if test="stationIdList != null ">
  236. and station_id in
  237. <foreach item="item" index="index" collection="stationIdList"
  238. open="(" separator="," close=")">
  239. #{item}
  240. </foreach>
  241. </if>
  242. </where>
  243. GROUP BY oil_name
  244. </select>
  245. <select id="selectOverViewData" parameterType="Long" resultMap="PayOrderResult">
  246. 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
  247. from pay_order
  248. <where>
  249. <if test="stationId != null "> and station_id = #{stationId}</if>
  250. <if test="status != null "> and status = #{status}</if>
  251. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  252. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  253. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  254. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  255. </if>
  256. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  257. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  258. </if>
  259. <if test="stationIdList != null ">
  260. and station_id in
  261. <foreach item="item" index="index" collection="stationIdList"
  262. open="(" separator="," close=")">
  263. #{item}
  264. </foreach>
  265. </if>
  266. </where>
  267. </select>
  268. <!--日报数据-->
  269. <select id="selectDayReport" parameterType="Long" resultMap="PayOrderResult">
  270. SELECT date_format( b.created_date, '%Y-%m-%d' ) as created_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,sum(receivable_amt) as receivable_amt,sum(received_amt) as received_amt
  271. 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
  272. from pay_order a) b
  273. <where>
  274. <if test="stationId != null "> and station_id = #{stationId}</if>
  275. <if test="status != null "> and status = #{status}</if>
  276. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  277. <if test="stationIdList != null ">
  278. and station_id in
  279. <foreach item="item" index="index" collection="stationIdList"
  280. open="(" separator="," close=")">
  281. #{item}
  282. </foreach>
  283. </if>
  284. </where>
  285. GROUP BY date_format( created_date, '%Y-%m-%d' )
  286. ORDER BY date_format( created_date, '%Y-%m-%d' ) DESC
  287. </select>
  288. <!-- 日报折线图油品数据-->
  289. <select id="listQydata" parameterType="Long" resultMap="PayOrderResult">
  290. SELECT sum(amt) as amt,date_format(created_date,'%Y-%m-%d') as created_date
  291. from pay_order
  292. <where>
  293. <if test="stationId != null "> and station_id = #{stationId}</if>
  294. <if test="status != null and status != ''"> and status = #{status}</if>
  295. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  296. <if test="oilName != null "> and oil_name = #{oilName}</if>
  297. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  298. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  299. </if>
  300. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  301. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  302. </if>
  303. <if test="stationIdList != null ">
  304. and station_id in
  305. <foreach item="item" index="index" collection="stationIdList"
  306. open="(" separator="," close=")">
  307. #{item}
  308. </foreach>
  309. </if>
  310. </where>
  311. GROUP BY oil_name ,date_format(created_date,'%Y-%m-%d')
  312. </select>
  313. <!-- 日报折线图X轴数据-->
  314. <select id="listXdata" parameterType="Long" resultMap="PayOrderResult">
  315. SELECT date_format(created_date,'%Y-%m-%d') as created_date
  316. from pay_order
  317. <where>
  318. <if test="stationId != null "> and station_id = #{stationId}</if>
  319. <if test="status != null and status != ''"> and status = #{status}</if>
  320. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  321. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  322. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  323. </if>
  324. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  325. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  326. </if>
  327. <if test="stationIdList != null ">
  328. and station_id in
  329. <foreach item="item" index="index" collection="stationIdList"
  330. open="(" separator="," close=")">
  331. #{item}
  332. </foreach>
  333. </if>
  334. </where>
  335. GROUP BY date_format(created_date,'%Y-%m-%d')
  336. </select>
  337. <!--查询数据,根据员工汇总数据-->
  338. <select id="selectPersonnelStructure" parameterType="Long" resultMap="PayOrderResult">
  339. SELECT a.oil_personnel,GROUP_CONCAT(DISTINCT a.oil_gun) as oil_gun,ROUND(SUM(a.amt),2) as amt,ROUND(SUM(order_liters),2) as order_liters,COUNT(order_no) as order_no
  340. from pay_order a
  341. <where>
  342. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  343. <if test="status != null and status != ''"> and status = #{status}</if>
  344. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  345. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  346. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  347. </if>
  348. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  349. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  350. </if>
  351. <if test="stationIdList != null ">
  352. and station_id in
  353. <foreach item="item" index="index" collection="stationIdList"
  354. open="(" separator="," close=")">
  355. #{item}
  356. </foreach>
  357. </if>
  358. </where>
  359. GROUP BY a.oil_personnel
  360. </select>
  361. <!--初始化数据班结数据,根据油品汇总 -->
  362. <select id="selectOilStructure" parameterType="Long" resultMap="PayOrderResult">
  363. SELECT a.oil_name,GROUP_CONCAT(DISTINCT oil_gun) as oil_gun,ROUND(SUM(a.amt),2) as amt,ROUND(SUM(order_liters),2) as order_liters,COUNT(order_no) as order_no
  364. from pay_order a
  365. <where>
  366. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  367. <if test="status != null and status != ''"> and status = #{status}</if>
  368. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  369. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  370. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  371. </if>
  372. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  373. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  374. </if>
  375. </where>
  376. GROUP BY a.oil_name
  377. </select>
  378. <!--初始化数据班结数据,根据员工/支付方式汇总 -->
  379. <select id="selectPersonnelPayStructure" parameterType="Long" resultMap="PayOrderResult">
  380. SELECT oil_personnel,GROUP_CONCAT(DISTINCT oil_gun) oil_gun,count(wx_amt) wx_num,count(zfb_amt) zfb_num,count(xj_amt) xj_num,sum(discount_amt) discount_amt,SUM(discount_coupon_amt) discount_coupon_amt,SUM(wx_amt) wx_amt,SUM(zfb_amt) zfb_amt,SUM(xj_amt) xj_amt,sum(member_amt) member_amt
  381. from pay_order a
  382. <where>
  383. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  384. <if test="status != null and status != ''"> and status = #{status}</if>
  385. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  386. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  387. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  388. </if>
  389. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  390. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  391. </if>
  392. </where>
  393. GROUP BY a.oil_personnel
  394. </select>
  395. <!--查询本站第一笔数据-->
  396. <select id="getPayOrderInfoMin" parameterType="Long" resultMap="PayOrderResult">
  397. SELECT * from pay_order where order_id = (
  398. SELECT min(order_id)
  399. from pay_order
  400. <where>
  401. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  402. <if test="stationId != null "> and station_id = #{stationId}</if>
  403. <if test="stationName != null and stationName != ''"> and station_name like concat('%', #{stationName}, '%')</if>
  404. <if test="status != null and status != ''"> and status = #{status}</if>
  405. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  406. </where>
  407. )
  408. </select>
  409. <insert id="insertPayOrder" parameterType="PayOrder" useGeneratedKeys="true" keyProperty="orderId">
  410. insert into pay_order
  411. <trim prefix="(" suffix=")" suffixOverrides=",">
  412. <if test="orderNo != null">order_no,</if>
  413. <if test="stationId != null">station_id,</if>
  414. <if test="stationName != null">station_name,</if>
  415. <if test="status != null">status,</if>
  416. <if test="consumerId != null">consumer_id,</if>
  417. <if test="consumer != null">consumer,</if>
  418. <if test="oilGun != null">oil_gun,</if>
  419. <if test="oilName != null">oil_name,</if>
  420. <if test="oilPirce != null">oil_pirce,</if>
  421. <if test="oilType != null">oil_type,</if>
  422. <if test="orderLiters != null">order_liters,</if>
  423. <if test="amt != null">amt,</if>
  424. <if test="receivableAmt != null">receivable_amt,</if>
  425. <if test="receivedAmt != null">received_amt,</if>
  426. <if test="discountAmt != null">discount_amt,</if>
  427. <if test="discountCouponAmt != null">discount_coupon_amt,</if>
  428. <if test="discountCoupon != null">discount_coupon,</if>
  429. <if test="wxAmt != null">wx_amt,</if>
  430. <if test="zfbAmt != null">zfb_amt,</if>
  431. <if test="posAmt != null">pos_amt,</if>
  432. <if test="xjAmt != null">xj_amt,</if>
  433. <if test="didiAppAmt != null">didi_app_amt,</if>
  434. <if test="tyAppAmt != null">ty_app_amt,</if>
  435. <if test="otherAmt != null">other_amt,</if>
  436. <if test="dzkAmt != null">dzk_amt,</if>
  437. <if test="score != null">score,</if>
  438. <if test="memberNo != null">member_no,</if>
  439. <if test="memberAmt != null">member_amt,</if>
  440. <if test="printCount != null">print_count,</if>
  441. <if test="payType != null">pay_type,</if>
  442. <if test="payWay != null">pay_way,</if>
  443. <if test="oilPersonnel != null">oil_personnel,</if>
  444. <if test="payDate != null">pay_date,</if>
  445. <if test="createdDate != null">created_date,</if>
  446. <if test="orderType != null">order_type,</if>
  447. <if test="carNo != null">car_no,</if>
  448. <if test="customerPhone != null">customer_phone,</if>
  449. <if test="customerGrade != null">customer_grade,</if>
  450. </trim>
  451. <trim prefix="values (" suffix=")" suffixOverrides=",">
  452. <if test="orderNo != null">#{orderNo},</if>
  453. <if test="stationId != null">#{stationId},</if>
  454. <if test="stationName != null">#{stationName},</if>
  455. <if test="status != null">#{status},</if>
  456. <if test="consumerId != null">#{consumerId},</if>
  457. <if test="consumer != null">#{consumer},</if>
  458. <if test="oilGun != null">#{oilGun},</if>
  459. <if test="oilName != null">#{oilName},</if>
  460. <if test="oilPirce != null">#{oilPirce},</if>
  461. <if test="oilType != null">#{oilType},</if>
  462. <if test="orderLiters != null">#{orderLiters},</if>
  463. <if test="amt != null">#{amt},</if>
  464. <if test="receivableAmt != null">#{receivableAmt},</if>
  465. <if test="receivedAmt != null">#{receivedAmt},</if>
  466. <if test="discountAmt != null">#{discountAmt},</if>
  467. <if test="discountCouponAmt != null">#{discountCouponAmt},</if>
  468. <if test="discountCoupon != null">#{discountCoupon},</if>
  469. <if test="wxAmt != null">#{wxAmt},</if>
  470. <if test="zfbAmt != null">#{zfbAmt},</if>
  471. <if test="posAmt != null">#{posAmt},</if>
  472. <if test="xjAmt != null">#{xjAmt},</if>
  473. <if test="didiAppAmt != null">#{didiAppAmt},</if>
  474. <if test="tyAppAmt != null">#{tyAppAmt},</if>
  475. <if test="otherAmt != null">#{otherAmt},</if>
  476. <if test="dzkAmt != null">#{dzkAmt},</if>
  477. <if test="score != null">#{score},</if>
  478. <if test="memberNo != null">#{memberNo},</if>
  479. <if test="memberAmt != null">#{memberAmt},</if>
  480. <if test="printCount != null">#{printCount},</if>
  481. <if test="payType != null">#{payType},</if>
  482. <if test="payWay != null">#{payWay},</if>
  483. <if test="oilPersonnel != null">#{oilPersonnel},</if>
  484. <if test="payDate != null">#{payDate},</if>
  485. <if test="createdDate != null">#{createdDate},</if>
  486. <if test="orderType != null">#{orderType},</if>
  487. <if test="carNo != null">#{carNo},</if>
  488. <if test="customerPhone != null">#{customerPhone},</if>
  489. <if test="customerGrade != null">#{customerGrade},</if>
  490. </trim>
  491. </insert>
  492. <update id="updatePayOrder" parameterType="PayOrder">
  493. update pay_order
  494. <trim prefix="SET" suffixOverrides=",">
  495. <if test="orderNo != null">order_no = #{orderNo},</if>
  496. <if test="stationId != null">station_id = #{stationId},</if>
  497. <if test="stationName != null">station_name = #{stationName},</if>
  498. <if test="status != null">status = #{status},</if>
  499. <if test="consumerId != null">consumer_id = #{consumerId},</if>
  500. <if test="consumer != null">consumer = #{consumer},</if>
  501. <if test="oilGun != null">oil_gun = #{oilGun},</if>
  502. <if test="oilName != null">oil_name = #{oilName},</if>
  503. <if test="oilPirce != null">oil_pirce = #{oilPirce},</if>
  504. <if test="oilType != null">oil_type = #{oilType},</if>
  505. <if test="orderLiters != null">order_liters = #{orderLiters},</if>
  506. <if test="amt != null">amt = #{amt},</if>
  507. <if test="receivableAmt != null">receivable_amt = #{receivableAmt},</if>
  508. <if test="receivedAmt != null">received_amt = #{receivedAmt},</if>
  509. <if test="discountAmt != null">discount_amt = #{discountAmt},</if>
  510. <if test="discountCouponAmt != null">discount_coupon_amt = #{discountCouponAmt},</if>
  511. <if test="discountCoupon != null">discount_coupon = #{discountCoupon},</if>
  512. <if test="wxAmt != null">wx_amt = #{wxAmt},</if>
  513. <if test="zfbAmt != null">zfb_amt = #{zfbAmt},</if>
  514. <if test="posAmt != null">pos_amt = #{posAmt},</if>
  515. <if test="xjAmt != null">xj_amt = #{xjAmt},</if>
  516. <if test="didiAppAmt != null">didi_app_amt = #{didiAppAmt},</if>
  517. <if test="tyAppAmt != null">ty_app_amt = #{tyAppAmt},</if>
  518. <if test="otherAmt != null">other_amt = #{otherAmt},</if>
  519. <if test="dzkAmt != null">dzk_amt = #{dzkAmt},</if>
  520. <if test="score != null">score = #{score},</if>
  521. <if test="memberNo != null">member_no = #{memberNo},</if>
  522. <if test="memberAmt != null">member_amt = #{memberAmt},</if>
  523. <if test="printCount != null">print_count = #{printCount},</if>
  524. <if test="payType != null">pay_type = #{payType},</if>
  525. <if test="payWay != null">pay_way = #{payWay},</if>
  526. <if test="oilPersonnel != null">oil_personnel = #{oilPersonnel},</if>
  527. <if test="payDate != null">pay_date = #{payDate},</if>
  528. <if test="createdDate != null">created_date = #{createdDate},</if>
  529. <if test="orderType != null">order_type = #{orderType},</if>
  530. <if test="carNo != null">car_no = #{carNo},</if>
  531. <if test="customerPhone != null">customer_phone = #{customerPhone},</if>
  532. <if test="customerGrade != null">customer_grade = #{customerGrade},</if>
  533. </trim>
  534. where order_id = #{orderId}
  535. </update>
  536. <delete id="deletePayOrderById" parameterType="Long">
  537. delete from pay_order where order_id = #{orderId}
  538. </delete>
  539. <delete id="deletePayOrderByIds" parameterType="String">
  540. delete from pay_order where order_id in
  541. <foreach item="orderId" collection="array" open="(" separator="," close=")">
  542. #{orderId}
  543. </foreach>
  544. </delete>
  545. </mapper>