HouseOrderMapper.xml 13 KB

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