ReleaseTravelMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.travel.mapper.ReleaseTravelMapper">
  5. <!-- 新增每天游记内容 -->
  6. <insert id="travelInsterExper" parameterType="TravelExperience">
  7. insert into bus_travel_experience(uuid,day_num,synopsis,video_url,img_url,title) values(#{uuid},#{dayNum},#{synopsis},#{videoUrl},#{imgUrl},#{title})
  8. </insert>
  9. <!-- 新增游记内容 -->
  10. <insert id="travelInster" parameterType="Travel">
  11. insert into bus_travel(code,title_img,synopsis,video_url,img_url,uuid,state_type,travel_date,travel_day,capita,figure,play_type,season,destination,jdrq,people_all,title,title_travel,demand_uuid,look_num,title_day_name,amount,release_uuid)
  12. values (#{code},#{titleImg},#{synopsis},#{videoUrl},#{imgUrl},#{uuid},#{stateType},#{travelDate},#{travelDay},#{capita},#{figure},#{playType},#{season},#{destination},SYSDATETIME(),#{peopleAll},#{title},#{titleTravel},#{demandUuid},0,#{titleDayName},#{amount},#{releaseUuid})
  13. </insert>
  14. <!-- 查询游记内容 -->
  15. <select id="getTravel" resultType="Travel">
  16. select
  17. top ${limit} a.*,b.countNum,c.flag,d.commCount,f.name,f.headpir
  18. from
  19. bus_travel AS a
  20. LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) b ON a.uuid = b.travel_uuid
  21. LEFT JOIN ( SELECT COUNT ( * ) AS flag, travel_uuid FROM sys_travel_give WHERE code = #{code} GROUP BY travel_uuid ) c ON a.uuid = c.travel_uuid
  22. LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
  23. LEFT JOIN (SELECT headpir,name,code from sys_users) f on f.code = a.code
  24. <trim prefix="WHERE" prefixOverrides="and | or">
  25. <if test="uuid != null and uuid != ''">
  26. and a.uuid = #{uuid}
  27. </if>
  28. <if test="code != null and code != ''">
  29. and a.code = #{code}
  30. </if>
  31. <if test="stateType != null and stateType != ''">
  32. and a.state_type = #{stateType}
  33. </if>
  34. <if test="demandUuid != null and demandUuid != ''">
  35. and a.demand_uuid = #{demandUuid}
  36. </if>
  37. and a.id not in (select top ${page} id from bus_travel ) order by a.id
  38. </trim>
  39. </select>
  40. <!-- 查询游记列表内容 -->
  41. <select id="getTravelAll" resultType="Travel">
  42. SELECT TOP
  43. ${limit} e.*
  44. FROM
  45. (
  46. SELECT
  47. a.id,
  48. a.uuid,
  49. a.img_url,
  50. a.look_num,
  51. a.code,
  52. a.capita,
  53. a.jdrq,
  54. a.title_img,
  55. a.title_travel,
  56. a.travel_date,
  57. a.title_day_name,
  58. a.amount,
  59. a.people_all,
  60. a.travel_day,
  61. a.synopsis,
  62. f.name,
  63. f.headpir,
  64. b.countNum,
  65. c.flag,
  66. d.commCount,
  67. 'ptyh' as typeForm
  68. FROM
  69. bus_travel AS a
  70. LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) b ON a.uuid = b.travel_uuid
  71. LEFT JOIN ( SELECT COUNT ( * ) AS flag, travel_uuid FROM sys_travel_give WHERE code = #{code} GROUP BY travel_uuid ) c ON a.uuid = c.travel_uuid
  72. LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
  73. LEFT JOIN ( SELECT headpir, name, code FROM sys_users ) f ON f.code = a.code
  74. <trim prefix="WHERE" prefixOverrides="and | or">
  75. <if test="destination != null and destination != ''">
  76. a.destination like CONCAT(CONCAT('%', #{destination}), '%')
  77. </if>
  78. <if test="titleTravel != null and titleTravel != ''">
  79. a.title_travel like CONCAT(CONCAT('%', #{titleTravel}), '%')
  80. </if>
  81. <if test="jdrq != null and jdrq != ''">
  82. #{startTime} <![CDATA[ <= ]]> jdrq and #{endTime} <![CDATA[ > ]]> jdrq
  83. </if>
  84. </trim>
  85. UNION ALL
  86. SELECT
  87. a.id,
  88. a.uuid,
  89. a.title_img,
  90. a.look_num,
  91. a.code,
  92. (a.price_all / a.people_num) as capita,
  93. a.jdrq,
  94. a.title_img,
  95. a.offer_name as titleTravel,
  96. (a.start_time + '~' + a.end_time) as travelDate,
  97. a.title_day_name,
  98. a.price_all,
  99. a.people_num,
  100. datediff(day,a.start_time,a.end_time) as travelDay,
  101. null as synopsis,
  102. f.name,
  103. f.headpir,
  104. b.countNum,
  105. c.flag,
  106. d.commCount,
  107. 'gys' as typeForm
  108. FROM
  109. bus_supplier_route AS a
  110. LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) b ON a.uuid = b.travel_uuid
  111. LEFT JOIN ( SELECT COUNT ( * ) AS flag, travel_uuid FROM sys_travel_give WHERE code = #{code} GROUP BY travel_uuid ) c ON a.uuid = c.travel_uuid
  112. LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
  113. LEFT JOIN ( SELECT headpir, name, code FROM sys_supplier ) f ON f.code = a.code
  114. <trim prefix="WHERE" prefixOverrides="and | or">
  115. <if test="destination != null and destination != ''">
  116. a.destination like CONCAT(CONCAT('%', #{destination}), '%')
  117. </if>
  118. <if test="titleTravel != null and titleTravel != ''">
  119. a.offer_name like CONCAT(CONCAT('%', #{titleTravel}), '%')
  120. </if>
  121. <if test="jdrq != null and jdrq != ''">
  122. #{startTime} <![CDATA[ <= ]]> jdrq and #{endTime} <![CDATA[ > ]]> jdrq
  123. </if>
  124. </trim>
  125. ) e
  126. where
  127. e.id not in (
  128. select top ${page} f.id
  129. from
  130. (select id,jdrq
  131. from bus_travel
  132. <trim prefix="WHERE" prefixOverrides="and | or">
  133. <if test="destination != null and destination != ''">
  134. a.destination like CONCAT(CONCAT('%', #{destination}), '%')
  135. </if>
  136. <if test="titleTravel != null and titleTravel != ''">
  137. a.title_travel like CONCAT(CONCAT('%', #{titleTravel}), '%')
  138. </if>
  139. <if test="jdrq != null and jdrq != ''">
  140. #{startTime} <![CDATA[ <= ]]> jdrq and #{endTime} <![CDATA[ > ]]> jdrq
  141. </if>
  142. </trim>
  143. UNION ALL
  144. select
  145. id,jdrq
  146. from bus_supplier_route
  147. <trim prefix="WHERE" prefixOverrides="and | or">
  148. <if test="destination != null and destination != ''">
  149. a.destination like CONCAT(CONCAT('%', #{destination}), '%')
  150. </if>
  151. <if test="titleTravel != null and titleTravel != ''">
  152. a.offer_name like CONCAT(CONCAT('%', #{titleTravel}), '%')
  153. </if>
  154. <if test="jdrq != null and jdrq != ''">
  155. #{startTime} <![CDATA[ <= ]]> jdrq and #{endTime} <![CDATA[ > ]]> jdrq
  156. </if>
  157. </trim>
  158. ) f ORDER BY f.jdrq desc)
  159. ORDER BY
  160. e.jdrq desc
  161. </select>
  162. <!-- 查询随机一条游记 -->
  163. <select id="getTravelOne" resultType="Travel" parameterType="Travel">
  164. select
  165. top ${limit} a.*,b.countNum,c.flag,d.commCount,f.name,f.headpir
  166. from
  167. bus_travel AS a
  168. LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) b ON a.uuid = b.travel_uuid
  169. LEFT JOIN ( SELECT COUNT ( * ) AS flag, travel_uuid FROM sys_travel_give WHERE code = #{code} GROUP BY travel_uuid ) c ON a.uuid = c.travel_uuid
  170. LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
  171. LEFT JOIN (SELECT headpir,name,code from sys_users) f on f.code = a.code
  172. ORDER BY NEWID()
  173. </select>
  174. <!-- 查询游记详情 -->
  175. <select id="getTravelID" resultType="Travel">
  176. SELECT
  177. a.*,b.name,b.headpir,c.countNum,d.commCount,e.sendTravelNum,f.collectionNum,g.conllectionCount,h.flag
  178. FROM
  179. bus_travel a
  180. LEFT JOIN (SELECT headpir,name,code from sys_users) b on b.code = a.code
  181. LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) c ON a.uuid = c.travel_uuid
  182. LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
  183. LEFT JOIN ( SELECT COUNT ( * ) as sendTravelNum,code from bus_travel GROUP BY code ) e on a.code = e.code
  184. LEFT JOIN ( SELECT COUNT ( * ) as collectionNum,ordering_uuid from bus_collection where type = '1' and code = #{code} GROUP BY ordering_uuid ) f on a.uuid = f.ordering_uuid
  185. LEFT JOIN ( SELECT COUNT ( * ) as conllectionCount,ordering_uuid from bus_collection where type = '1' GROUP BY ordering_uuid ) g on a.uuid = g.ordering_uuid
  186. LEFT JOIN ( SELECT COUNT ( * ) AS flag, travel_uuid FROM sys_travel_give WHERE code = #{code} GROUP BY travel_uuid ) h ON a.uuid = h.travel_uuid
  187. WHERE
  188. a.uuid = #{uuid}
  189. </select>
  190. <!-- 查询每天游记内容 -->
  191. <select id="getTravelExper" resultType="TravelExperience">
  192. select id,uuid,day_num as dayNum,synopsis,video_url as videoUrl,img_url as imgUrl,title
  193. from bus_travel_experience
  194. where uuid = #{uuid}
  195. </select>
  196. <!-- 删除游记 -->
  197. <delete id="delTravel" parameterType="Travel">
  198. delete from bus_travel where uuid = #{uuid} and code = #{code}
  199. </delete>
  200. <!-- 删除每日游记 -->
  201. <delete id="delTravelExper">
  202. delete from bus_travel_experience
  203. <trim prefix="WHERE" prefixOverrides="and | or">
  204. <if test="uuid != null and uuid != ''">
  205. and uuid = #{uuid}
  206. </if>
  207. <if test="id != null and id != ''">
  208. and id = #{id}
  209. </if>
  210. </trim>
  211. </delete>
  212. <!-- 修改游记 -->
  213. <update id="updateTravel" parameterType="Travel">
  214. update bus_travel
  215. <set>
  216. <trim suffixOverrides=",">
  217. <if test="titleImg != null and titleImg != ''">
  218. title_img=#{titleImg},
  219. </if>
  220. <if test="synopsis != null and synopsis != ''">
  221. synopsis=#{synopsis},
  222. </if>
  223. <if test="videoUrl != null and videoUrl != ''">
  224. video_url=#{videoUrl},
  225. </if>
  226. <if test="imgUrl != null and imgUrl != ''">
  227. img_url=#{imgUrl},
  228. </if>
  229. <if test="travelDate != null and travelDate != ''">
  230. travel_date=#{travelDate},
  231. </if>
  232. <if test="travelDay != null and travelDay != ''">
  233. travel_day=#{travelDay},
  234. </if>
  235. <if test="capita != null and capita != ''">
  236. capita=#{capita},
  237. </if>
  238. <if test="figure != null and figure != ''">
  239. figure=#{figure},
  240. </if>
  241. <if test="playType != null and playType != ''">
  242. play_type=#{playType},
  243. </if>
  244. <if test="season != null and season != ''">
  245. season=#{season},
  246. </if>
  247. <if test="title != null and title != ''">
  248. title=#{title},
  249. </if>
  250. <if test="titleTravel != null and titleTravel != ''">
  251. title_travel=#{titleTravel},
  252. </if>
  253. <if test="titleDayName != null and titleDayName != ''">
  254. title_day_name=#{titleDayName},
  255. </if>
  256. </trim>
  257. </set>
  258. where uuid = #{uuid}
  259. </update>
  260. <!-- 查询是否点赞 -->
  261. <select id="getGiveCount" resultType="int">
  262. select count(*) as count from sys_travel_give where code = #{code} and travel_uuid = #{travelUuid}
  263. </select>
  264. <!-- 点赞 -->
  265. <insert id="addGive" parameterType="TravelGive">
  266. insert into sys_travel_give(code,jdrq,travel_uuid,uuid) values(#{code},format(SYSDATETIME(),'yyyy-MM-dd hh:mm:ss'),#{travelUuid},#{uuid})
  267. </insert>
  268. <!-- 取消点赞 -->
  269. <delete id="delGive" parameterType="TravelGive">
  270. delete from sys_travel_give where code = #{code} and travel_uuid=#{travelUuid}
  271. </delete>
  272. <!-- 查看数量 -->
  273. <update id="updateLookNum" parameterType="Travel">
  274. UPDATE bus_travel
  275. SET look_num = ( SELECT look_num + 1 FROM bus_travel WHERE uuid = #{uuid} )
  276. WHERE
  277. uuid = #{uuid}
  278. </update>
  279. <!-- 查询游记总数 -->
  280. <select id="getTravelCountAll" resultType="int">
  281. select count(*) as count
  282. from
  283. (
  284. select id
  285. from bus_travel
  286. <trim prefix="WHERE" prefixOverrides="and | or">
  287. <if test="stateType != null and stateType != ''">
  288. and state_type = #{stateType}
  289. </if>
  290. <if test="demandUuid != null and demandUuid != ''">
  291. and demand_uuid = #{demandUuid}
  292. </if>
  293. <if test="code != null and code != ''">
  294. and code = #{code}
  295. </if>
  296. <if test="destination != null and destination != ''">
  297. destination = #{destination}
  298. </if>
  299. </trim>
  300. UNION ALL
  301. select id
  302. FROM bus_supplier_route
  303. <trim prefix="WHERE" prefixOverrides="and | or">
  304. <if test="stateType != null and stateType != ''">
  305. and state_type = #{stateType}
  306. </if>
  307. <if test="demandUuid != null and demandUuid != ''">
  308. and demand_uuid = #{demandUuid}
  309. </if>
  310. <if test="code != null and code != ''">
  311. and code = #{code}
  312. </if>
  313. <if test="destination != null and destination != ''">
  314. destination = #{destination}
  315. </if>
  316. </trim>
  317. ) a
  318. </select>
  319. <!-- 查询游记总数个人 -->
  320. <select id="getTravelCount" resultType="int">
  321. select count(*) as count
  322. from bus_travel
  323. <trim prefix="WHERE" prefixOverrides="and | or">
  324. <if test="stateType != null and stateType != ''">
  325. and state_type = #{stateType}
  326. </if>
  327. <if test="code != null and code != ''">
  328. and code = #{code}
  329. </if>
  330. <if test="demandUuid != null and demandUuid != ''">
  331. and demand_uuid = #{demandUuid}
  332. </if>
  333. </trim>
  334. </select>
  335. <!-- 修改供应商路线查看次数 -->
  336. <update id="updateLookNumRoute" parameterType="Release">
  337. UPDATE bus_supplier_route
  338. SET look_num = ( SELECT look_num + 1 FROM bus_supplier_route WHERE uuid = #{uuid} )
  339. WHERE
  340. uuid = #{uuid}
  341. </update>
  342. <!-- 查询供应商路线详情 -->
  343. <select id="getTravelRoute" parameterType="Travel" resultType="Travel">
  344. SELECT
  345. a.id,
  346. a.code,
  347. a.title_img,
  348. null as synopsis,
  349. null as videoUrl,
  350. null as imgUrl,
  351. a.uuid,
  352. 0 as stateType,
  353. (a.start_time + '~' + a.end_time) as travelDate,
  354. datediff(day,a.start_time,a.end_time) as travelDay,
  355. (a.price_all / a.people_num) as capita,
  356. null as title,
  357. a.offer_name as titleTravel,
  358. a.uuid as demandUuid,
  359. a.jdrq,
  360. a.look_num,
  361. a.destination,
  362. b.name,
  363. b.headpir,
  364. c.countNum,
  365. d.commCount,
  366. e.sendTravelNum,
  367. f.collectionNum,
  368. g.conllectionCount,
  369. h.flag
  370. FROM
  371. bus_supplier_route a
  372. LEFT JOIN (SELECT headpir,name,code from sys_supplier) b on b.code = a.code
  373. LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) c ON a.uuid = c.travel_uuid
  374. LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
  375. LEFT JOIN ( SELECT COUNT ( * ) as sendTravelNum,code from bus_supplier_route GROUP BY code ) e on a.code = e.code
  376. LEFT JOIN ( SELECT COUNT ( * ) as collectionNum,ordering_uuid from bus_collection where type = '2' and code = #{code} GROUP BY ordering_uuid ) f on a.uuid = f.ordering_uuid
  377. LEFT JOIN ( SELECT COUNT ( * ) as conllectionCount,ordering_uuid from bus_collection where type = '2' GROUP BY ordering_uuid ) g on a.uuid = g.ordering_uuid
  378. LEFT JOIN ( SELECT COUNT ( * ) AS flag, travel_uuid FROM sys_travel_give WHERE code = #{code} GROUP BY travel_uuid ) h ON a.uuid = h.travel_uuid
  379. WHERE
  380. a.uuid = #{uuid}
  381. </select>
  382. <!-- 查询订单完成的定制单并且是没写过游记的 -->
  383. <select id="getTravelRelese" resultType="PrivateOrder">
  384. SELECT
  385. b.uuid,
  386. b.start_time,
  387. b.end_time,
  388. c.uuid AS uuidRele,
  389. c.price_all,
  390. c.title_img,
  391. c.offer_name as offerName,
  392. c.order_no AS orderNoRelease,
  393. a.order_type AS orderType,
  394. e.name AS supplieName
  395. FROM
  396. bus_private_ordering AS b
  397. LEFT JOIN bus_supplier_release c ON b.uuid = c.demand_uuid
  398. LEFT JOIN sys_supplier e ON c.code = e.code
  399. JOIN bus_private_ordering_type a ON (order_type = '4' or order_type = '5') and b.uuid = a.demand_uuid
  400. where b.code = #{code} and b.uuid not in (select demand_uuid from bus_travel where code = #{code} )
  401. </select>
  402. <!-- 查询指定定制单内容 -->
  403. <select id="getTravelVal" resultType="PrivateOrder">
  404. SELECT
  405. b.*,
  406. a.price_all
  407. FROM
  408. bus_supplier_release a
  409. LEFT JOIN bus_private_ordering b on a.demand_uuid = b.uuid
  410. WHERE
  411. a.uuid = #{id}
  412. </select>
  413. </mapper>