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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?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.UserTargetInfoMapper">
  <resultMap id="BaseResultMap" type="com.xzx.gc.entity.UserTargetInfo">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
    <result column="user_name" jdbcType="VARCHAR" property="userName" />
    <result column="regster_type" jdbcType="INTEGER" property="regsterType" />
    <result column="mobile" jdbcType="VARCHAR" property="mobile" />
    <result column="address_remark" jdbcType="VARCHAR" property="addressRemark" />
    <result column="disc" jdbcType="VARCHAR" property="disc" />
    <result column="user_id" jdbcType="VARCHAR" property="userId" />
    <result column="real_user_id" jdbcType="VARCHAR" property="realUserId" />
    <result column="create_time" jdbcType="VARCHAR" property="createTime" />
    <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
    <result column="user_image" jdbcType="VARCHAR" property="userImage" />
    <result column="province_id" jdbcType="VARCHAR" property="provinceId" />
    <result column="city_id" jdbcType="VARCHAR" property="cityId" />
    <result column="township_id" jdbcType="VARCHAR" property="townshipId" />
    <result column="address_area" jdbcType="VARCHAR" property="addressArea" />
    <result column="detail_address" jdbcType="VARCHAR" property="detailAddress" />
    <result column="lay_floor" jdbcType="VARCHAR" property="layFloor" />
    <result column="longitude" jdbcType="VARCHAR" property="longitude" />
    <result column="latitude" jdbcType="VARCHAR" property="latitude" />
    <result column="stair_type" jdbcType="VARCHAR" property="stairType" />
    <result column="top_flag" jdbcType="SMALLINT" property="topFlag" />
    <result column="top_flag_user" jdbcType="SMALLINT" property="topFlagUser" />
  </resultMap>
  <sql id="Base_Column_List">
    id, nick_name, user_name, regster_type, mobile, address_remark, disc, user_id, create_time,
    del_flag, user_image, province_id, city_id, township_id, address_area, detail_address, 
    lay_floor, longitude, latitude,stair_type,real_user_id
  </sql>
  <select id="find" resultMap="BaseResultMap" >
      select DISTINCT t.id,t.user_image,t.user_name,t.mobile,t.create_time ,t.regster_type ,t.address_remark ,t.detail_address,t.longitude,t.latitude,t.nick_name,t.disc,t.real_user_id ,t.user_id   from  xzx_user_target_info t
    left join  xzx_user_info u on t.mobile=u.mobile_phone and u.del_flag=0 and u.is_prohibit=0
    where 1=1
    <if test="userId != null and userId != ''">
      and t.user_id=#{userId}
    </if>
 
    <if test="searchName != null and searchName != ''">
        and (t.mobile like concat("%",#{searchName},"%") or t.detail_address  like concat("%",#{searchName},"%") or t.address_remark  like concat("%",#{searchName},"%"))
    </if>
    <if test="status!=null and status != ''">
            and t.regster_type=#{status}
    </if>
    order by  t.create_time desc
  </select>
 
  <select id="findPage" resultMap="BaseResultMap" >
    SELECT DISTINCT
    t.id,
    t.user_image,
    t.user_name,
    t.mobile,
    t.create_time,
    t.regster_type,
    t.address_remark,
    t.address_area,
    t.detail_address,
    t.longitude,
    t.latitude,
    t.nick_name,
    t.disc,
    t.real_user_id,
    t.user_id,
    t.top_flag,
    t.top_flag_user,
    ROUND(lat_lng_distance(#{latitude}, #{longitude}, t.latitude, t.longitude), 3) as distance
    FROM
    xzx_user_target_info t
    inner join xzx_user_other_info b on (t.user_id=b.user_id or t.real_user_id=b.user_id)
    WHERE t.del_flag=0 and b.partner_id=#{partnerId}
 
    <if test="userId != null and userId != ''">
      and (t.user_id=#{userId} or t.real_user_id=#{userId} )
    </if>
 
    <if test="searchName != null and searchName != ''">
      and (t.mobile like concat("%",#{searchName},"%") or t.user_name  like concat("%",#{searchName},"%") or from_base64(t.nick_name)  like concat("%",#{searchName},"%"))
    </if>
 
    <choose>
      <when test="orderType != null and orderType != ''">
        <choose>
          <when test="orderType==1">
            order by   t.create_time desc
          </when>
          <when test="orderType==2">
            order by   t.user_name asc
          </when>
          <when test="orderType==3">
            order by  distance asc
          </when>
          <when test="orderType==4">
            order by  t.regster_type desc
          </when>
        </choose>
      </when>
      <otherwise>
        order by   t.create_time desc
      </otherwise>
    </choose>
 
  </select>
 
 
  <select id="recommend" resultMap="BaseResultMap">
    SELECT DISTINCT
    t.id,
    t.user_image,
    t.user_name,
    t.mobile,
    t.create_time,
    t.regster_type,
    t.address_remark,
    t.address_area,
    t.detail_address,
    t.longitude,
    t.latitude,
    t.nick_name,
    t.disc,
    t.real_user_id,
    t.user_id,
    t.top_flag,
    t.top_flag_user
    FROM
    xzx_user_target_info t
    inner join xzx_user_other_info b on (t.user_id=b.user_id or t.real_user_id=b.user_id)
    WHERE t.del_flag=0 and b.partner_id=#{partnerId}
    and t.regster_type=3
    <if test="userId != null and userId != ''">
      and t.real_user_id=#{userId}
    </if>
    order by  t.create_time desc
  </select>
    <select id="queryList" resultType="com.xzx.gc.model.admin.TargetUserModel">
        SELECT y.id, y.nick_name,y.user_name, y.mobile, y.regster_type, y.promoterName,y.promoter,y.real_user_id,
                    y.create_time, y.detail_address, y.address_remark, y.disc,x.regist_time, y.latitude, y.longitude,
                    IFNULL(z.latitude, 0) AS latitudex, IFNULL(z.longitude, 0) AS longitudex
               FROM
             (
                select a.*,b.nick_name as promoterName,t.nick_name as promoter from xzx_user_target_info a
                left join xzx_user_other_info b on a.real_user_id = b.user_id
                left join xzx_user_other_info t on t.user_id = a.user_id
                where a.del_flag = 0
                    <if test="regsterType != null and regsterType != ''">
                      AND a.regster_type in (#{regsterType},#{regsterType1})
                    </if>
                  <if test="nickName != null and nickName != ''">
                      AND a.nick_name like concat('%',#{nickName} ,'%')
                  </if>
                  <if test="mobile != null and mobile != ''">
                    AND a.mobile like concat('%',#{mobile} ,'%')
                  </if>
                  <if test="promoterName != null and promoterName != ''">
                    AND b.name like concat('%',#{promoterName} ,'%')
                  </if>
                  <if test="promoter != null and promoter != ''">
                    AND t.name like concat('%',#{promoter} ,'%')
                  </if>
            ) y
            LEFT JOIN xzx_user_info x ON x.mobile_phone = y.mobile
            LEFT JOIN xzx_user_address_info z ON y.mobile = z.mobile_phone AND z.flag = 1 AND z.del_flag=0
            <if test="startTime != null and startTime != ''">
                      where x.regist_time BETWEEN #{startTime} AND #{endTime}
            </if>
            GROUP BY y.id
    </select>
 
  <select id="queryUser" resultType="com.xzx.gc.model.admin.TargetUserModel">
         SELECT a.mobile_phone as mobile, a.nick_name as nickName,
          b.order_id as orderId, c.longitude as longitudex, c.latitude as latitudex FROM xzx_user_info a
          LEFT JOIN xzx_order_info b on a.user_id = b.create_user_id
          LEFT JOIN xzx_user_address_info c ON a.user_id=c.user_id
          WHERE a.del_flag=0 GROUP BY a.mobile_phone
  </select>
 
  <select id="queryTgNameByRealUserId"   resultType="java.lang.String">
    select b.name from xzx_user_target_info a
      left join xzx_user_other_info b on a.real_user_id=b.user_id
    where a.mobile=#{mobilePhone} and b.user_type=6 and b.del_flag=0
  </select>
 
  <select id="queryTgNameByUserId"   resultType="java.lang.String">
    select b.name from xzx_user_target_info a
      left join xzx_user_other_info b on a.user_id=b.user_id
    where a.mobile=#{mobilePhone} and b.user_type=6 and b.del_flag=0
  </select>
 
    <update id="UpdateUserApiByTargetUserId">
        update xzx_user_target_info set is_prohibit=#{flag} where user_id=#{userId}
    </update>
 
    <select id="queryUnregisteredApiList" parameterType="com.xzx.gc.model.admin.CollectorModel"
            resultType="com.xzx.gc.model.admin.CollectorModel">
        select a.township_id as area,b.del_flag as delFlag,
        (select level_3_name from xzx_sys_address_level_info where level_3_id=a.township_id) as areaName ,
        a.mobile as mobilePhone,a.create_time as createTime,
        a.user_name as name,a.nick_name as nickName,
        b.name as tgyName,
        a.address_remark as address,
        (select c.partner_name from xzx_city_partner c where c.id=b.partner_id) as partnerName
        from xzx_user_target_info a
        left join xzx_user_other_info b on b.user_id=a.user_id
        where a.real_user_id is null
        <if test="area != null and area != ''">
            AND a.township_id=#{area}
        </if>
        <if test="startTime != null and startTime != ''">
            AND a.create_time<![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND a.create_time<![CDATA[<= ]]>#{endTime}
        </if>
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND b.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        group by a.mobile
        order by a.create_time desc
    </select>
</mapper>