2025-01-18 19:05:51 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
|
|
|
|
|
|
<mapper namespace="com.central.order.mapper.TourismMapper">
|
|
|
|
|
|
|
|
|
|
<select id="findList" resultType="com.central.order.model.Tourism">
|
2025-10-01 03:51:53 +08:00
|
|
|
SELECT *
|
|
|
|
|
FROM tourisms t
|
|
|
|
|
<where>
|
|
|
|
|
<if test="p.tenantIds != null and p.tenantIds.size > 0">
|
|
|
|
|
AND t.tenant_id IN
|
|
|
|
|
<foreach collection="p.tenantIds" item="tid" open="(" separator="," close=")">
|
|
|
|
|
#{tid}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="(p.tenantIds == null or p.tenantIds.size == 0) and p.tenantId != null and p.tenantId != ''">
|
|
|
|
|
AND t.tenant_id = #{p.tenantId}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
ORDER BY t.id DESC
|
2025-01-18 19:05:51 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<resultMap id="TourismResultMap" type="com.central.order.model.Tourism">
|
|
|
|
|
</resultMap>
|
|
|
|
|
<select id="getTourismById" resultMap="TourismResultMap">
|
|
|
|
|
SELECT * FROM tourisms WHERE id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<insert id="insertTourism">
|
|
|
|
|
INSERT INTO tourisms (tourism_no, tourism_name, tourism_address,tourism_phone)
|
|
|
|
|
VALUES (#{tourismNo}, #{tourismName}, #{tourismAddress},#{tourismPhone})
|
|
|
|
|
</insert>
|
2025-07-21 10:29:00 +08:00
|
|
|
|
|
|
|
|
<!-- 获取景区设备列表 -->
|
|
|
|
|
<select id="getDevicesByTourismId" resultType="java.util.Map">
|
|
|
|
|
SELECT DISTINCT
|
|
|
|
|
q.device_sn as deviceSn,
|
|
|
|
|
q.name as qrcodeName,
|
|
|
|
|
q.code_id as qrcodeId,
|
|
|
|
|
q.price as qrcodePrice,
|
|
|
|
|
q.status as qrcodeStatus,
|
|
|
|
|
q.create_time as qrcodeCreateTime,
|
|
|
|
|
t.tourism_name as tourismName,
|
|
|
|
|
t.tourism_address as tourismAddress
|
|
|
|
|
FROM qrcodes q
|
|
|
|
|
LEFT JOIN tourisms t ON q.tourism_id = t.id
|
|
|
|
|
WHERE q.tourism_id = #{tourismId}
|
|
|
|
|
AND q.is_del = 0
|
|
|
|
|
AND t.is_del = 0
|
|
|
|
|
ORDER BY q.create_time DESC
|
|
|
|
|
</select>
|
2025-07-29 12:08:44 +08:00
|
|
|
|
|
|
|
|
<!-- 查询附近景区列表 -->
|
|
|
|
|
<select id="findNearbyTourisms" resultType="com.central.order.model.TourismWithDistance">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
SELECT
|
|
|
|
|
*,
|
|
|
|
|
(
|
|
|
|
|
6371 * acos(
|
|
|
|
|
cos(radians(#{latitude})) *
|
|
|
|
|
cos(radians(latitude)) *
|
|
|
|
|
cos(radians(longitude) - radians(#{longitude})) +
|
|
|
|
|
sin(radians(#{latitude})) *
|
|
|
|
|
sin(radians(latitude))
|
|
|
|
|
)
|
|
|
|
|
) AS distance
|
|
|
|
|
FROM tourisms
|
|
|
|
|
WHERE is_del = 0
|
|
|
|
|
AND status = 1
|
|
|
|
|
AND longitude IS NOT NULL
|
|
|
|
|
AND latitude IS NOT NULL
|
2025-08-14 20:17:29 +08:00
|
|
|
]]>
|
|
|
|
|
<choose>
|
|
|
|
|
<when test="showInHomepage != null">
|
|
|
|
|
<if test="showInHomepage == 1">
|
|
|
|
|
AND (show_in_homepage = 1 OR show_in_homepage IS NULL)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="showInHomepage == 0">
|
|
|
|
|
AND show_in_homepage = 0
|
|
|
|
|
</if>
|
|
|
|
|
</when>
|
|
|
|
|
<otherwise>
|
|
|
|
|
AND (show_in_homepage = 1 OR show_in_homepage IS NULL)
|
|
|
|
|
</otherwise>
|
|
|
|
|
</choose>
|
|
|
|
|
<![CDATA[
|
2025-07-29 12:08:44 +08:00
|
|
|
HAVING distance <= #{radius}
|
|
|
|
|
ORDER BY distance ASC
|
|
|
|
|
]]>
|
|
|
|
|
<if test="limit != null and limit > 0">
|
|
|
|
|
LIMIT #{limit}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!-- 根据经纬度范围查询景区 -->
|
|
|
|
|
<select id="findTourismsByBounds" resultType="com.central.order.model.Tourism">
|
|
|
|
|
SELECT * FROM tourisms
|
|
|
|
|
WHERE is_del = 0
|
|
|
|
|
AND status = 1
|
|
|
|
|
AND longitude BETWEEN #{minLongitude} AND #{maxLongitude}
|
|
|
|
|
AND latitude BETWEEN #{minLatitude} AND #{maxLatitude}
|
|
|
|
|
ORDER BY create_time DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
2025-10-01 03:51:53 +08:00
|
|
|
<!-- 根据租户ID集合查询景区ID集合 -->
|
|
|
|
|
<select id="findTourismIdsByTenantIds" resultType="java.lang.Long">
|
|
|
|
|
SELECT id FROM tourisms
|
|
|
|
|
WHERE is_del = 0
|
|
|
|
|
<if test="tenantIds != null and tenantIds.size > 0">
|
|
|
|
|
AND tenant_id IN
|
|
|
|
|
<foreach collection="tenantIds" item="tid" open="(" separator="," close=")">
|
|
|
|
|
#{tid}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
ORDER BY id DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
2025-01-18 19:05:51 +08:00
|
|
|
</mapper>
|