liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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.xiaopeng.account.mapper.XpAppUserCollectAddrMapper">
 
    <select id="userCollectAddrPageList" resultType="com.xiaopeng.account.model.vo.XpAppUserCollectAddrVO">
        select
            c.id,
            c.item_type as itemType,
            c.longitude,
            c.latitude,
            c.point_id as pointId,
            c.station_id as stationId,
            c.item_type = 2
        from xp_app_user_collect_addr c
        where c.app_user_id = #{uid}
          and c.is_deleted = 0
        order by c.create_time desc
    </select>
 
    <select id="selectPointCollectTarget" resultType="com.xiaopeng.account.model.vo.CollectAddrTargetVO">
        select
            1 as itemType,
            p.id as pointId,
            p.station_id as stationId,
            p.point_lon as longitude,
            p.point_lat as latitude
        from xp_point p
        inner join xp_electronic_fence_area a on a.id = p.electronic_area_id
        where p.is_deleted = 0
          and p.point_type = 1
          and p.operation_status = 2
          and a.is_deleted = 0
          and a.area_status = 1
          and p.id = #{pointId}
    </select>
 
    <select id="selectStationCollectTarget" resultType="com.xiaopeng.account.model.vo.CollectAddrTargetVO">
        select
            2 as itemType,
            coalesce(dp.id, fp.id) as pointId,
            s.id as stationId,
            coalesce(s.center_lon, dp.point_lon, fp.point_lon) as longitude,
            coalesce(s.center_lat, dp.point_lat, fp.point_lat) as latitude
        from xp_station s
        inner join xp_electronic_fence_area a on a.id = s.electronic_area_id
        left join xp_point dp on dp.id = s.default_point_id
            and dp.is_deleted = 0
            and dp.point_type = 1
            and dp.operation_status = 2
        left join xp_point fp on fp.id = (
            select p1.id
            from xp_point p1
            where p1.station_id = s.id
              and p1.is_deleted = 0
              and p1.point_type = 1
              and p1.operation_status = 2
            order by case when s.default_point_id is not null and p1.id = s.default_point_id then 0 else 1 end,
                     p1.station_sort_no asc,
                     p1.id asc
            limit 1
        )
        where s.is_deleted = 0
          and s.status = 6
          and a.is_deleted = 0
          and a.area_status = 1
          and s.id = #{stationId}
          and coalesce(dp.id, fp.id) is not null
    </select>
</mapper>