ResourceRouteMapper.xml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.resource.dal.mysql.route.ResourceRouteMapper">
  4. <!--
  5. 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  6. 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  7. 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  8. 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  9. -->
  10. <select id="selectAppRoutePage" resultType="com.yc.ship.module.resource.controller.app.route.vo.AppResourceRouteRespVO">
  11. select * from (
  12. SELECT
  13. rr.direction,
  14. rr.id route_id,
  15. rr.NAME route_name,
  16. rr.on_dock_id dock_id,
  17. rp.id port_id,
  18. rr.short_name route_short_name,
  19. rr.duration,
  20. rs.id ship_id,
  21. rs.NAME ship_name,
  22. rs.img ship_img,
  23. t2.price
  24. FROM
  25. resource_route rr
  26. LEFT JOIN resource_dock rd on rr.on_dock_id = rd.id
  27. LEFT JOIN resource_port rp on rd.port_id = rp.id
  28. LEFT JOIN product_voyage pv ON rr.id = pv.route_id
  29. <if test="reqVo.startDay != null and reqVo.startDay != ''">
  30. and pv.start_time BETWEEN BETWEEN CONCAT(#{reqVo.startDay},' 00:00:00') and CONCAT(#{reqVo.startDay},' 23:59:59')
  31. </if>
  32. LEFT JOIN resource_ship rs ON pv.ship_id = rs.id
  33. LEFT JOIN (
  34. SELECT
  35. *
  36. FROM
  37. (
  38. SELECT
  39. ppv.voyage_id,
  40. pprm.price
  41. FROM
  42. product_price_voyage ppv
  43. LEFT JOIN product_price_room_model pprm ON pprm.object_id = ppv.id
  44. where ppv.deleted = 0 and pprm.deleted = 0
  45. ORDER BY
  46. pprm.price ASC
  47. ) t1
  48. GROUP BY
  49. t1.voyage_id
  50. ) t2 ON pv.id = t2.voyage_id
  51. where rr.deleted = 0 and rd.deleted = 0 and rp.deleted = 0 and pv.deleted = 0 and rs.deleted = 0 and pv.start_time > now()
  52. and pv.channel like '%2%'
  53. GROUP BY
  54. rr.id, rs.id
  55. ) t3 where 1=1 and t3.price is not null
  56. <if test="reqVo.shipId != null">
  57. and t3.ship_id = #{reqVo.shipId}
  58. </if>
  59. <if test="reqVo.dockId != null">
  60. and t3.dock_id = #{reqVo.dockId}
  61. </if>
  62. <if test="reqVo.portId != null">
  63. and t3.port_id = #{reqVo.portId}
  64. </if>
  65. <if test="reqVo.routeId != null">
  66. and t3.routeId = #{reqVo.routeId}
  67. </if>
  68. <if test="reqVo.direction != null">
  69. and t3.direction = #{reqVo.direction}
  70. </if>
  71. order by t3.price asc
  72. </select>
  73. </mapper>