| <?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> |