xiaoyong931011
2021-07-21 1d03a9e224dc0ce11d47bede74da9db2189d663c
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?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.xzx.gc.user.mapper.PartnerGaodeMapper">
  <resultMap id="BaseResultMap" type="com.xzx.gc.entity.PartnerGaode">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="partner_id" jdbcType="VARCHAR" property="partnerId" />
    <result column="partner_key" jdbcType="VARCHAR" property="partnerKey" />
    <result column="town_id" jdbcType="VARCHAR" property="townId" />
    <result column="city_id" jdbcType="VARCHAR" property="cityId" />
    <result column="create_time" jdbcType="VARCHAR" property="createTime" />
    <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
    <result column="update_time" jdbcType="VARCHAR" property="updateTime" />
  </resultMap>
 
    <select id="queryAreaByParentner" resultType="com.xzx.gc.model.admin.AreaModel">
        select b.level_1_name as provinceName,b.level_2_name as cityName,b.level_3_name as townName,a.town_id as townId
        from xzx_partner_gaode a
        LEFT JOIN xzx_sys_address_level_info b on a.town_id = b.level_3_id
        where 1=1 and partner_id!=partner_key and del_flag=0
        <if test="partnerId != null and partnerId != ''">
            and a.partner_id= #{partnerId}
        </if>
    </select>
 
    <insert id="insertGaodeInfo">
        insert xzx_partner_gaode (partner_id,partner_key,
        town_id,create_time,del_flag,city_id,address_area) values
 
        <foreach collection="gaodeModels" index="index" item="info" separator=",">
 
            <trim prefix="(" suffix=")" suffixOverrides=",">
                #{info.partnerId},#{info.partnerKey},#{info.townId},#{info.createTime},#{info.delFlag},#{info.cityId},#{info.addressArea}
            </trim>
        </foreach>
    </insert>
 
    <delete id="deletePartnerTownCode">
        update xzx_partner_gaode
        set del_flag = 1
        where partner_id = #{partnerId}
    </delete>
 
    <select id="queryPartnerGaode" resultType="int">
        select count(a.id) from xzx_partner_gaode a
        left join xzx_sys_address_level_info b on a.town_id =b.level_3_id
        where level_3_name in
        <foreach collection="areaList" index="index" item="id" separator="," open="(" close=")">
            #{id}
        </foreach>
        and a.del_flag=0
    </select>
 
    <select id="queryGaodeByParentner" resultType="java.lang.String">
        select city_id
        from xzx_partner_gaode
        where del_flag = 0 and partner_id = #{partnerId} and partner_id != partner_key
        group by city_id
    </select>
 
    <select id="queryGaodeAreaByPackageId" resultType="com.xzx.gc.model.admin.PartnerGaodeModel">
        select *
        from xzx_partner_gaode
        where partner_id = #{partnerId} and del_flag = 0
    </select>
 
    <select id="queryCitysByPartnerId" resultType="java.lang.String">
        select city_id
        from xzx_partner_gaode
        where del_flag = 0 and partner_id = #{pid}
        group by city_id
    </select>
 
    <select id="queryTownIdsByPartnerId" resultType="java.lang.String">
        select town_id
        from xzx_partner_gaode
        where del_flag = 0 and partner_id = #{partnerId}
    </select>
 
    <select id="queryGaodeByCid" resultType="map">
        select b.level_2_id as code,b.level_2_name as value from xzx_partner_gaode a
        left join xzx_sys_address_level_info b on a.town_id=b.level_3_id
        where a.del_flag=0  and partner_id<![CDATA[<> ]]>partner_key and a.town_id is not null and b.level_1_id = #{pid}
        <if test="id != null and id != ''">
            and a.partner_id=#{id}
        </if>
        group by b.level_2_id
    </select>
 
    <select id="queryGaodeByTid" resultType="map">
        select b.level_3_id as code,b.level_3_name as value from xzx_partner_gaode a
        left join xzx_sys_address_level_info b on a.town_id=b.level_3_id
        where a.del_flag=0 and partner_id<![CDATA[<> ]]>partner_key and a.town_id is not null and b.level_2_id = #{cid}
        <if test="id != null and id != ''">
            and a.partner_id=#{id}
        </if>
    </select>
 
    <select id="queryPartnerCityById" resultType="map">
        select b.level_1_id as pId,b.level_1_name as pName,b.level_2_id as cId,b.level_2_name as cName,a.town_id as
        cityId,b.level_3_name as cityName from xzx_partner_gaode a
        left join xzx_sys_address_level_info b on a.town_id=b.level_3_id
        where a.del_flag=0 and partner_id!=partner_key and a.town_id is not null
        <if test="id != null and id != ''">
            and a.partner_id=#{id}
        </if>
    </select>
 
    <select id="queryPidBypartnerId" resultType="map">
        select b.level_1_id as code,b.level_1_name as value from xzx_partner_gaode a
        left join xzx_sys_address_level_info b on a.town_id=b.level_3_id
        where a.del_flag=0 and partner_id<![CDATA[<> ]]>partner_key and a.town_id is not null
        <if test="id != null and id != ''">
            and a.partner_id=#{id}
        </if>
        group by b.level_1_id
    </select>
</mapper>