insert into bus_travel_experience(uuid,day_num,synopsis,video_url,img_url,title) values(#{uuid},#{dayNum},#{synopsis},#{videoUrl},#{imgUrl},#{title})
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)
values (#{code},#{titleImg},#{synopsis},#{videoUrl},#{imgUrl},#{uuid},#{stateType},#{travelDate},#{travelDay},#{capita},#{figure},#{playType},#{season},#{destination},SYSDATETIME(),#{peopleAll},#{title},#{titleTravel},#{demandUuid},0,#{titleDayName},#{amount},#{releaseUuid})
select
top ${limit} a.*,b.countNum,c.flag,d.commCount,f.name,f.headpir
from
bus_travel AS a
LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) b ON a.uuid = b.travel_uuid
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
LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
LEFT JOIN (SELECT headpir,name,code from sys_users) f on f.code = a.code
and a.uuid = #{uuid}
and a.code = #{code}
and a.state_type = #{stateType}
and a.demand_uuid = #{demandUuid}
and a.id not in (select top ${page} id from bus_travel ) order by a.id
SELECT TOP
${limit} e.*
FROM
(
SELECT
a.id,
a.uuid,
a.img_url,
a.look_num,
a.code,
a.capita,
a.jdrq,
a.title_img,
a.title_travel,
a.travel_date,
a.title_day_name,
a.amount,
a.people_all,
a.travel_day,
a.synopsis,
f.name,
f.headpir,
b.countNum,
c.flag,
d.commCount,
'ptyh' as typeForm
FROM
bus_travel AS a
LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) b ON a.uuid = b.travel_uuid
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
LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
LEFT JOIN ( SELECT headpir, name, code FROM sys_users ) f ON f.code = a.code
a.destination like CONCAT(CONCAT('%', #{destination}), '%')
a.title_travel like CONCAT(CONCAT('%', #{titleTravel}), '%')
#{startTime} jdrq and #{endTime} ]]> jdrq
UNION ALL
SELECT
a.id,
a.uuid,
a.title_img,
a.look_num,
a.code,
(a.price_all / a.people_num) as capita,
a.jdrq,
a.title_img,
a.offer_name as titleTravel,
(a.start_time + '~' + a.end_time) as travelDate,
a.title_day_name,
a.price_all,
a.people_num,
datediff(day,a.start_time,a.end_time) as travelDay,
null as synopsis,
f.name,
f.headpir,
b.countNum,
c.flag,
d.commCount,
'gys' as typeForm
FROM
bus_supplier_route AS a
LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) b ON a.uuid = b.travel_uuid
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
LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
LEFT JOIN ( SELECT headpir, name, code FROM sys_supplier ) f ON f.code = a.code
a.destination like CONCAT(CONCAT('%', #{destination}), '%')
a.offer_name like CONCAT(CONCAT('%', #{titleTravel}), '%')
#{startTime} jdrq and #{endTime} ]]> jdrq
) e
where
e.id not in (
select top ${page} f.id
from
(select id,jdrq
from bus_travel
a.destination like CONCAT(CONCAT('%', #{destination}), '%')
a.title_travel like CONCAT(CONCAT('%', #{titleTravel}), '%')
#{startTime} jdrq and #{endTime} ]]> jdrq
UNION ALL
select
id,jdrq
from bus_supplier_route
a.destination like CONCAT(CONCAT('%', #{destination}), '%')
a.offer_name like CONCAT(CONCAT('%', #{titleTravel}), '%')
#{startTime} jdrq and #{endTime} ]]> jdrq
) f ORDER BY f.jdrq desc)
ORDER BY
e.jdrq desc
select
top ${limit} a.*,b.countNum,c.flag,d.commCount,f.name,f.headpir
from
bus_travel AS a
LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) b ON a.uuid = b.travel_uuid
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
LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
LEFT JOIN (SELECT headpir,name,code from sys_users) f on f.code = a.code
ORDER BY NEWID()
SELECT
a.*,b.name,b.headpir,c.countNum,d.commCount,e.sendTravelNum,f.collectionNum,g.conllectionCount,h.flag
FROM
bus_travel a
LEFT JOIN (SELECT headpir,name,code from sys_users) b on b.code = a.code
LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) c ON a.uuid = c.travel_uuid
LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
LEFT JOIN ( SELECT COUNT ( * ) as sendTravelNum,code from bus_travel GROUP BY code ) e on a.code = e.code
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
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
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
WHERE
a.uuid = #{uuid}
select id,uuid,day_num as dayNum,synopsis,video_url as videoUrl,img_url as imgUrl,title
from bus_travel_experience
where uuid = #{uuid}
delete from bus_travel where uuid = #{uuid} and code = #{code}
delete from bus_travel_experience
and uuid = #{uuid}
and id = #{id}
update bus_travel
title_img=#{titleImg},
synopsis=#{synopsis},
video_url=#{videoUrl},
img_url=#{imgUrl},
travel_date=#{travelDate},
travel_day=#{travelDay},
capita=#{capita},
figure=#{figure},
play_type=#{playType},
season=#{season},
title=#{title},
title_travel=#{titleTravel},
title_day_name=#{titleDayName},
where uuid = #{uuid}
select count(*) as count from sys_travel_give where code = #{code} and travel_uuid = #{travelUuid}
insert into sys_travel_give(code,jdrq,travel_uuid,uuid) values(#{code},format(SYSDATETIME(),'yyyy-MM-dd hh:mm:ss'),#{travelUuid},#{uuid})
delete from sys_travel_give where code = #{code} and travel_uuid=#{travelUuid}
UPDATE bus_travel
SET look_num = ( SELECT look_num + 1 FROM bus_travel WHERE uuid = #{uuid} )
WHERE
uuid = #{uuid}
select count(*) as count
from
(
select id
from bus_travel
and state_type = #{stateType}
and demand_uuid = #{demandUuid}
and code = #{code}
destination = #{destination}
UNION ALL
select id
FROM bus_supplier_route
and state_type = #{stateType}
and demand_uuid = #{demandUuid}
and code = #{code}
destination = #{destination}
) a
select count(*) as count
from bus_travel
and state_type = #{stateType}
and code = #{code}
and demand_uuid = #{demandUuid}
UPDATE bus_supplier_route
SET look_num = ( SELECT look_num + 1 FROM bus_supplier_route WHERE uuid = #{uuid} )
WHERE
uuid = #{uuid}
SELECT
a.id,
a.code,
a.title_img,
null as synopsis,
null as videoUrl,
null as imgUrl,
a.uuid,
0 as stateType,
(a.start_time + '~' + a.end_time) as travelDate,
datediff(day,a.start_time,a.end_time) as travelDay,
(a.price_all / a.people_num) as capita,
null as title,
a.offer_name as titleTravel,
a.uuid as demandUuid,
a.jdrq,
a.look_num,
a.destination,
b.name,
b.headpir,
c.countNum,
d.commCount,
e.sendTravelNum,
f.collectionNum,
g.conllectionCount,
h.flag
FROM
bus_supplier_route a
LEFT JOIN (SELECT headpir,name,code from sys_supplier) b on b.code = a.code
LEFT JOIN ( SELECT COUNT ( * ) AS countNum, travel_uuid FROM sys_travel_give GROUP BY travel_uuid ) c ON a.uuid = c.travel_uuid
LEFT JOIN ( SELECT COUNT ( * ) AS commCount, travel_uuid FROM bus_travel_comments GROUP BY travel_uuid ) d ON a.uuid = d.travel_uuid
LEFT JOIN ( SELECT COUNT ( * ) as sendTravelNum,code from bus_supplier_route GROUP BY code ) e on a.code = e.code
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
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
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
WHERE
a.uuid = #{uuid}
SELECT
b.uuid,
b.start_time,
b.end_time,
c.uuid AS uuidRele,
c.price_all,
c.title_img,
c.offer_name as offerName,
c.order_no AS orderNoRelease,
a.order_type AS orderType,
e.name AS supplieName
FROM
bus_private_ordering AS b
LEFT JOIN bus_supplier_release c ON b.uuid = c.demand_uuid
LEFT JOIN sys_supplier e ON c.code = e.code
JOIN bus_private_ordering_type a ON (order_type = '4' or order_type = '5') and b.uuid = a.demand_uuid
where b.code = #{code} and b.uuid not in (select demand_uuid from bus_travel where code = #{code} )
SELECT
b.*,
a.price_all
FROM
bus_supplier_release a
LEFT JOIN bus_private_ordering b on a.demand_uuid = b.uuid
WHERE
a.uuid = #{id}