TradeVisitorMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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.order.TradeVisitorMapper">
  4. <select id="selectVisitorListBySupplierOrder"
  5. resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  6. select v.*,d.voucher_code
  7. FROM trade_detail_base db
  8. INNER JOIN trade_detail d on d.id = db.detail_id
  9. INNER JOIN trade_visitor v on v.detail_id = d.id
  10. <where>
  11. db.plat_supplier_order_id = #{platSupplierOrderId}
  12. </where>
  13. group by v.id
  14. order by v.detail_id
  15. </select>
  16. <select id="selectVisitorListBySpecType"
  17. resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  18. select v.*
  19. FROM trade_detail_base db
  20. INNER JOIN trade_detail d on d.id = db.detail_id
  21. INNER JOIN trade_visitor v on v.detail_id = d.id
  22. <where>
  23. db.plat_supplier_order_id = #{platSupplierOrderId}
  24. and db.spec_type = #{specType}
  25. and db.product_base_id in
  26. <foreach collection="baseList" index="index" item="item" open="(" separator="," close=")">
  27. #{item}
  28. </foreach>
  29. </where>
  30. group by v.id
  31. order by v.detail_id
  32. </select>
  33. <select id="selectVisitorVoucherListByOrderId"
  34. resultType="com.yc.ship.module.trade.service.order.bo.TradeVisitorBO">
  35. select v.*,d.voucher_code,d.quantity_of_one
  36. FROM trade_detail d
  37. LEFT JOIN trade_visitor v on v.detail_id = d.id
  38. <where>
  39. d.order_id = #{orderId}
  40. </where>
  41. order by d.id
  42. </select>
  43. <select id="selectInsureVisitor"
  44. resultType="com.yc.ship.module.trade.service.order.bo.TradeVisitorBO">
  45. select tv.*,td.use_date
  46. from trade_detail td
  47. inner join trade_visitor tv on tv.detail_id = td.id
  48. <where>
  49. td.order_id =#{orderId} and td.voucher_status not in (4,5) and td.voucher_status>=1 and tv.is_insure =1
  50. and td.product_id=#{productId}
  51. </where>
  52. </select>
  53. <select id="selectContractVisitor"
  54. resultType="com.yc.ship.module.trade.service.order.bo.TradeVisitorBO">
  55. select distinct tv.*,td.use_date
  56. from trade_detail td
  57. inner join trade_visitor tv on tv.id = td.visitor_id
  58. <where>
  59. td.order_id =#{orderId} and td.voucher_status not in (4,5) and td.voucher_status>=1
  60. </where>
  61. </select>
  62. <select id="selectSupplierVisitor"
  63. resultType="com.yc.ship.module.trade.service.order.bo.TradeVisitorBO">
  64. select tdb.supplier_voucher_code, v.*
  65. from trade_detail_base tdb
  66. inner join trade_visitor v on v.detail_id = tdb.detail_id
  67. <where>
  68. tdb.plat_supplier_order_id = #{platSupplierOrderId}
  69. <if test="visitorIdList!=null">
  70. and v.id in
  71. <foreach collection="visitorIdList" item="item" separator="," open="(" close=")">
  72. #{item}
  73. </foreach>
  74. </if>
  75. </where>
  76. </select>
  77. <select id="selectShipVisitor"
  78. resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  79. select t.product_type productType,v.*,t3.id_card jzCard,t3.arrive_time jzTime,t3.phone jzPhone,t3.address jzAddress
  80. , a.name nationalityName,t5.room_model_name roomModelName
  81. from trade_detail t inner join trade_visitor v on v.detail_id = t.id
  82. left join trade_order_jz_detail t3 on v.credential_no = t3.id_card and t3.deleted =0
  83. left join area a on v.nationality = a.id
  84. left join trade_order_room_model t5 on v.room_index_id = t5.room_index_id
  85. where t.order_id = #{orderId} and v.deleted =0 and t.product_type =0 and t.deleted =0
  86. group by v.id
  87. </select>
  88. <select id="selectRoomShipVisitor"
  89. resultType="com.yc.ship.module.product.api.dto.OrderRoomUseDTO">
  90. select room_model_id,floor,room_id,count(1) num from trade_visitor
  91. where order_id = #{orderId} and deleted =0
  92. group by room_model_id,floor,room_id
  93. </select>
  94. <select id="selectRefundRoomShipVisitor"
  95. resultType="com.yc.ship.module.product.api.dto.OrderRoomUseDTO">
  96. select t1.room_model_id,t1.floor,t1.room_id,count(distinct t1.id) num from trade_visitor t1
  97. inner join trade_detail t2 on t1.detail_id = t2.id
  98. inner join trade_refund_detail t3 on t2.id = t3.trade_detail_id
  99. where t3.refund_id = #{refundId} and deleted =0
  100. group by t1.room_model_id,t1.floor,t1.room_id
  101. </select>
  102. <select id="selectRoomShipVisitor2"
  103. resultType="com.yc.ship.module.product.api.dto.OrderRoomUseDTO">
  104. select room_model_id,floor,'' room_id,count(1) num from trade_order_room_model
  105. where order_id = #{orderId}
  106. group by room_model_id,floor
  107. </select>
  108. <select id="queryRelatedVisitor"
  109. resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  110. SELECT v1.*, v2.id associatedVisitorId
  111. FROM trade_visitor v1
  112. INNER JOIN trade_visitor v2 ON v2.ota_detail_id = v1.detail_id
  113. WHERE v2.id in
  114. <foreach collection="visitorIds" item="item" separator="," open="(" close=")">
  115. #{item}
  116. </foreach>
  117. UNION ALL
  118. SELECT v1.*, v2.id associatedVisitorId
  119. FROM trade_visitor v1
  120. INNER JOIN trade_visitor v2 ON v2.detail_id = v1.ota_detail_id
  121. WHERE v2.id in
  122. <foreach collection="visitorIds" item="item" separator="," open="(" close=")">
  123. #{item}
  124. </foreach>
  125. </select>
  126. <select id="queryVisitorByOrderId" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeVisitorRespVO">
  127. SELECT v1.*,t3.name nationalityName FROM trade_visitor v1 INNER JOIN trade_detail v2 ON v1.id = v2.visitor_id
  128. left join area t3 on v1.nationality = t3.id
  129. WHERE v2.order_id = #{orderId} and v1.deleted = 0 and v2.deleted = 0 and v2.product_type = 0
  130. </select>
  131. <select id="selectVisitorListByDate" resultType="com.yc.ship.module.trade.service.order.bo.TradeVisitorBO">
  132. select tv.*,td.product_name,td.spec_type,td.use_date,prp.name planName
  133. from trade_detail td
  134. inner join trade_order tt on td.order_id = tt.id
  135. left join product_route_plan prp on tt.route_plan_id = prp.id
  136. inner join trade_visitor tv on td.id = tv.detail_id
  137. inner join trade_detail_base tdb on td.id = tdb.detail_id
  138. where td.use_date =#{useDate} and tv.credential_no is not null
  139. and tdb.project_code='boat'
  140. and tv.is_push is null
  141. and td.voucher_status in (1,2,4,8,9)
  142. <if test="orderId!=null">
  143. and td.order_id = #{orderId}
  144. </if>
  145. <if test="tenantId!=null">
  146. and td.tenant_id = #{tenantId}
  147. </if>
  148. GROUP BY td.id,tv.id
  149. order by tv.create_time asc
  150. </select>
  151. <select id="selectBoatVisitorListByRefund" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  152. select tv.*
  153. from trade_refund tr
  154. INNER JOIN trade_refund_detail_base trdb on trdb.refund_id = tr.id
  155. INNER JOIN trade_detail_base tdb on tdb.id = trdb.trade_detail_base_id
  156. INNER JOIN trade_visitor tv on tv.detail_id = trdb.trade_detail_id
  157. where tr.id = #{refundId} and tdb.project_code = 'boat'
  158. <if test="useDate!=null">
  159. and tdb.use_date = #{useDate}
  160. </if>
  161. GROUP BY tv.id
  162. </select>
  163. <select id="selectOrderVisitorCount" resultType="java.lang.Integer">
  164. select count(*) totalCount
  165. from trade_detail td
  166. INNER JOIN trade_visitor tv on tv.detail_id = td.id
  167. where td.order_id = #{orderId}
  168. and td.voucher_status !=5
  169. </select>
  170. <select id="selectShipByOrderIds"
  171. resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  172. select * from trade_visitor where detail_id in (
  173. select id from trade_detail where order_id in
  174. <foreach collection="orderIds" item="item" separator="," open="(" close=")">
  175. #{item}
  176. </foreach>
  177. )
  178. </select>
  179. <select id="queryVisitorByVovageId" resultType="java.lang.Integer">
  180. select count(*) from trade_visitor t1 inner join trade_order t2 on t1.order_id=t2.id
  181. where t1.credential_no=#{credentialNo} and t2.voyage_id=#{voyageId} and t2.order_no!=#{orderNo}
  182. and t2.deleted = 0 and t1.deleted = 0 and t2.order_status in (15, 14, 13, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
  183. </select>
  184. <select id="selectListByVoyageId" resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  185. select tv.*,if(pprmt.total_num &gt;=2 and pprmt.enable_share=0,1,0) as isHaveTogethers,if(pprmt.total_num =1 and pprmt.enable_share=0,1,0) as isAlone
  186. from trade_visitor tv
  187. join trade_order to1 on tv.order_id=to1.id and to1.deleted=0
  188. join trade_order_room_model torm on tv.room_index_id=torm.room_index_id and torm.deleted=0
  189. join product_price_room_model_type pprmt on torm.room_model_type_id = pprmt.id and pprmt.deleted=0
  190. where to1.voyage_id=#{voyageId} and to1.order_status=6 and tv.deleted=0
  191. and tv.room_index_id is not null
  192. and tv.room_model_id is not null
  193. and tv.floor is not null
  194. </select>
  195. <select id="selectListByVoyageIdAndRoomId"
  196. resultType="com.yc.ship.module.trade.dal.dataobject.order.TradeVisitorDO">
  197. select tv.*
  198. from trade_visitor tv
  199. join trade_order b on tv.order_id=b.id and b.deleted=0
  200. where b.order_status=6 and b.voyage_id=#{voyageId} and if(tv.final_room_id is null,tv.init_room_id,tv.final_room_id)=#{roomId}
  201. </select>
  202. <select id="getExportVisitorList" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TradeOrderRespExcelVO">
  203. select t1.order_no orderNo,t1.group_no groupNo,t1.order_status orderStatus,t1.source_name sourceName,t3.name name,
  204. t3.gender gender,t3.type visitorType,t3.credential_type credentialType,t3.credential_no credentialNo,
  205. t7.name nationality,t3.birthday birthday,t3.mobile mobile,t3.age age,t3.mobile mobile,t5.short_name roomModelName,t3.floor floor,t6.room_num roomName,t2.price price,t3.remark remark
  206. from trade_order t1 inner join trade_detail t2 on t1.id=t2.order_id and t2.product_type = 0 and t2.deleted = 0
  207. inner join trade_visitor t3 on t2.visitor_id=t3.id and t3.deleted =0
  208. left join trade_order_room_model t4 on t3.room_index_id=t4.room_index_id and t4.deleted=0
  209. left join resource_room_model t5 on t4.room_model_id = t5.id and t5.deleted=0
  210. left join resource_room t6 on t3.room_id = t6.id and t6.deleted=0
  211. left join area t7 on t3.nationality = t7.id
  212. where t1.order_status in (15, 14, 13, 11, 10, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1)
  213. <if test="vo.orderNo != null and vo.orderNo != ''">
  214. AND t1.order_no = #{vo.orderNo}
  215. </if>
  216. <if test="vo.voyageId != null and vo.voyageId != ''">
  217. AND t1.voyage_id = #{vo.voyageId}
  218. </if>
  219. <if test="vo.otaId != null and vo.otaId != ''">
  220. AND t1.source_id = #{vo.otaId}
  221. </if>
  222. <if test="vo.otaIds != null and vo.otaIds.size()>0">
  223. AND t1.source_id IN
  224. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  225. #{item}
  226. </foreach>
  227. </if>
  228. <if test="vo.orderStatus!=null and vo.orderStatus.size()>0">
  229. and t1.order_status in
  230. <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
  231. #{item}
  232. </foreach>
  233. </if>
  234. </select>
  235. <!-- 查询游客名单导出游客列表 -->
  236. <select id="selectTouristExportVisitor" resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.TouristExportVisitorVO">
  237. SELECT
  238. od.name AS sourceName,
  239. tor.order_no AS orderNo,
  240. tor.group_no AS groupNo,
  241. CASE WHEN rr.direction = 1 THEN '上水' ELSE '下水' END AS direction,
  242. CASE WHEN tjz.is_jz = 1 THEN '是' ELSE '否' END AS jz,
  243. DATE_FORMAT(pv.start_time, '%Y.%m.%d') AS travelDate,
  244. tor.pay_amount AS amount,
  245. tor.real_pay_amount AS payAmount,
  246. tor.deposi,
  247. tv.room_index_id AS roomIndexId,
  248. torm.room_model_name AS roomType,
  249. pprmt.type_name AS typeName ,
  250. tv.name,
  251. tv.gender,
  252. tv.birthday,
  253. tv.mobile,
  254. tv.order_id as orderId,
  255. tv.credential_type AS credentialType,
  256. tv.credential_no AS credentialNo,
  257. tv.type AS visitorType,
  258. tv.age,
  259. torm.floor as floor,
  260. a.name AS nationalityName,
  261. GROUP_CONCAT(ps.product_name) AS valueAddedService,
  262. tor.remark,
  263. tor.order_status as orderStatus
  264. FROM trade_visitor tv
  265. INNER JOIN trade_order tor ON tv.order_id = tor.id AND tor.deleted = 0
  266. INNER JOIN trade_detail td ON tv.id = td.visitor_id AND td.deleted = 0
  267. LEFT JOIN area a ON tv.nationality = a.id
  268. LEFT JOIN product_voyage pv ON tor.voyage_id = pv.id
  269. LEFT JOIN resource_route rr ON pv.route_id = rr.id
  270. LEFT JOIN ota_distributor od ON tor.source_id = od.id
  271. LEFT JOIN trade_order_room_model torm ON tv.room_index_id = torm.room_index_id AND torm.deleted = 0
  272. left JOIN product_spu ps on ps.id = td.product_id
  273. left join trade_order_pay top ON top.order_id = tor.id and top.deleted = 0 and top.pay_status = 1
  274. left Join trade_order_jz tjz on tjz.order_id = tor.id
  275. left Join product_price_room_model_type pprmt on torm.room_model_type_id = pprmt.id
  276. WHERE tv.deleted = 0
  277. <if test="vo.orderNo != null and vo.orderNo != ''">
  278. AND tor.order_no = #{vo.orderNo}
  279. </if>
  280. <if test="vo.voyageId != null and vo.voyageId != ''">
  281. AND tor.voyage_id = #{vo.voyageId}
  282. </if>
  283. <if test="vo.shipId != null and vo.shipId != ''">
  284. AND pv.ship_id = #{vo.shipId}
  285. </if>
  286. <if test="vo.routeId != null and vo.routeId != ''">
  287. AND pv.route_id = #{vo.routeId}
  288. </if>
  289. <if test="vo.travelDateStart != null and vo.travelDateStart != ''">
  290. AND pv.start_time &gt;= #{vo.travelDateStart}
  291. </if>
  292. <if test="vo.travelDateEnd != null and vo.travelDateEnd != ''">
  293. AND pv.start_time &lt;= #{vo.travelDateEnd}
  294. </if>
  295. <if test="vo.orderDateStart != null and vo.orderDateStart != ''">
  296. AND tor.create_time &gt;= #{vo.orderDateStart}
  297. </if>
  298. <if test="vo.orderDateEnd != null and vo.orderDateEnd != ''">
  299. AND tor.create_time &lt;= #{vo.orderDateEnd}
  300. </if>
  301. <if test="vo.orderStatus != null and vo.orderStatus.size() > 0">
  302. AND tor.order_status IN
  303. <foreach collection="vo.orderStatus" item="item" separator="," open="(" close=")">
  304. #{item}
  305. </foreach>
  306. </if>
  307. <if test="vo.userName != null and vo.userName != ''">
  308. AND tv.name LIKE CONCAT('%', #{vo.userName}, '%')
  309. </if>
  310. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  311. AND tv.credential_no = #{vo.credentialNo}
  312. </if>
  313. <if test="vo.roomModelId != null and vo.roomModelId != ''">
  314. AND torm.room_model_id = #{vo.roomModelId}
  315. </if>
  316. <if test="vo.floor != null and vo.floor != ''">
  317. AND tv.floor = #{vo.floor}
  318. </if>
  319. <if test="vo.otaId != null and vo.otaId != ''">
  320. AND tor.source_id = #{vo.otaId}
  321. </if>
  322. <if test="vo.otaIds != null and vo.otaIds.size()>0">
  323. AND tor.source_id IN
  324. <foreach collection="vo.otaIds" item="item" separator="," open="(" close=")">
  325. #{item}
  326. </foreach>
  327. </if>
  328. <if test="vo.distributorId != null and vo.distributorId != ''">
  329. AND tor.source_id = #{vo.distributorId}
  330. </if>
  331. <if test="vo.otaCateId != null and vo.otaCateId != ''">
  332. AND od.ota_category_id = #{vo.otaCateId}
  333. </if>
  334. <if test="vo.otaCateIds != null and vo.otaCateIds.size() > 0">
  335. AND od.ota_category_id IN
  336. <foreach collection="vo.otaCateIds" item="item" separator="," open="(" close=")">
  337. #{item}
  338. </foreach>
  339. </if>
  340. <if test="vo.contactName != null and vo.contactName != ''">
  341. AND tor.link_man LIKE CONCAT('%', #{vo.contactName}, '%')
  342. </if>
  343. <if test="vo.mobile != null and vo.mobile != ''">
  344. AND tor.link_mobile = #{vo.mobile}
  345. </if>
  346. group by tv.id
  347. ORDER BY od.id ASC,tor.order_no ASC, tv.room_index_id ASC
  348. </select>
  349. <select id="selectPersonDesc" resultType="com.yc.ship.module.trade.controller.app.otc.vo.AppPersonDescVO">
  350. select order_id,name, count(1) num
  351. from trade_visitor
  352. where deleted = 0 and order_id in
  353. <foreach item="item" collection="orderIds" separator="," open="(" close=")">
  354. #{item}
  355. </foreach>
  356. <if test="keyword != null and keyword != ''">
  357. and (mobile = #{keyword} or credential_no = #{keyword})
  358. </if>
  359. GROUP BY order_id
  360. </select>
  361. <select id="selectWithLeaderStatsByOrderIds"
  362. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.OrderWithLeaderStatVO">
  363. select
  364. type,
  365. if(gender=0,'女','男') gender,
  366. count(1) num
  367. from trade_visitor
  368. where deleted = 0 and (type = 'with' or type = 'leader') and order_id in
  369. <foreach item="item" collection="orderIds" separator="," open="(" close=")">
  370. #{item}
  371. </foreach>
  372. GROUP BY type, gender
  373. </select>
  374. <select id="selectOrderCountryStatsByOrderIds"
  375. resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.OrderTotalCountryVO">
  376. SELECT
  377. d1.country_id,
  378. d2.country_name,
  379. d1.adultNum,
  380. d1.childNum,
  381. d1.babyNum,
  382. d1.leaderNum,
  383. d1.withNum,
  384. d2.twoNum,
  385. d2.threeNum,
  386. d2.fourNum,
  387. d2.fiveNum,
  388. d2.sixNum
  389. FROM
  390. (
  391. SELECT
  392. a1.country_id,
  393. a1.country_name,
  394. sum( CASE WHEN a1.type = 'adultTake' OR a1.type = 'adultPlus' THEN a1.num ELSE 0 END ) AS adultNum,
  395. sum( CASE WHEN a1.type = 'childTake' OR a1.type = 'childNonTake' or a1.type = 'childPlus' THEN a1.num ELSE 0 END ) AS childNum,
  396. sum( CASE WHEN a1.type = 'babyTake' OR a1.type = 'babyNonTake' or a1.type = 'babyPlus' THEN a1.num ELSE 0 END ) AS babyNum,
  397. sum( CASE WHEN a1.type = 'leader' THEN a1.num ELSE 0 END ) AS leaderNum,
  398. sum( CASE WHEN a1.type = 'with' THEN a1.num ELSE 0 END ) AS withNum
  399. FROM
  400. (
  401. SELECT
  402. t1.nationality country_id,
  403. t2.`name` country_name,
  404. t1.type,
  405. count( t1.id ) num
  406. FROM
  407. trade_visitor t1
  408. LEFT JOIN area t2 ON t1.nationality = t2.id
  409. WHERE
  410. t1.deleted = 0
  411. AND t1.nationality IS NOT NULL
  412. AND t1.nationality != ''
  413. and t1.order_id in
  414. <foreach item="item" collection="orderIds" separator="," open="(" close=")">
  415. #{item}
  416. </foreach>
  417. GROUP BY
  418. t1.nationality,
  419. t1.type
  420. ) a1
  421. GROUP BY
  422. a1.country_id
  423. ORDER BY
  424. a1.country_id ASC
  425. ) d1
  426. LEFT JOIN (
  427. SELECT
  428. a1.country_id,
  429. a1.country_name,
  430. sum( CASE WHEN a1.floor = 2 THEN a1.num ELSE 0 END ) AS twoNum,
  431. sum( CASE WHEN a1.floor = 3 THEN a1.num ELSE 0 END ) AS threeNum,
  432. sum( CASE WHEN a1.floor = 4 THEN a1.num ELSE 0 END ) AS fourNum,
  433. sum( CASE WHEN a1.floor = 5 THEN a1.num ELSE 0 END ) AS fiveNum,
  434. sum( CASE WHEN a1.floor = 6 THEN a1.num ELSE 0 END ) AS sixNum
  435. FROM
  436. (
  437. SELECT
  438. t1.nationality country_id,
  439. t2.`name` country_name,
  440. t3.floor,
  441. count( t1.id ) num
  442. FROM
  443. trade_visitor t1
  444. LEFT JOIN area t2 ON t1.nationality = t2.id
  445. LEFT JOIN trade_order_room_model t3 ON t1.room_index_id = t3.room_index_id
  446. WHERE
  447. t1.deleted = 0
  448. AND t3.deleted = 0
  449. AND t1.nationality IS NOT NULL
  450. AND t1.nationality != ''
  451. and t1.order_id in
  452. <foreach item="item" collection="orderIds" separator="," open="(" close=")">
  453. #{item}
  454. </foreach>
  455. GROUP BY
  456. t1.nationality,
  457. t3.floor
  458. ) a1
  459. GROUP BY
  460. a1.country_id
  461. ORDER BY
  462. a1.country_id ASC
  463. ) d2 ON d1.country_id = d2.country_id
  464. ORDER BY
  465. d1.country_id ASC
  466. </select>
  467. <select id="selectPersonListByOrderId"
  468. resultType="com.yc.ship.module.trade.controller.app.otc.vo.AppItineraryPersonVO">
  469. SELECT
  470. t1.id,
  471. t1.NAME,
  472. t1.mobile,
  473. t1.final_room_id,
  474. t2.room_num final_room_name,
  475. t1.init_room_id,
  476. t3.room_num init_room_name,
  477. t1.room_id,
  478. t4.room_num room_name
  479. FROM
  480. trade_visitor t1
  481. LEFT JOIN resource_room t2 ON t1.final_room_id = t2.id
  482. LEFT JOIN resource_room t3 ON t1.init_room_id = t3.id
  483. LEFT JOIN resource_room t4 ON t1.room_id = t4.id
  484. WHERE
  485. t1.deleted = 0
  486. AND t1.order_id = #{orderId}
  487. <if test="keyword != null and keyword != ''">
  488. AND (t1.mobile = #{keyword} or t1.credential_no = #{keyword})
  489. </if>
  490. </select>
  491. <select id="selectVisitorPage" resultType="com.yc.ship.module.trade.controller.admin.visitor.vo.VisitorRespVO">
  492. select t3.policy_no,t3.id insurance_id, t1.id,t1.order_id,t1.`name`,t1.gender,t1.credential_no,t1.nationality,t1.credential_type,t1.mobile,t1.is_insure,t1.insure_msg,t1.age,t2.order_no,t2.order_status,t4.id voyage_id,t4.name voyage_name from trade_visitor t1 LEFT JOIN trade_order t2 on t1.order_id = t2.id and t2.deleted = 0 LEFT JOIN trade_insurance t3 on t1.id = t3.visitor_id and t3.deleted = 0 LEFT JOIN product_voyage t4 on t2.voyage_id = t4.id and t4.deleted = 0
  493. where t1.deleted = 0 and t2.order_status in (1,6,13,14) and t4.id is not null
  494. <if test="vo.orderNo != null and vo.orderNo != ''">
  495. and t2.order_no = #{vo.orderNo}
  496. </if>
  497. <if test="vo.voyageId != null and vo.voyageId != ''">
  498. and t4.id = #{vo.voyageId}
  499. </if>
  500. <if test="vo.shipId != null and vo.shipId != ''">
  501. and t4.ship_id = #{vo.shipId}
  502. </if>
  503. <if test="vo.credentialNo != null and vo.credentialNo != ''">
  504. and t1.credential_no = #{vo.credentialNo}
  505. </if>
  506. <if test="vo.name != null and vo.name != ''">
  507. and t1.name like concat('%',#{vo.name},'%')
  508. </if>
  509. <if test="vo.isInsure != null">
  510. and t1.is_insure = #{vo.isInsure}
  511. </if>
  512. order by t1.create_time asc
  513. </select>
  514. <delete id="deleteAllByOrderId">
  515. delete from trade_visitor where order_id = #{orderId}
  516. </delete>
  517. </mapper>