HouseOrderMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.template.mapper.HouseOrderMapper">
  4. <select id="pageList" resultType="com.template.model.vo.HouseOrderPageListVo">
  5. SELECT
  6. ho.id,
  7. ho.order_number as orderNumber,
  8. ho.reserve_live_time as reserveLiveTime,
  9. ho.reserve_leave_time as reserveLeaveTime,
  10. ho.live_time as liveTime,
  11. ho.leave_time as LeaveTime,
  12. ho.reserve_name as reserveName,
  13. ho.reserve_phone as phone,
  14. ho.live_name as liveName,
  15. u.id_card as idCard,
  16. h.room_name as houseName,
  17. hn.room_number as houseNumber,
  18. ho.pay_price as orderPrice,
  19. ho.pay_type as payType,
  20. ho.order_channel as payChannelType,
  21. ho.order_status as orderStart,
  22. ho.pay_time as payTime,
  23. ho.refund_time as refundTime,
  24. ho.cancel_time as cancelTime,
  25. ho.order_channel as orderChannel,
  26. h.id as houseId,
  27. hn.id as houseNumberId,
  28. h.room_type as roomType,
  29. ho.key_type as lockStatus,
  30. ho.key_pass_word as keyPassWord,
  31. ho.give_back as giveBack,
  32. ho.remark
  33. FROM
  34. `house_order` ho
  35. LEFT JOIN house_number hn ON hn.id = ho.house_number_id
  36. AND hn.deleted = 0
  37. LEFT JOIN house h ON h.id = hn.house_id
  38. AND hn.deleted = 0
  39. LEFT JOIN users u ON u.id = ho.live_users_id
  40. AND u.deleted = 0
  41. LEFT JOIN building b ON b.id = hn.building_id
  42. AND b.deleted = 0
  43. where
  44. ho.deleted=0
  45. <if test="orderStatus != null and orderStatus != ''">
  46. AND ho.order_status = #{orderStatus}
  47. </if>
  48. <if test="houseType != null and houseType != ''">
  49. AND h.room_type = #{houseType}
  50. </if>
  51. <if test="keyWord != null and keyWord != ''">
  52. AND (ho.reserve_name LIKE '%' #{keyWord} '%' or ho.live_name LIKE '%' #{keyWord} '%' )
  53. </if>
  54. <if test="payPriceStartTime != null and payPriceStartTime != '' and payPriceEndTime != null and payPriceEndTime != '' ">
  55. AND #{payPriceEndTime} >= ho.pay_time
  56. AND ho.pay_time >= #{payPriceStartTime}
  57. </if>
  58. <if test="refundStartTime != null and refundStartTime != '' and refundEndTime != null and refundEndTime != '' ">
  59. AND ho.refund_time >= #{refundStartTime}
  60. AND #{refundEndTime} >= ho.refund_time
  61. </if>
  62. <if test="cancelStartTime != null and cancelStartTime != '' and cancelEndTime != null and cancelEndTime != '' ">
  63. AND ho.cancel_time >= #{cancelStartTime}
  64. AND #{cancelEndTime} >= ho.cancel_time
  65. </if>
  66. <if test="liveStartTime != null and liveStartTime != '' and liveEndTime != null and liveEndTime != '' ">
  67. AND #{liveEndTime} >= ho.live_time
  68. AND ho.live_time >= #{liveStartTime}
  69. </if>
  70. <if test="leaveStartTime != null and leaveStartTime != '' and leaveEndTime != null and leaveEndTime != '' ">
  71. AND #{leaveEndTime} >= ho.leave_time
  72. AND ho.leave_time >= #{leaveStartTime}
  73. </if>
  74. <if test="houseId != null and houseId != ''">
  75. AND h.id = #{houseId}
  76. </if>
  77. <if test="keyType != null and keyType != ''">
  78. AND ho.key_type = #{keyType}
  79. </if>
  80. <if test="giveBack != null and giveBack != ''">
  81. AND ho.give_back = #{giveBack}
  82. </if>
  83. <if test="buildingId != null and buildingId != ''">
  84. AND hn.building_id=#{buildingId}
  85. </if>
  86. ORDER BY
  87. ho.create_time DESC
  88. </select>
  89. <select id="queryExport" resultType="com.template.model.vo.QueryExportVo">
  90. SELECT
  91. hn.room_number as houseNumber,
  92. h.room_type as roomType,
  93. h.room_name as houseName,
  94. ho.key_type as lockStatus,
  95. ho.give_back as giveBack,
  96. ho.reserve_name as reserveName,
  97. ho.reserve_phone as phone,
  98. ho.live_name as liveName,
  99. u.id_card as idCard,
  100. ho.order_number as orderNumber,
  101. ho.live_time as liveTime,
  102. ho.leave_time as leaveTime,
  103. ho.pay_price as orderPrice,
  104. ho.order_status as orderStart,
  105. ho.remark,
  106. ho.pay_type as payType,
  107. ho.order_channel as orderChannelType,
  108. ho.pay_time as payTime,
  109. ho.refund_time as refundTime,
  110. ho.cancel_time as cancelTime
  111. FROM
  112. `house_order` ho
  113. LEFT JOIN house_number hn ON hn.id = ho.house_number_id
  114. AND hn.deleted = 0
  115. LEFT JOIN house h ON h.id = hn.house_id
  116. AND hn.deleted = 0
  117. LEFT JOIN users u ON u.id = ho.live_users_id
  118. AND u.deleted = 0
  119. LEFT JOIN building b ON b.id = hn.building_id
  120. AND b.deleted = 0
  121. where
  122. ho.deleted=0
  123. <if test="orderStatus != null and orderStatus != ''">
  124. AND ho.order_status = #{orderStatus}
  125. </if>
  126. <if test="houseType != null and houseType != ''">
  127. AND h.room_type = #{houseType}
  128. </if>
  129. <if test="keyWord != null and keyWord != ''">
  130. AND (ho.reserve_name LIKE '%' #{keyWord} '%' or ho.live_name LIKE '%' #{keyWord} '%' )
  131. </if>
  132. <if test="payPriceStartTime != null and payPriceStartTime != '' and payPriceEndTime != null and payPriceEndTime != '' ">
  133. AND #{payPriceEndTime} >= ho.pay_time
  134. AND ho.pay_time >= #{payPriceStartTime}
  135. </if>
  136. <if test="refundStartTime != null and refundStartTime != '' and refundEndTime != null and refundEndTime != '' ">
  137. AND ho.refund_time >= #{refundStartTime}
  138. AND #{refundEndTime} >= ho.refund_time
  139. </if>
  140. <if test="cancelStartTime != null and cancelStartTime != '' and cancelEndTime != null and cancelEndTime != '' ">
  141. AND ho.cancel_time >= #{cancelStartTime}
  142. AND #{cancelEndTime} >= ho.cancel_time
  143. </if>
  144. <if test="liveStartTime != null and liveStartTime != '' and liveEndTime != null and liveEndTime != '' ">
  145. AND #{liveEndTime} >= ho.live_time
  146. AND ho.live_time >= #{liveStartTime}
  147. </if>
  148. <if test="leaveStartTime != null and leaveStartTime != '' and leaveEndTime != null and leaveEndTime != '' ">
  149. AND #{leaveEndTime} >= ho.leave_time
  150. AND ho.leave_time >= #{leaveStartTime}
  151. </if>
  152. <if test="houseId != null and houseId != ''">
  153. AND h.id = #{houseId}
  154. </if>
  155. <if test="keyType != null and keyType != ''">
  156. AND ho.key_type = #{keyType}
  157. </if>
  158. <if test="giveBack != null and giveBack != ''">
  159. AND ho.give_back = #{giveBack}
  160. </if>
  161. <if test="buildingId != null and buildingId != ''">
  162. AND hn.building_id=#{buildingId}
  163. </if>
  164. ORDER BY
  165. ho.create_time DESC
  166. </select>
  167. <select id="getOrderNumber" resultType="com.template.model.vo.HouseOrderCheckInShowVo">
  168. SELECT ho.reserve_name as liveName,
  169. u.phone,
  170. ho.reserve_live_time as reserveLiveTime,
  171. ho.reserve_leave_time as reserveLeaveTime,
  172. h.room_type as roomType,
  173. ho.house_id as houseId,
  174. ho.house_number_id as houseNumberId,
  175. u.id_card as idCard,
  176. u.card_number as cardNumber,
  177. ho.pay_price as payPrice,
  178. ho.live_day as liveDay,
  179. ho.order_number as orderNumber
  180. FROM `house_order` ho
  181. LEFT JOIN house h on ho.house_id = h.id
  182. LEFT JOIN users u on ho.reserve_user_id = u.id
  183. WHERE ho.order_number = #{orderNumber}
  184. and ho.deleted = 0
  185. </select>
  186. <select id="reportStatisticsPage" resultType="com.template.model.vo.ReportStatisticsVo">
  187. SELECT
  188. ho.id,
  189. ho.order_number as orderNumber,
  190. ho.order_status as orderStatus,
  191. ho.house_id as houseId,
  192. ho.house_number_id as houseNumberId,
  193. ho.live_name as liveName,
  194. ho.reserve_name as reserveName,
  195. ho.reserve_phone as reservePhone,
  196. ho.reserve_user_id as reserveUserId,
  197. ho.live_users_id as liveUsersId,
  198. ho.reserve_live_time as reserveLiveTime,
  199. ho.reserve_leave_time as reserveLeaveTime,
  200. ho.price as price,
  201. ho.house_order_number as houseOrderNumber ,
  202. ho.live_day as liveDay,
  203. ho.live_name_type as liveNameType,
  204. ho.live_time as liveTime,
  205. ho.leave_time as leaveTime,
  206. ho.pay_time as payTime,
  207. ho.refund_time as refundTime,
  208. ho.pay_user_id as payUserId,
  209. ho.order_channel as orderChannel,
  210. ho.pay_type as payType,
  211. ho.pay_price as payPrice,
  212. ho.cancel_time as cancelTime,
  213. ho.electric_cost as electricCost,
  214. ho.electric_consume as electricConsume,
  215. ho.water_cost as waterCost,
  216. ho.water_consume as waterConsume,
  217. ho.create_time as createTime,
  218. hn.room_number AS roomNumber,
  219. h.room_type AS roomType,
  220. h.room_name as roomName
  221. FROM
  222. `house_order` ho
  223. LEFT JOIN house_number hn on ho.house_number_id=hn.id
  224. LEFT JOIN house h on ho.house_id=h.id
  225. WHERE ho.deleted=0
  226. and FIND_IN_SET(ho.order_status,#{s})
  227. <if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
  228. AND #{endTime} >= ho.create_time
  229. AND ho.create_time >= #{startTime}
  230. </if>
  231. <if test="keyWord != null and keyWord != ''">
  232. AND ( ho.order_number LIKE '%' #{keyWord} '%' or ho.live_name LIKE '%' #{keyWord} '%' )
  233. </if>
  234. ORDER BY ho.create_time DESC
  235. </select>
  236. <select id="reportStatisticsExport" resultType="com.template.model.vo.ReportStatisticsExportVo">
  237. SELECT
  238. ho.order_number as orderNumber,
  239. ho.reserve_name as liveName,
  240. h.room_name as roomName,
  241. h.room_type AS roomType,
  242. hn.room_number AS roomNumber,
  243. ho.pay_price as payPrice,
  244. ho.pay_time as payTime,
  245. ho.order_status as orderStatus,
  246. ho.create_time as createTime
  247. FROM
  248. `house_order` ho
  249. LEFT JOIN house_number hn on ho.house_number_id=hn.id
  250. LEFT JOIN house h on ho.house_id=h.id
  251. WHERE ho.deleted=0
  252. and FIND_IN_SET(ho.order_status,#{s})
  253. <if test="startTime != null and startTime != '' and endTime != null and endTime != '' ">
  254. AND #{endTime} >= ho.create_time
  255. AND ho.create_time >= #{startTime}
  256. </if>
  257. <if test="keyWord != null and keyWord != ''">
  258. AND ( ho.order_number LIKE '%' #{keyWord} '%' or ho.live_name LIKE '%' #{keyWord} '%' )
  259. </if>
  260. ORDER BY ho.create_time DESC
  261. </select>
  262. <select id="payHouseOrderUser" resultType="java.lang.String">
  263. SELECT
  264. reserve_user_id
  265. FROM
  266. `house_order`
  267. WHERE deleted=0
  268. AND leave_time> #{start}
  269. AND #{end}> leave_time
  270. GROUP BY reserve_user_id
  271. </select>
  272. <select id="getDate" resultType="com.template.model.pojo.HouseOrder">
  273. SELECT
  274. *
  275. FROM
  276. `house_order`
  277. WHERE
  278. deleted=0
  279. AND FIND_IN_SET(order_status,'1,2,3,4')
  280. AND reserve_user_id=#{userId}
  281. AND #{dateTime} >= reserve_live_time
  282. AND reserve_leave_time >= #{dateTime}
  283. </select>
  284. </mapper>