PayOrderMapper.xml 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  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="oilPersonnelId" column="oil_personnel_id" />
  41. <result property="payDate" column="pay_date" />
  42. <result property="createdDate" column="created_date" />
  43. <result property="orderType" column="order_type" />
  44. <result property="carNo" column="car_no" />
  45. <result property="customerPhone" column="customer_phone" />
  46. <result property="customerGrade" column="customer_grade" />
  47. <result property="wxNum" column="wx_num" />
  48. <result property="zfbNum" column="zfb_num" />
  49. <result property="xjNum" column="xj_num" />
  50. <result property="qyAmt" column="qy_amt" />
  51. <result property="cyAmt" column="cy_amt" />
  52. <result property="sellAmt" column="sell_amt" />
  53. <result property="sellDiscountAmt" column="sell_discount_amt" />
  54. <result property="mobilePhone" column="mobile_phone" />
  55. <result property="sellOilPrice" column="sell_oil_price" />
  56. <result property="driverOilPrice" column="driver_oil_price" />
  57. <result property="countNum" column="count_num" />
  58. <result property="driverDiscountAmt" column="driver_discount_amt" />
  59. </resultMap>
  60. <sql id="selectPayOrderVo">
  61. select order_id, order_no, station_id,d.dept_name as station_name, p.status,consumer_id, consumer, oil_gun,
  62. oil_name, oil_pirce, oil_type, order_liters, amt, receivable_amt, received_amt, discount_amt,sell_oil_price,driver_oil_price,oil_personnel_id,
  63. discount_coupon_amt, discount_coupon, wx_amt, zfb_amt, pos_amt, xj_amt, didi_app_amt, ty_app_amt,
  64. other_amt, dzk_amt, score, member_no, member_amt, print_count, pay_type, pay_way, oil_personnel,
  65. pay_date, created_date, order_type, car_no, customer_phone, customer_grade,sell_amt,sell_discount_amt,driver_discount_amt
  66. from pay_order p join sys_dept d on p.station_id =d.dept_id
  67. </sql>
  68. <select id="selectPayOrderList" parameterType="PayOrder" resultMap="PayOrderResult">
  69. <include refid="selectPayOrderVo"/>
  70. <where>
  71. <if test="orderNo != null and orderNo != ''"> and order_no like concat('%', #{orderNo}, '%')</if>
  72. <if test="stationId != null "> and station_id = #{stationId}</if>
  73. <if test="status != null and status != ''"> and p.status = #{status}</if>
  74. <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
  75. <if test="consumer != null and consumer != ''"> and consumer like concat('%', #{consumer}, '%')</if>
  76. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  77. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  78. <if test="oilPirce != null "> and oil_pirce = #{oilPirce}</if>
  79. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  80. <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
  81. <if test="amt != null "> and amt = #{amt}</if>
  82. <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
  83. <if test="receivedAmt != null "> and received_amt = #{receivedAmt}</if>
  84. <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
  85. <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
  86. <if test="discountCoupon != null and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
  87. <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
  88. <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
  89. <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
  90. <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
  91. <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
  92. <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
  93. <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
  94. <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
  95. <if test="score != null "> and score = #{score}</if>
  96. <if test="memberNo != null and memberNo != ''"> and member_no = #{memberNo}</if>
  97. <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
  98. <if test="printCount != null "> and print_count = #{printCount}</if>
  99. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  100. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  101. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  102. <if test="oilPersonnelId != null and oilPersonnelId != ''"> and oil_personnel_id = #{oilPersonnelId}</if>
  103. <if test="payDate != null "> and pay_date = #{payDate}</if>
  104. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  105. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  106. <if test="carNo != null and carNo != ''"> and car_no = #{carNo}</if>
  107. <if test="customerPhone != null and customerPhone != ''"> and customer_phone = #{customerPhone}</if>
  108. <if test="customerGrade != null and customerGrade != ''"> and customer_grade = #{customerGrade}</if>
  109. <if test="likeConsumer != null and likeConsumer != ''"> and consumer like concat('%',#{likeConsumer}, '%')</if>
  110. <if test="likeCarNo != null and likeCarNo != ''"> and car_no like concat('%',#{likeCarNo}, '%') </if>
  111. <if test="likeCustomerPhone != null and likeCustomerPhone != ''"> and customer_phone like concat('%',#{likeCustomerPhone}, '%') </if>
  112. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  113. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  114. </if>
  115. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  116. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  117. </if>
  118. <if test="stationIdList != null ">
  119. and station_id in
  120. <foreach item="item" index="index" collection="stationIdList"
  121. open="(" separator="," close=")">
  122. #{item}
  123. </foreach>
  124. </if>
  125. </where>
  126. order by order_id desc
  127. </select>
  128. <!--查询导出数据-->
  129. <select id="selectPayOrderExport" parameterType="PayOrder" resultMap="PayOrderResult">
  130. select order_no,oil_name,oil_pirce,order_liters, amt,consumer,oil_personnel,oil_gun,pay_type,pay_way,sell_oil_price,driver_oil_price
  131. from pay_order
  132. <where>
  133. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  134. <if test="stationId != null "> and station_id = #{stationId}</if>
  135. <if test="status != null and status != ''"> and status = #{status}</if>
  136. <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
  137. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  138. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  139. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  140. <if test="oilPirce != null "> and oil_pirce = #{oilPirce}</if>
  141. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  142. <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
  143. <if test="amt != null "> and amt = #{amt}</if>
  144. <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
  145. <if test="receivedAmt != null "> and received_amt = #{receivedAmt}</if>
  146. <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
  147. <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
  148. <if test="discountCoupon != null and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
  149. <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
  150. <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
  151. <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
  152. <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
  153. <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
  154. <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
  155. <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
  156. <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
  157. <if test="score != null "> and score = #{score}</if>
  158. <if test="memberNo != null and memberNo != ''"> and member_no = #{memberNo}</if>
  159. <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
  160. <if test="printCount != null "> and print_count = #{printCount}</if>
  161. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  162. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  163. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  164. <if test="payDate != null "> and pay_date = #{payDate}</if>
  165. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  166. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  167. <if test="carNo != null and carNo != ''"> and car_no = #{carNo}</if>
  168. <if test="customerPhone != null and customerPhone != ''"> and customer_phone like concat('%',#{customerPhone}, '%') </if>
  169. <if test="customerGrade != null and customerGrade != ''"> and customer_grade like concat('%',#{customerGrade}, '%') </if>
  170. <if test="stationIdList != null ">
  171. and station_id in
  172. <foreach item="item" index="index" collection="stationIdList"
  173. open="(" separator="," close=")">
  174. #{item}
  175. </foreach>
  176. </if>
  177. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  178. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  179. </if>
  180. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  181. AND date_format(created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  182. </if>
  183. </where>
  184. order by order_id desc
  185. </select>
  186. <!--用戶信息关联订单查询-->
  187. <select id="selectUserPayOrderList" parameterType="PayOrder" resultMap="PayOrderResult">
  188. SELECT order_id,dept_name as station_name,oil_name,order_no,p.oil_pirce,order_liters,receivable_amt,amt,sell_amt,sell_discount_amt,amt,discount_amt,pay_date,mobile_phone as customer_phone,sell_oil_price,driver_oil_price,driver_discount_amt
  189. from pay_order p
  190. left join sys_dept d on d.dept_id =p.station_id
  191. join app_user_info a on a.user_id=p.consumer_id
  192. <where>
  193. <if test="orderNo != null and orderNo != ''"> and p.order_no = #{orderNo}</if>
  194. <if test="stationId != null "> and p.station_id = #{stationId}</if>
  195. <if test="status != null and status != ''"> and p.status = #{status}</if>
  196. <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
  197. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  198. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  199. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  200. <if test="oilPirce != null "> and oil_pirce = #{oilPirce}</if>
  201. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  202. <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
  203. <if test="amt != null "> and amt = #{amt}</if>
  204. <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
  205. <if test="receivedAmt != null "> and received_amt = #{receivedAmt}</if>
  206. <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
  207. <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
  208. <if test="discountCoupon != null and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
  209. <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
  210. <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
  211. <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
  212. <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
  213. <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
  214. <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
  215. <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
  216. <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
  217. <if test="score != null "> and score = #{score}</if>
  218. <if test="oilPersonnelId != null and oilPersonnelId != ''"> and oil_personnel_id = #{oilPersonnelId}</if>
  219. <if test="memberNo != null and memberNo != ''"> and member_no = #{memberNo}</if>
  220. <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
  221. <if test="printCount != null "> and print_count = #{printCount}</if>
  222. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  223. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  224. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  225. <if test="payDate != null "> and pay_date = #{payDate}</if>
  226. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  227. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  228. <if test="carNo != null and carNo != ''"> and car_no = #{carNo}</if>
  229. <if test="customerPhone != null and customerPhone != ''"> and mobile_phone like concat('%',#{customerPhone}, '%') </if>
  230. <if test="customerGrade != null and customerGrade != ''"> and customer_grade like concat('%',#{customerGrade}, '%') </if>
  231. <if test="stationIdList != null ">
  232. and p.station_id in
  233. <foreach item="item" index="index" collection="stationIdList"
  234. open="(" separator="," close=")">
  235. #{item}
  236. </foreach>
  237. </if>
  238. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  239. AND date_format(p.created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  240. </if>
  241. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  242. AND date_format(p.created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  243. </if>
  244. </where>
  245. order by order_id desc
  246. </select>
  247. <!--查询LNG导出数据-->
  248. <select id="selectLNGPayOrderExport" parameterType="PayOrder" resultMap="PayOrderResult">
  249. SELECT order_id,dept_name as station_name,oil_name,order_no,p.oil_pirce,order_liters,receivable_amt,amt,sell_amt,sell_discount_amt,discount_amt,pay_date,mobile_phone,sell_oil_price,driver_oil_price,driver_discount_amt,p.status
  250. from pay_order p
  251. left join sys_dept d on d.dept_id =p.station_id
  252. join app_user_info a on a.user_id=p.consumer_id
  253. <where>
  254. <if test="orderNo != null and orderNo != ''"> and p.order_no = #{orderNo}</if>
  255. <if test="stationId != null "> and p.station_id = #{stationId}</if>
  256. <if test="status != null and status != ''"> and (p.status = #{status} or p.status=2)</if>
  257. <if test="consumerId != null "> and consumer_id = #{consumerId}</if>
  258. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  259. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  260. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  261. <if test="oilPirce != null "> and oil_pirce = #{oilPirce}</if>
  262. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  263. <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
  264. <if test="amt != null "> and amt = #{amt}</if>
  265. <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
  266. <if test="receivedAmt != null "> and received_amt = #{receivedAmt}</if>
  267. <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
  268. <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
  269. <if test="discountCoupon != null and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
  270. <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
  271. <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
  272. <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
  273. <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
  274. <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
  275. <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
  276. <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
  277. <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
  278. <if test="score != null "> and score = #{score}</if>
  279. <if test="oilPersonnelId != null and oilPersonnelId != ''"> and oil_personnel_id = #{oilPersonnelId}</if>
  280. <if test="memberNo != null and memberNo != ''"> and member_no = #{memberNo}</if>
  281. <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
  282. <if test="printCount != null "> and print_count = #{printCount}</if>
  283. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  284. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  285. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  286. <if test="payDate != null "> and pay_date = #{payDate}</if>
  287. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  288. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  289. <if test="carNo != null and carNo != ''"> and car_no = #{carNo}</if>
  290. <if test="customerPhone != null and customerPhone != ''"> and mobile_phone like concat('%',#{customerPhone}, '%') </if>
  291. <if test="customerGrade != null and customerGrade != ''"> and customer_grade like concat('%',#{customerGrade}, '%') </if>
  292. <if test="stationIdList != null ">
  293. and p.station_id in
  294. <foreach item="item" index="index" collection="stationIdList"
  295. open="(" separator="," close=")">
  296. #{item}
  297. </foreach>
  298. </if>
  299. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  300. AND date_format(p.created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  301. </if>
  302. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  303. AND date_format(p.created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  304. </if>
  305. </where>
  306. order by order_id desc
  307. </select>
  308. <select id="LNGDeptList" parameterType="PayOrder" resultMap="PayOrderResult">
  309. SELECT dept_name as station_name,order_id,order_no,oil_name,p.oil_pirce,sell_oil_price,order_liters,receivable_amt,sell_amt,sell_discount_amt,pay_date,driver_discount_amt,
  310. concat(LEFT (mobile_phone, 3), '****', RIGHT (mobile_phone, 4)) mobile_phone,p.status
  311. from pay_order p
  312. left join sys_dept d on d.dept_id =p.station_id
  313. join app_user_info a on a.user_id=p.consumer_id
  314. <where>
  315. <if test="orderNo != null and orderNo != ''"> and p.order_no = #{orderNo}</if>
  316. <if test="stationId != null "> and p.station_id = #{stationId}</if>
  317. <if test="status != null and status != ''"> and (p.status = #{status} or p.status=2)</if>
  318. <if test="consumerId != null "> and p.consumer_id = #{consumerId}</if>
  319. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  320. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  321. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  322. <if test="oilPirce != null "> and oil_pirce = #{oilPirce}</if>
  323. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  324. <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
  325. <if test="amt != null "> and amt = #{amt}</if>
  326. <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
  327. <if test="receivedAmt != null "> and received_amt = #{receivedAmt}</if>
  328. <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
  329. <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
  330. <if test="discountCoupon != null and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
  331. <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
  332. <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
  333. <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
  334. <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
  335. <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
  336. <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
  337. <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
  338. <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
  339. <if test="score != null "> and score = #{score}</if>
  340. <if test="memberNo != null and memberNo != ''"> and member_no = #{memberNo}</if>
  341. <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
  342. <if test="printCount != null "> and print_count = #{printCount}</if>
  343. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  344. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  345. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  346. <if test="payDate != null "> and pay_date = #{payDate}</if>
  347. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  348. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  349. <if test="carNo != null and carNo != ''"> and car_no = #{carNo}</if>
  350. <if test="customerPhone != null and customerPhone != ''"> and customer_phone like concat('%',#{customerPhone}, '%') </if>
  351. <if test="customerGrade != null and customerGrade != ''"> and customer_grade like concat('%',#{customerGrade}, '%') </if>
  352. <if test="stationIdList != null ">
  353. and p.station_id in
  354. <foreach item="item" index="index" collection="stationIdList"
  355. open="(" separator="," close=")">
  356. #{item}
  357. </foreach>
  358. </if>
  359. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  360. AND date_format(p.created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  361. </if>
  362. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  363. AND date_format(p.created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  364. </if>
  365. </where>
  366. order by order_id desc
  367. </select>
  368. <select id="LNGDeptListAll" parameterType="PayOrder" resultMap="PayOrderResult">
  369. SELECT dept_name as station_name,order_id,order_no,oil_name,p.oil_pirce,sell_oil_price,order_liters,receivable_amt,sell_amt,sell_discount_amt,pay_date,driver_discount_amt,
  370. concat(LEFT (mobile_phone, 3), '****', RIGHT (mobile_phone, 4)) mobile_phone,p.status
  371. from pay_order p
  372. left join sys_dept d on d.dept_id =p.station_id
  373. join app_user_info a on a.user_id=p.consumer_id
  374. <where>
  375. <if test="orderNo != null and orderNo != ''"> and p.order_no = #{orderNo}</if>
  376. <if test="stationId != null "> and p.station_id = #{stationId}</if>
  377. <if test="status != null and status != ''"> and p.status = #{status}</if>
  378. <if test="consumerId != null "> and p.consumer_id = #{consumerId}</if>
  379. <if test="consumer != null and consumer != ''"> and consumer = #{consumer}</if>
  380. <if test="oilGun != null and oilGun != ''"> and oil_gun = #{oilGun}</if>
  381. <if test="oilName != null and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if>
  382. <if test="oilPirce != null "> and oil_pirce = #{oilPirce}</if>
  383. <if test="oilType != null and oilType != ''"> and oil_type = #{oilType}</if>
  384. <if test="orderLiters != null "> and order_liters = #{orderLiters}</if>
  385. <if test="amt != null "> and amt = #{amt}</if>
  386. <if test="receivableAmt != null "> and receivable_amt = #{receivableAmt}</if>
  387. <if test="receivedAmt != null "> and received_amt = #{receivedAmt}</if>
  388. <if test="discountAmt != null "> and discount_amt = #{discountAmt}</if>
  389. <if test="discountCouponAmt != null "> and discount_coupon_amt = #{discountCouponAmt}</if>
  390. <if test="discountCoupon != null and discountCoupon != ''"> and discount_coupon = #{discountCoupon}</if>
  391. <if test="wxAmt != null "> and wx_amt = #{wxAmt}</if>
  392. <if test="zfbAmt != null "> and zfb_amt = #{zfbAmt}</if>
  393. <if test="posAmt != null "> and pos_amt = #{posAmt}</if>
  394. <if test="xjAmt != null "> and xj_amt = #{xjAmt}</if>
  395. <if test="didiAppAmt != null "> and didi_app_amt = #{didiAppAmt}</if>
  396. <if test="tyAppAmt != null "> and ty_app_amt = #{tyAppAmt}</if>
  397. <if test="otherAmt != null "> and other_amt = #{otherAmt}</if>
  398. <if test="dzkAmt != null "> and dzk_amt = #{dzkAmt}</if>
  399. <if test="score != null "> and score = #{score}</if>
  400. <if test="memberNo != null and memberNo != ''"> and member_no = #{memberNo}</if>
  401. <if test="memberAmt != null "> and member_amt = #{memberAmt}</if>
  402. <if test="printCount != null "> and print_count = #{printCount}</if>
  403. <if test="payType != null and payType != ''"> and pay_type = #{payType}</if>
  404. <if test="payWay != null and payWay != ''"> and pay_way = #{payWay}</if>
  405. <if test="oilPersonnel != null and oilPersonnel != ''"> and oil_personnel = #{oilPersonnel}</if>
  406. <if test="payDate != null "> and pay_date = #{payDate}</if>
  407. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  408. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  409. <if test="carNo != null and carNo != ''"> and car_no = #{carNo}</if>
  410. <if test="customerPhone != null and customerPhone != ''"> and customer_phone like concat('%',#{customerPhone}, '%') </if>
  411. <if test="customerGrade != null and customerGrade != ''"> and customer_grade like concat('%',#{customerGrade}, '%') </if>
  412. <if test="stationIdList != null ">
  413. and p.station_id in
  414. <foreach item="item" index="index" collection="stationIdList"
  415. open="(" separator="," close=")">
  416. #{item}
  417. </foreach>
  418. </if>
  419. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  420. AND date_format(p.created_date,'%y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%y-%m-%d %H:%i:%s')
  421. </if>
  422. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  423. AND date_format(p.created_date,'%y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%y-%m-%d %H:%i:%s')
  424. </if>
  425. </where>
  426. order by order_id desc
  427. </select>
  428. <select id="selectPayOrderById" parameterType="Long" resultMap="PayOrderResult">
  429. select order_id, order_no, p.station_id, p.station_name, p.status,consumer_id, consumer, oil_gun,
  430. oil_name, oil_pirce, oil_type, order_liters, amt, receivable_amt, received_amt, discount_amt,sell_oil_price,driver_oil_price,
  431. discount_coupon_amt, discount_coupon, wx_amt, zfb_amt, pos_amt, xj_amt, didi_app_amt, ty_app_amt,
  432. other_amt, dzk_amt, score, member_no, member_amt, print_count, pay_type, pay_way, oil_personnel,oil_personnel_id,
  433. pay_date, created_date, order_type, car_no,customer_grade,sell_amt,sell_discount_amt,d.mobile_phone as customer_phone
  434. from pay_order p join app_user_info d on p.consumer_id =d.user_id
  435. where order_id = #{orderId}
  436. </select>
  437. <select id="selectDaySources" parameterType="PayOrder" resultMap="PayOrderResult">
  438. SELECT SUM(amt) as amt,sum(order_liters) as order_liters,sum(sell_amt) as sell_amt,count(1) count_num
  439. from pay_order
  440. <where>
  441. <if test="stationId != null "> and station_id = #{stationId}</if>
  442. <if test="status != null "> and status = #{status}</if>
  443. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  444. <if test="createdDate != null "> and created_date like concat(#{createdDate}, '%') </if>
  445. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  446. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  447. </if>
  448. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  449. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  450. </if>
  451. <if test="stationIdList != null ">
  452. and station_id in
  453. <foreach item="item" index="index" collection="stationIdList"
  454. open="(" separator="," close=")">
  455. #{item}
  456. </foreach>
  457. </if>
  458. </where>
  459. </select>
  460. <select id="selectAllDaySources" parameterType="PayOrder" resultMap="PayOrderResult">
  461. SELECT SUM(amt) as amt,sum(order_liters) as order_liters,sum(sell_amt) as sell_amt,count(1) count_num
  462. from pay_order
  463. <where>
  464. <if test="stationId != null "> and station_id = #{stationId}</if>
  465. <if test="status != null "> and (status = #{status} or status=2)</if>
  466. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  467. <if test="createdDate != null "> and created_date like concat(#{createdDate}, '%') </if>
  468. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  469. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  470. </if>
  471. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  472. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  473. </if>
  474. <if test="stationIdList != null ">
  475. and station_id in
  476. <foreach item="item" index="index" collection="stationIdList"
  477. open="(" separator="," close=")">
  478. #{item}
  479. </foreach>
  480. </if>
  481. </where>
  482. </select>
  483. <select id="selectOilTypeSources" parameterType="Long" resultMap="PayOrderResult">
  484. SELECT SUM(amt) as amt,sum(order_liters) as order_liters,sum(sell_amt) sell_amt, oil_type,count(1) count_num
  485. from pay_order
  486. <where>
  487. <if test="stationId != null "> and station_id = #{stationId}</if>
  488. <if test="status != null "> and status = #{status}</if>
  489. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  490. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  491. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  492. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  493. </if>
  494. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  495. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  496. </if>
  497. <if test="stationIdList != null ">
  498. and station_id in
  499. <foreach item="item" index="index" collection="stationIdList"
  500. open="(" separator="," close=")">
  501. #{item}
  502. </foreach>
  503. </if>
  504. </where>
  505. GROUP BY oil_type
  506. </select>
  507. <select id="selectAllOilTypeSources" parameterType="Long" resultMap="PayOrderResult">
  508. SELECT SUM(amt) as amt,sum(order_liters) as order_liters,sum(sell_amt) sell_amt, oil_type,count(1) count_num
  509. from pay_order
  510. <where>
  511. <if test="stationId != null "> and station_id = #{stationId}</if>
  512. <if test="status != null "> and (status = #{status} or status=2)</if>
  513. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  514. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  515. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  516. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  517. </if>
  518. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  519. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  520. </if>
  521. <if test="stationIdList != null ">
  522. and station_id in
  523. <foreach item="item" index="index" collection="stationIdList"
  524. open="(" separator="," close=")">
  525. #{item}
  526. </foreach>
  527. </if>
  528. </where>
  529. GROUP BY oil_type
  530. </select>
  531. <select id="dayOilTypeSources" parameterType="Long" resultMap="PayOrderResult">
  532. SELECT oil_name,GROUP_CONCAT(DISTINCT oil_gun) as oil_gun,sum(order_liters) as order_liters,SUM(receivable_amt) as receivable_amt,
  533. sum(discount_amt) as discount_amt,sum(discount_coupon_amt) as discount_coupon_amt,sum(amt) as amt,
  534. sum(member_amt) as member_amt,sum(wx_amt) as wx_amt,sum(zfb_amt) as zfb_amt
  535. from pay_order
  536. <where>
  537. <if test="stationId != null "> and station_id = #{stationId}</if>
  538. <if test="status != null "> and status = #{status}</if>
  539. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  540. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  541. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  542. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  543. </if>
  544. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  545. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  546. </if>
  547. <if test="stationIdList != null ">
  548. and station_id in
  549. <foreach item="item" index="index" collection="stationIdList"
  550. open="(" separator="," close=")">
  551. #{item}
  552. </foreach>
  553. </if>
  554. </where>
  555. GROUP BY oil_name
  556. </select>
  557. <select id="dayAllOilTypeSources" parameterType="Long" resultMap="PayOrderResult">
  558. SELECT oil_name,GROUP_CONCAT(DISTINCT oil_gun) as oil_gun,sum(order_liters) as order_liters,SUM(receivable_amt) as receivable_amt,
  559. sum(discount_amt) as discount_amt,sum(discount_coupon_amt) as discount_coupon_amt,sum(amt) as amt,
  560. sum(member_amt) as member_amt,sum(wx_amt) as wx_amt,sum(zfb_amt) as zfb_amt
  561. from pay_order
  562. <where>
  563. <if test="stationId != null "> and station_id = #{stationId}</if>
  564. <if test="status != null "> and (status = #{status} or status=2)</if>
  565. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  566. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  567. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  568. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  569. </if>
  570. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  571. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  572. </if>
  573. <if test="stationIdList != null ">
  574. and station_id in
  575. <foreach item="item" index="index" collection="stationIdList"
  576. open="(" separator="," close=")">
  577. #{item}
  578. </foreach>
  579. </if>
  580. </where>
  581. GROUP BY oil_name
  582. </select>
  583. <select id="selectOverViewData" parameterType="Long" resultMap="PayOrderResult">
  584. SELECT SUM(wx_amt) as wx_amt,sum(zfb_amt) as zfb_amt, sum(dzk_amt) as dzk_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
  585. from pay_order
  586. <where>
  587. <if test="stationId != null "> and station_id = #{stationId}</if>
  588. <if test="status != null "> and status = #{status}</if>
  589. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  590. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  591. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  592. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  593. </if>
  594. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  595. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  596. </if>
  597. <if test="stationIdList != null ">
  598. and station_id in
  599. <foreach item="item" index="index" collection="stationIdList"
  600. open="(" separator="," close=")">
  601. #{item}
  602. </foreach>
  603. </if>
  604. </where>
  605. </select>
  606. <select id="selectAllOverViewData" parameterType="Long" resultMap="PayOrderResult">
  607. SELECT SUM(wx_amt) as wx_amt,sum(zfb_amt) as zfb_amt, sum(dzk_amt) as dzk_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
  608. from pay_order
  609. <where>
  610. <if test="stationId != null "> and station_id = #{stationId}</if>
  611. <if test="status != null "> and (status = #{status} or status=2)</if>
  612. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  613. <if test="createdDate != null "> and created_date = #{createdDate}</if>
  614. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  615. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  616. </if>
  617. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  618. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  619. </if>
  620. <if test="stationIdList != null ">
  621. and station_id in
  622. <foreach item="item" index="index" collection="stationIdList"
  623. open="(" separator="," close=")">
  624. #{item}
  625. </foreach>
  626. </if>
  627. </where>
  628. </select>
  629. <!--日报数据-->
  630. <select id="selectDayReport" parameterType="Long" resultMap="PayOrderResult">
  631. SELECT
  632. b.created_date,
  633. sum( b.amt ) amt,
  634. sum( b.order_liters ) order_liters,
  635. sum( b.member_amt ) member_amt,
  636. sum( b.receivable_amt ) receivable_amt,
  637. sum( b.received_amt ) received_amt,
  638. MAX(CASE b.oil_type WHEN '1' THEN amt ELSE 0 END) AS qy_amt,
  639. MAX(CASE b.oil_type WHEN '2' THEN amt ELSE 0 END) AS cy_amt,
  640. sum(b.order_no) order_no
  641. from (
  642. SELECT
  643. date_format( a.created_date, '%Y-%m-%d' ) as created_date,
  644. sum( a.amt ) amt,
  645. sum( a.order_liters ) order_liters,
  646. sum( a.member_amt ) member_amt,
  647. sum( a.receivable_amt ) receivable_amt,
  648. sum( a.received_amt ) received_amt,
  649. a.oil_type,
  650. count( 1 ) order_no
  651. FROM
  652. pay_order a
  653. <where>
  654. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  655. <if test="status != null "> and a.status = #{status}</if>
  656. <if test="orderType != null and orderType != ''"> and a.order_type = #{orderType}</if>
  657. <if test="stationIdList != null ">
  658. and a.station_id in
  659. <foreach item="item" index="index" collection="stationIdList"
  660. open="(" separator="," close=")">
  661. #{item}
  662. </foreach>
  663. </if>
  664. </where>
  665. GROUP BY
  666. date_format( a.created_date, '%Y-%m-%d' ),a.oil_type
  667. ) b
  668. GROUP BY b.created_date
  669. ORDER BY b.created_date desc
  670. </select>
  671. <!--日报数据-->
  672. <select id="selectAllDayReport" parameterType="Long" resultMap="PayOrderResult">
  673. SELECT
  674. b.created_date,
  675. sum( b.amt ) amt,
  676. sum( b.order_liters ) order_liters,
  677. sum( b.member_amt ) member_amt,
  678. sum( b.receivable_amt ) receivable_amt,
  679. sum( b.received_amt ) received_amt,
  680. MAX(CASE b.oil_type WHEN '1' THEN amt ELSE 0 END) AS qy_amt,
  681. MAX(CASE b.oil_type WHEN '2' THEN amt ELSE 0 END) AS cy_amt,
  682. sum(b.order_no) order_no
  683. from (
  684. SELECT
  685. date_format( a.created_date, '%Y-%m-%d' ) as created_date,
  686. sum( a.amt ) amt,
  687. sum( a.order_liters ) order_liters,
  688. sum( a.member_amt ) member_amt,
  689. sum( a.receivable_amt ) receivable_amt,
  690. sum( a.received_amt ) received_amt,
  691. a.oil_type,
  692. count( 1 ) order_no
  693. FROM
  694. pay_order a
  695. <where>
  696. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  697. <if test="status != null "> and (a.status = #{status} or a.status=2)</if>
  698. <if test="orderType != null and orderType != ''"> and a.order_type = #{orderType}</if>
  699. <if test="stationIdList != null ">
  700. and a.station_id in
  701. <foreach item="item" index="index" collection="stationIdList"
  702. open="(" separator="," close=")">
  703. #{item}
  704. </foreach>
  705. </if>
  706. </where>
  707. GROUP BY
  708. date_format( a.created_date, '%Y-%m-%d' ),a.oil_type
  709. ) b
  710. GROUP BY b.created_date
  711. ORDER BY b.created_date desc
  712. </select>
  713. <!-- 日报折线图油品数据-->
  714. <select id="listQydata" parameterType="Long" resultMap="PayOrderResult">
  715. SELECT sum(amt) as amt,date_format(created_date,'%Y-%m-%d') as created_date
  716. from pay_order
  717. <where>
  718. <if test="stationId != null "> and station_id = #{stationId}</if>
  719. <if test="status != null and status != ''"> and status = #{status}</if>
  720. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  721. <if test="oilName != null "> and oil_name = #{oilName}</if>
  722. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  723. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  724. </if>
  725. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  726. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  727. </if>
  728. <if test="stationIdList != null ">
  729. and station_id in
  730. <foreach item="item" index="index" collection="stationIdList"
  731. open="(" separator="," close=")">
  732. #{item}
  733. </foreach>
  734. </if>
  735. </where>
  736. GROUP BY oil_name ,date_format(created_date,'%Y-%m-%d')
  737. </select>
  738. <!-- 日报折线图X轴数据-->
  739. <select id="listXdata" parameterType="Long" resultMap="PayOrderResult">
  740. SELECT date_format(created_date,'%Y-%m-%d') as created_date
  741. from pay_order
  742. <where>
  743. <if test="stationId != null "> and station_id = #{stationId}</if>
  744. <if test="status != null and status != ''"> and status = #{status}</if>
  745. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  746. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  747. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  748. </if>
  749. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  750. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  751. </if>
  752. <if test="stationIdList != null ">
  753. and station_id in
  754. <foreach item="item" index="index" collection="stationIdList"
  755. open="(" separator="," close=")">
  756. #{item}
  757. </foreach>
  758. </if>
  759. </where>
  760. GROUP BY date_format(created_date,'%Y-%m-%d')
  761. </select>
  762. <!--查询数据,根据员工汇总数据-->
  763. <select id="selectPersonnelStructure" parameterType="Long" resultMap="PayOrderResult">
  764. 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
  765. from pay_order a
  766. <where>
  767. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  768. <if test="status != null and status != ''"> and status = #{status}</if>
  769. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  770. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  771. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  772. </if>
  773. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  774. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  775. </if>
  776. <if test="stationIdList != null ">
  777. and station_id in
  778. <foreach item="item" index="index" collection="stationIdList"
  779. open="(" separator="," close=")">
  780. #{item}
  781. </foreach>
  782. </if>
  783. </where>
  784. GROUP BY a.oil_personnel
  785. </select>
  786. <!--初始化数据班结数据,根据油品汇总 -->
  787. <select id="selectOilStructure" parameterType="Long" resultMap="PayOrderResult">
  788. 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
  789. from pay_order a
  790. <where>
  791. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  792. <if test="status != null and status != ''"> and status = #{status}</if>
  793. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  794. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  795. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  796. </if>
  797. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  798. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  799. </if>
  800. </where>
  801. GROUP BY a.oil_name
  802. </select>
  803. <!--初始化数据班结数据,根据员工/支付方式汇总 -->
  804. <select id="selectPersonnelPayStructure" parameterType="Long" resultMap="PayOrderResult">
  805. 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
  806. from pay_order a
  807. <where>
  808. <if test="stationId != null "> and a.station_id = #{stationId}</if>
  809. <if test="status != null and status != ''"> and status = #{status}</if>
  810. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  811. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  812. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  813. </if>
  814. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  815. AND date_format(created_date,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  816. </if>
  817. </where>
  818. GROUP BY a.oil_personnel
  819. </select>
  820. <!--查询本站第一笔数据-->
  821. <select id="getPayOrderInfoMin" parameterType="Long" resultMap="PayOrderResult">
  822. SELECT * from pay_order where order_id = (
  823. SELECT min(order_id)
  824. from pay_order
  825. <where>
  826. <if test="orderNo != null and orderNo != ''"> and order_no = #{orderNo}</if>
  827. <if test="stationId != null "> and station_id = #{stationId}</if>
  828. <if test="status != null and status != ''"> and status = #{status}</if>
  829. <if test="orderType != null and orderType != ''"> and order_type = #{orderType}</if>
  830. </where>
  831. )
  832. </select>
  833. <insert id="insertPayOrder" parameterType="PayOrder" useGeneratedKeys="true" keyProperty="orderId">
  834. insert into pay_order
  835. <trim prefix="(" suffix=")" suffixOverrides=",">
  836. <if test="orderNo != null">order_no,</if>
  837. <if test="stationId != null">station_id,</if>
  838. <if test="status != null">status,</if>
  839. <if test="consumerId != null">consumer_id,</if>
  840. <if test="consumer != null">consumer,</if>
  841. <if test="oilGun != null">oil_gun,</if>
  842. <if test="oilName != null">oil_name,</if>
  843. <if test="oilPirce != null">oil_pirce,</if>
  844. <if test="oilType != null">oil_type,</if>
  845. <if test="orderLiters != null">order_liters,</if>
  846. <if test="amt != null">amt,</if>
  847. <if test="receivableAmt != null">receivable_amt,</if>
  848. <if test="receivedAmt != null">received_amt,</if>
  849. <if test="discountAmt != null">discount_amt,</if>
  850. <if test="discountCouponAmt != null">discount_coupon_amt,</if>
  851. <if test="discountCoupon != null">discount_coupon,</if>
  852. <if test="wxAmt != null">wx_amt,</if>
  853. <if test="zfbAmt != null">zfb_amt,</if>
  854. <if test="posAmt != null">pos_amt,</if>
  855. <if test="xjAmt != null">xj_amt,</if>
  856. <if test="didiAppAmt != null">didi_app_amt,</if>
  857. <if test="tyAppAmt != null">ty_app_amt,</if>
  858. <if test="otherAmt != null">other_amt,</if>
  859. <if test="dzkAmt != null">dzk_amt,</if>
  860. <if test="score != null">score,</if>
  861. <if test="memberNo != null">member_no,</if>
  862. <if test="memberAmt != null">member_amt,</if>
  863. <if test="printCount != null">print_count,</if>
  864. <if test="payType != null">pay_type,</if>
  865. <if test="payWay != null">pay_way,</if>
  866. <if test="oilPersonnel != null">oil_personnel,</if>
  867. <if test="payDate != null">pay_date,</if>
  868. <if test="createdDate != null">created_date,</if>
  869. <if test="orderType != null">order_type,</if>
  870. <if test="carNo != null">car_no,</if>
  871. <if test="customerPhone != null">customer_phone,</if>
  872. <if test="customerGrade != null">customer_grade,</if>
  873. </trim>
  874. <trim prefix="values (" suffix=")" suffixOverrides=",">
  875. <if test="orderNo != null">#{orderNo},</if>
  876. <if test="stationId != null">#{stationId},</if>
  877. <if test="status != null">#{status},</if>
  878. <if test="consumerId != null">#{consumerId},</if>
  879. <if test="consumer != null">#{consumer},</if>
  880. <if test="oilGun != null">#{oilGun},</if>
  881. <if test="oilName != null">#{oilName},</if>
  882. <if test="oilPirce != null">#{oilPirce},</if>
  883. <if test="oilType != null">#{oilType},</if>
  884. <if test="orderLiters != null">#{orderLiters},</if>
  885. <if test="amt != null">#{amt},</if>
  886. <if test="receivableAmt != null">#{receivableAmt},</if>
  887. <if test="receivedAmt != null">#{receivedAmt},</if>
  888. <if test="discountAmt != null">#{discountAmt},</if>
  889. <if test="discountCouponAmt != null">#{discountCouponAmt},</if>
  890. <if test="discountCoupon != null">#{discountCoupon},</if>
  891. <if test="wxAmt != null">#{wxAmt},</if>
  892. <if test="zfbAmt != null">#{zfbAmt},</if>
  893. <if test="posAmt != null">#{posAmt},</if>
  894. <if test="xjAmt != null">#{xjAmt},</if>
  895. <if test="didiAppAmt != null">#{didiAppAmt},</if>
  896. <if test="tyAppAmt != null">#{tyAppAmt},</if>
  897. <if test="otherAmt != null">#{otherAmt},</if>
  898. <if test="dzkAmt != null">#{dzkAmt},</if>
  899. <if test="score != null">#{score},</if>
  900. <if test="memberNo != null">#{memberNo},</if>
  901. <if test="memberAmt != null">#{memberAmt},</if>
  902. <if test="printCount != null">#{printCount},</if>
  903. <if test="payType != null">#{payType},</if>
  904. <if test="payWay != null">#{payWay},</if>
  905. <if test="oilPersonnel != null">#{oilPersonnel},</if>
  906. <if test="payDate != null">#{payDate},</if>
  907. <if test="createdDate != null">#{createdDate},</if>
  908. <if test="orderType != null">#{orderType},</if>
  909. <if test="carNo != null">#{carNo},</if>
  910. <if test="customerPhone != null">#{customerPhone},</if>
  911. <if test="customerGrade != null">#{customerGrade},</if>
  912. </trim>
  913. </insert>
  914. <update id="updatePayOrder" parameterType="PayOrder">
  915. update pay_order
  916. <trim prefix="SET" suffixOverrides=",">
  917. <if test="orderNo != null">order_no = #{orderNo},</if>
  918. <if test="stationId != null">station_id = #{stationId},</if>
  919. <if test="status != null">status = #{status},</if>
  920. <if test="consumerId != null">consumer_id = #{consumerId},</if>
  921. <if test="consumer != null">consumer = #{consumer},</if>
  922. <if test="oilGun != null">oil_gun = #{oilGun},</if>
  923. <if test="oilName != null">oil_name = #{oilName},</if>
  924. <if test="oilPirce != null">oil_pirce = #{oilPirce},</if>
  925. <if test="oilType != null">oil_type = #{oilType},</if>
  926. <if test="orderLiters != null">order_liters = #{orderLiters},</if>
  927. <if test="amt != null">amt = #{amt},</if>
  928. <if test="receivableAmt != null">receivable_amt = #{receivableAmt},</if>
  929. <if test="receivedAmt != null">received_amt = #{receivedAmt},</if>
  930. <if test="discountAmt != null">discount_amt = #{discountAmt},</if>
  931. <if test="discountCouponAmt != null">discount_coupon_amt = #{discountCouponAmt},</if>
  932. <if test="discountCoupon != null">discount_coupon = #{discountCoupon},</if>
  933. <if test="wxAmt != null">wx_amt = #{wxAmt},</if>
  934. <if test="zfbAmt != null">zfb_amt = #{zfbAmt},</if>
  935. <if test="posAmt != null">pos_amt = #{posAmt},</if>
  936. <if test="xjAmt != null">xj_amt = #{xjAmt},</if>
  937. <if test="didiAppAmt != null">didi_app_amt = #{didiAppAmt},</if>
  938. <if test="tyAppAmt != null">ty_app_amt = #{tyAppAmt},</if>
  939. <if test="otherAmt != null">other_amt = #{otherAmt},</if>
  940. <if test="dzkAmt != null">dzk_amt = #{dzkAmt},</if>
  941. <if test="score != null">score = #{score},</if>
  942. <if test="memberNo != null">member_no = #{memberNo},</if>
  943. <if test="memberAmt != null">member_amt = #{memberAmt},</if>
  944. <if test="printCount != null">print_count = #{printCount},</if>
  945. <if test="payType != null">pay_type = #{payType},</if>
  946. <if test="payWay != null">pay_way = #{payWay},</if>
  947. <if test="oilPersonnel != null">oil_personnel = #{oilPersonnel},</if>
  948. <if test="payDate != null">pay_date = #{payDate},</if>
  949. <if test="createdDate != null">created_date = #{createdDate},</if>
  950. <if test="orderType != null">order_type = #{orderType},</if>
  951. <if test="carNo != null">car_no = #{carNo},</if>
  952. <if test="customerPhone != null">customer_phone = #{customerPhone},</if>
  953. <if test="customerGrade != null">customer_grade = #{customerGrade},</if>
  954. </trim>
  955. where order_id = #{orderId}
  956. </update>
  957. <delete id="deletePayOrderById" parameterType="Long">
  958. delete from pay_order where order_id = #{orderId}
  959. </delete>
  960. <delete id="deletePayOrderByIds" parameterType="String">
  961. delete from pay_order where order_id in
  962. <foreach item="orderId" collection="array" open="(" separator="," close=")">
  963. #{orderId}
  964. </foreach>
  965. </delete>
  966. </mapper>