OrderJzDetailMapper.xml 12 KB

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