OrderJzDetailMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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.yc.ship.module.trade.dal.mysql.orderjzdetail.OrderJzDetailMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="selectPage2"
  11. resultType="com.yc.ship.module.trade.dal.dataobject.orderjzdetail.OrderJzDetailDO">
  12. select distinct d.* , r.direction , rm.name as room_model_name,
  13. o.order_no as orderNo, dj.dispatch_no as dispatchNo, dj.group_no as groupNo,
  14. o.source_name as sourceName,
  15. dj.bus_number as busNumber, dj.driver_name as driverName, dj.driver_phone as driverPhone,
  16. dj.receiver_name as receiverName, dj.receiver_phone as receiverPhone, d.sign_remark as dispatchRemark
  17. from trade_order_jz_detail d
  18. inner join trade_order_jz oz on d.jz_id = oz.id
  19. inner join trade_order o on o.deleted = 0 and o.id = oz.order_id
  20. inner join product_voyage v on o.voyage_id = v.id
  21. inner join resource_route r on v.route_id = r.id
  22. inner join trade_visitor u on u.credential_no = d.id_card and u.order_id = oz.order_id
  23. left join resource_room_model rm on u.room_model_id = rm.id
  24. left join trade_order_jz_dispatch dj on d.dispatch_id = dj.id
  25. inner join trade_detail td on td.order_id = o.id and td.product_id != 2034458675435925505
  26. where d.deleted = 0 and o.voyage_id = #{vo.voyageId} and o.order_status IN (15, 14, 13, 10, 12, 9, 8, 7, 6, 5, 4, 3, 1, 0)
  27. <if test="vo.idCard != null">
  28. and d.id_card like concat('%', #{vo.idCard}, '%')
  29. </if>
  30. <if test="vo.name != null">
  31. and d.name like concat('%', #{vo.name}, '%')
  32. </if>
  33. <if test="vo.address != null">
  34. and d.address = #{vo.address}
  35. </if>
  36. <if test="vo.arriveTime != null">
  37. and d.arrive_time = #{vo.arriveTime}
  38. </if>
  39. <if test="vo.dispatchNo != null and vo.dispatchNo != ''">
  40. and dj.dispatch_no like concat('%', #{vo.dispatchNo}, '%')
  41. </if>
  42. <if test="vo.signStatus != null and vo.signStatus == 1">
  43. and d.sign_time is not null
  44. </if>
  45. <if test="vo.signStatus != null and vo.signStatus == 0">
  46. and d.sign_time is null
  47. </if>
  48. order by d.address + 0 asc, d.arrive_time + 0 asc, oz.order_id asc
  49. </select>
  50. <!-- selectVisitorExportList: 导出游客接站明细,条件与selectPage2一致,不分页 -->
  51. <select id="selectVisitorExportList"
  52. resultType="com.yc.ship.module.trade.dal.dataobject.orderjzdetail.OrderJzDetailDO">
  53. select distinct d.* , r.direction , rm.name as room_model_name,
  54. o.order_no as orderNo,o.source_name as sourceName, dj.dispatch_no as dispatchNo, dj.group_no as groupNo, dj.bus_number as busNumber,dj.driver_name as driverName,dj.driver_phone as driverPhone,dj.receiver_name as receiverName,dj.receiver_phone as receiverPhone,d.sign_remark as dispatchRemark
  55. from trade_order_jz_detail d
  56. inner join trade_order_jz oz on d.jz_id = oz.id
  57. inner join trade_order o on o.deleted = 0 and o.id = oz.order_id
  58. inner join product_voyage v on o.voyage_id = v.id
  59. inner join resource_route r on v.route_id = r.id
  60. inner join trade_visitor u on u.credential_no = d.id_card and u.order_id = oz.order_id
  61. left join resource_room_model rm on u.room_model_id = rm.id
  62. left join trade_order_jz_dispatch dj on d.dispatch_id = dj.id
  63. inner join trade_detail td on td.order_id = o.id and td.product_id != 2034458675435925505
  64. where d.deleted = 0 and o.voyage_id = #{vo.voyageId} and o.order_status IN (15, 14, 13, 10, 12, 9, 8, 7, 6, 5, 4, 3, 1, 0)
  65. <if test="vo.idCard != null and vo.idCard != ''">
  66. and d.id_card like concat('%', #{vo.idCard}, '%')
  67. </if>
  68. <if test="vo.name != null and vo.name != ''">
  69. and d.name like concat('%', #{vo.name}, '%')
  70. </if>
  71. <if test="vo.address != null and vo.address != ''">
  72. and d.address = #{vo.address}
  73. </if>
  74. <if test="vo.arriveTime != null and vo.arriveTime != ''">
  75. and d.arrive_time = #{vo.arriveTime}
  76. </if>
  77. <if test="vo.dispatchNo != null and vo.dispatchNo != ''">
  78. and dj.dispatch_no like concat('%', #{vo.dispatchNo}, '%')
  79. </if>
  80. <if test="vo.signStatus != null and vo.signStatus == 1">
  81. and d.sign_time is not null
  82. </if>
  83. <if test="vo.signStatus != null and vo.signStatus == 0">
  84. and d.sign_time is null
  85. </if>
  86. order by d.address + 0 asc, d.arrive_time + 0 asc, oz.order_id asc
  87. </select>
  88. <select id="selectPage3" resultType="map">
  89. select distinct o.id, o.order_no, r.direction , v.name, v.credential_no, v.mobile, rm.name AS room_model_name
  90. from trade_order o
  91. inner join product_voyage p on o.voyage_id = p.id
  92. inner join resource_route r on p.route_id = r.id
  93. inner join trade_visitor v on o.id = v.order_id
  94. inner join resource_room_model rm ON v.room_model_id = rm.id
  95. where o.deleted = 0 and p.deleted = 0 and r.deleted = 0 and v.deleted = 0
  96. and o.voyage_id = #{vo.voyageId}
  97. <if test="vo.queryCode != null">
  98. and (v.credential_no like concat('%', #{vo.queryCode}, '%') or v.mobile like concat('%', #{vo.queryCode}, '%') or o.order_no like concat('%', #{vo.queryCode}, '%'))
  99. </if>
  100. </select>
  101. <update id="cleanSign">
  102. update trade_order_jz_detail set sign_time = null, sign_man = null, sign_remark = null, sign_image = null
  103. where id = #{id}
  104. </update>
  105. <!-- ==================== 赠送行程接站相关 ==================== -->
  106. <!-- 赠送行程分页查询:基于trade_order_jz_detail,关联trade_detail过滤product_id -->
  107. <select id="selectGiftPage"
  108. resultType="com.yc.ship.module.trade.dal.dataobject.orderjzdetail.OrderJzDetailDO">
  109. select distinct d.* , r.direction , rm.name as room_model_name,
  110. SUBSTRING_INDEX(o.order_no, '-', -1) as orderNo, dj.dispatch_no as dispatchNo, dj.group_no as groupNo,
  111. dj.bus_number as busNumber, dj.driver_name as driverName, dj.driver_phone as driverPhone,
  112. dj.receiver_name as receiverName, dj.receiver_phone as receiverPhone, d.sign_remark as dispatchRemark
  113. from trade_order_jz_detail d
  114. inner join trade_order_jz oz on d.jz_id = oz.id
  115. inner join trade_order o on o.deleted = 0 and o.id = oz.order_id
  116. inner join product_voyage v on o.voyage_id = v.id
  117. inner join resource_route r on v.route_id = r.id
  118. inner join trade_visitor u on u.credential_no = d.id_card and u.order_id = oz.order_id
  119. left join resource_room_model rm on u.room_model_id = rm.id
  120. left join trade_order_jz_dispatch dj on d.dispatch_id = dj.id
  121. inner join trade_detail td on td.order_id = o.id and td.product_id = 2034458675435925505
  122. where d.deleted = 0 and o.voyage_id = #{vo.voyageId}
  123. <if test="vo.idCard != null">
  124. and d.id_card like concat('%', #{vo.idCard}, '%')
  125. </if>
  126. <if test="vo.name != null">
  127. and d.name like concat('%', #{vo.name}, '%')
  128. </if>
  129. <if test="vo.address != null">
  130. and d.address = #{vo.address}
  131. </if>
  132. <if test="vo.arriveTime != null">
  133. and d.arrive_time = #{vo.arriveTime}
  134. </if>
  135. <if test="vo.dispatchNo != null and vo.dispatchNo != ''">
  136. and dj.dispatch_no like concat('%', #{vo.dispatchNo}, '%')
  137. </if>
  138. <if test="vo.signStatus != null and vo.signStatus == 1">
  139. and d.sign_time is not null
  140. </if>
  141. <if test="vo.signStatus != null and vo.signStatus == 0">
  142. and d.sign_time is null
  143. </if>
  144. <if test="vo.orderNo != null and vo.orderNo != ''">
  145. and o.order_no like concat('%', #{vo.orderNo}, '%')
  146. </if>
  147. <if test="vo.otaId != null and vo.otaId != ''">
  148. and o.source_id = #{vo.otaId}
  149. </if>
  150. order by d.address + 0 asc, d.arrive_time + 0 asc
  151. </select>
  152. <!-- 赠送行程导出查询:条件与selectGiftPage一致,不分页 -->
  153. <select id="selectGiftExportList"
  154. resultType="com.yc.ship.module.trade.dal.dataobject.orderjzdetail.OrderJzDetailDO">
  155. select distinct d.* , r.direction , rm.name as room_model_name,
  156. SUBSTRING_INDEX(o.order_no, '-', -1) as orderNo, dj.dispatch_no as dispatchNo, dj.group_no as groupNo, dj.bus_number as busNumber,dj.driver_name as driverName,dj.driver_phone as driverPhone,dj.receiver_name as receiverName,dj.receiver_phone as receiverPhone,d.sign_remark as dispatchRemark
  157. from trade_order_jz_detail d
  158. inner join trade_order_jz oz on d.jz_id = oz.id
  159. inner join trade_order o on o.deleted = 0 and o.id = oz.order_id
  160. inner join product_voyage v on o.voyage_id = v.id
  161. inner join resource_route r on v.route_id = r.id
  162. inner join trade_visitor u on u.credential_no = d.id_card and u.order_id = oz.order_id
  163. left join resource_room_model rm on u.room_model_id = rm.id
  164. left join trade_order_jz_dispatch dj on d.dispatch_id = dj.id
  165. inner join trade_detail td on td.order_id = o.id and td.product_id = 2034458675435925505
  166. where d.deleted = 0 and o.voyage_id = #{vo.voyageId}
  167. <if test="vo.idCard != null and vo.idCard != ''">
  168. and d.id_card like concat('%', #{vo.idCard}, '%')
  169. </if>
  170. <if test="vo.name != null and vo.name != ''">
  171. and d.name like concat('%', #{vo.name}, '%')
  172. </if>
  173. <if test="vo.address != null and vo.address != ''">
  174. and d.address = #{vo.address}
  175. </if>
  176. <if test="vo.arriveTime != null and vo.arriveTime != ''">
  177. and d.arrive_time = #{vo.arriveTime}
  178. </if>
  179. <if test="vo.dispatchNo != null and vo.dispatchNo != ''">
  180. and dj.dispatch_no like concat('%', #{vo.dispatchNo}, '%')
  181. </if>
  182. <if test="vo.signStatus != null and vo.signStatus == 1">
  183. and d.sign_time is not null
  184. </if>
  185. <if test="vo.signStatus != null and vo.signStatus == 0">
  186. and d.sign_time is null
  187. </if>
  188. <if test="vo.orderNo != null and vo.orderNo != ''">
  189. and o.order_no like concat('%', #{vo.orderNo}, '%')
  190. </if>
  191. <if test="vo.otaId != null and vo.otaId != ''">
  192. and o.source_id = #{vo.otaId}
  193. </if>
  194. order by d.address + 0 asc, d.arrive_time + 0 asc
  195. </select>
  196. <!-- 赠送行程补登订单查询:根据订单号/证件号后4位搜索,关联trade_detail过滤product_id -->
  197. <select id="selectGiftOrderPage" resultType="map">
  198. select distinct o.id, o.order_no, r.direction , v.name, v.credential_no, v.mobile, rm.name AS room_model_name
  199. from trade_order o
  200. inner join product_voyage p on o.voyage_id = p.id
  201. inner join resource_route r on p.route_id = r.id
  202. inner join trade_visitor v on o.id = v.order_id
  203. inner join resource_room_model rm ON v.room_model_id = rm.id
  204. inner join trade_detail td on td.order_id = o.id and td.product_id = 2034458675435925505
  205. where o.deleted = 0 and p.deleted = 0 and r.deleted = 0 and v.deleted = 0
  206. and o.voyage_id = #{vo.voyageId}
  207. <if test="vo.queryCode != null">
  208. and (v.credential_no like concat('%', #{vo.queryCode}, '%') or v.mobile like concat('%', #{vo.queryCode}, '%') or o.order_no like concat('%', #{vo.queryCode}, '%'))
  209. </if>
  210. <if test="vo.otaId != null and vo.otaId != ''">
  211. and o.source_id = #{vo.otaId}
  212. </if>
  213. </select>
  214. </mapper>