TradeVisitorMapper.xml 26 KB

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