| <?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.UserMapper"> | 
|     <resultMap id="AccountMap" type="com.xzx.gc.model.user.AccountVo"> | 
|         <result column="account_id" jdbcType="VARCHAR" property="accountId"/> | 
|         <result column="account_name" jdbcType="VARCHAR" property="accountName"/> | 
|         <result column="user_id" jdbcType="VARCHAR" property="userId"/> | 
|         <result column="pay_password" jdbcType="VARCHAR" property="payPassword"/> | 
|         <result column="freeze_money" jdbcType="VARCHAR" property="freezeMoney"/> | 
|         <result column="withdraw_money" jdbcType="VARCHAR" property="withdrawMoney"/> | 
|         <result column="overdraft_limit" jdbcType="VARCHAR" property="overdraftLimit"/> | 
|         <result column="lock_time" jdbcType="VARCHAR" property="lockTime"/> | 
|         <result column="error_times" jdbcType="INTEGER" property="errorTimes"/> | 
|         <result column="last_error_time" jdbcType="VARCHAR" property="lastErrorTime"/> | 
|         <result column="collect_score" jdbcType="VARCHAR" property="collectScore"/> | 
|     </resultMap> | 
|   | 
|     <resultMap id="UserInfoMap" type="com.xzx.gc.model.user.UserInfoVo"> | 
|         <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | 
|         <result column="user_type" jdbcType="VARCHAR" property="userType"/> | 
|         <result column="user_id" jdbcType="VARCHAR" property="userId"/> | 
|         <result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone"/> | 
|     </resultMap> | 
|   | 
|   | 
|     <!-- 一个openid只能对应一个手机号码(同一微信用户只能绑定一个手机号码)--> | 
|     <select id="isUniqueByMobilePhone" parameterType="java.util.Map" resultType="String"> | 
|         select distinct mobile_phone from xzx_user_info | 
|         where open_id = #{openId} and del_flag=0 and is_prohibit=0 | 
|     </select> | 
|   | 
|     <!-- 查询我的环保金 --> | 
|     <select id="queryMyMoney" parameterType="map" resultMap="AccountMap"> | 
|         SELECT a.user_id,a.account_name,a.freeze_money,a.money,a.pay_password, | 
|         a.withdraw_money,a.overdraft_limit,a.lock_time,a.collect_score | 
|         FROM xzx_account_info a | 
|         where del_flag=0 and is_prohibit='0' | 
|         <if test="userId!=null and userId!=''"> | 
|             and a.user_id=#{userId} | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="queryMyMoneyWithStatus" parameterType="map" resultMap="AccountMap"> | 
|         SELECT a.user_id,a.account_name,a.freeze_money,a.money,a.pay_password, | 
|         a.withdraw_money,a.overdraft_limit,a.lock_time,a.collect_score | 
|         FROM xzx_account_info a | 
|         where del_flag=0 | 
|         <if test="userId!=null and userId!=''"> | 
|             and a.user_id=#{userId} | 
|         </if> | 
|     </select> | 
|   | 
|   | 
|     <!-- 查询用户信息 --> | 
|     <select id="queryUserInfo" parameterType="map" resultMap="UserInfoMap"> | 
|         select d.user_id,d.mobile_phone,d.avatar,d.nick_name,d.sex,d.birthday,d.user_type,d.latitude,d.longitude | 
|         from xzx_user_info d | 
|         where d.del_flag=0 and d.is_prohibit=0 | 
|         <if test="mobilePhone != null and mobilePhone != ''"> | 
|            and d.mobile_phone=#{mobilePhone} | 
|         </if> | 
|         <if test="userId!=null and userId!=''"> | 
|             and d.user_id=#{userId} | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="queryUserInfoByUserId" parameterType="string" resultMap="UserInfoMap"> | 
|         select d.user_id,d.mobile_phone,d.avatar,d.nick_name,d.sex,d.birthday,d.user_type,d.latitude,d.longitude | 
|         from xzx_user_info d | 
|         where d.del_flag=0 | 
|             and d.user_id=#{userId} | 
|     </select> | 
|   | 
|     <!-- 根据手机号查询用户信息 --> | 
|     <!--<select id="findUserByMobile"   resultMap="UserInfoMap">--> | 
|         <!--select d.user_id--> | 
|         <!--from xzx_user_info d--> | 
|         <!--where d.mobile_phone=#{mobilePhone}--> | 
|         <!--and d.user_type = '2'--> | 
|     <!--</select>--> | 
|     <!-- 查询账户信息 --> | 
|     <select id="queryAccountInfo" parameterType="map" resultMap="AccountMap"> | 
|         select account_id,account_name,user_id,money,freeze_money, | 
|         withdraw_money,overdraft_limit,lock_time,error_times | 
|         from xzx_account_info | 
|         where user_id=#{userId} and del_flag=0 | 
|         <if test="payPassword!=null and payPassword!=''"> | 
|             and pay_password=#{payPassword} | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 新建修改支付密码 --> | 
|     <update id="modifyPayPassword" parameterType="map"> | 
|         update xzx_account_info set pay_password=#{payPassword} | 
|         where user_id=#{userId} and del_flag=0 | 
|     </update> | 
|   | 
|     <!-- 查询是否被锁定 --> | 
|     <select id="queryIsLock"   resultMap="AccountMap"> | 
|         select | 
|             error_times, | 
|             lock_time, | 
|             last_error_time | 
|         from | 
|             xzx_account_info | 
|         where user_id=#{userId,jdbcType=BIGINT} and del_flag=0 | 
|     </select> | 
|   | 
|   | 
|     <!-- 错误数+1 --> | 
|     <update id="setLock" parameterType="com.xzx.gc.model.user.AccountReq"> | 
|         update | 
|             xzx_account_info | 
|         <set> | 
|             <if test="errorTimes != null"> | 
|                 error_times = #{errorTimes}, | 
|             </if> | 
|             <if test="lockTime != null"> | 
|                 lock_time = #{lockTime}, | 
|             </if> | 
|             <if test="lastErrorTime != null"> | 
|                 last_error_time = #{lastErrorTime}, | 
|             </if> | 
|         </set> | 
|         where | 
|             user_id=#{userId}  and del_flag=0 | 
|     </update> | 
|     <select id="findByMobileTest" resultType="com.xzx.gc.entity.UserInfo"> | 
|         select user_id "userId",avatar,mobile_phone "mobilePhone" from  xzx_user_info_bak | 
|         where  mobile_phone=#{mobilePhone}  and del_flag=0 and is_prohibit=0 | 
|     </select> | 
|     <select id="findByOneAddr" resultType="com.xzx.gc.entity.UserInfo"> | 
|         SELECT | 
|         a.user_id "userId", | 
|         a.mobile_phone "mobilePhone", | 
|         a.nick_name "nickName", | 
|           b.rela_name "userName", | 
|           b.address_area "addressArea", | 
|           b.detail_address "detailAddress", | 
|           IFNULL( b.latitude, a.latitude ) "latitude", | 
|           IFNULL( b.longitude, a.longitude ) "longitude" | 
|         FROM | 
|         xzx_user_info a | 
|         LEFT JOIN xzx_user_address_info b ON a.user_id = b.user_id  AND b.flag = 1 AND b.del_flag = 0 | 
|         WHERE | 
|             a.del_flag = 0 | 
|             AND a.is_prohibit = 0 | 
|     </select> | 
|   | 
|     <select id="findByDistance" resultType="com.xzx.gc.entity.UserInfo"> | 
|         SELECT | 
|             a.user_id "userId", | 
|             a.mobile_phone "mobilePhone", | 
|             IFNULL( b.latitude, a.latitude ) "latitude", | 
|             IFNULL( b.longitude, a.longitude ) "longitude", | 
|             b.address_id "addressId", | 
|             IFNULL(b.rela_name,from_base64(a.nick_name)) "userName", | 
|             b.detail_address "detailAddress", | 
|             b.address_area "addressArea", | 
|             b.township_id "townShipId", | 
|             a.partner_id "partnerId" | 
|         FROM | 
|             xzx_user_info a | 
|             LEFT JOIN xzx_user_address_info b ON a.user_id = b.user_id | 
|                                                  AND b.del_flag = 0 | 
|                                                  AND b.flag = '1' | 
|         WHERE a.del_flag=0 | 
|         order by a.user_id desc | 
|   | 
|   | 
|     </select> | 
|     <select id="findOtherAll" resultType="com.xzx.gc.model.user.UserDTO"> | 
|         select * from ( | 
|   | 
|                           SELECT | 
|                               user_id "userId", | 
|                               from_base64 ( nick_name ) "name", | 
|                               mobile_phone "mobilePhone", | 
|                               user_type "userType" | 
|                           FROM | 
|                               xzx_user_info | 
|                           union | 
|                           SELECT | 
|                               user_id "userId", | 
|                               `name`, | 
|                               mobile_phone "mobilePhone", | 
|                               user_type "userType" | 
|                           FROM | 
|                               xzx_user_other_info) t WHERE 1=1 | 
|         <if test="keyword != null and keyword != ''"> | 
|             and  locate(#{keyword},t.name)>0  or  locate(#{keyword},t.mobilePhone)>0 | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="queryCuserForTimeList" resultType="com.xzx.gc.model.admin.UserModel"> | 
|         SELECT | 
|         a.regist_time, | 
|         a.nick_name, | 
|         a.mobile_phone, | 
|         a.user_id, | 
|         a.user_type AS user_typex, | 
|         a.is_prohibit AS isProhibit, | 
|         a.avatar AS avatar, | 
|         a.partner_id AS partnerId, | 
|         '普通用户' AS user_type | 
|         FROM xzx_user_info a | 
|         where a.del_flag=0 and a.user_type=1 | 
|         <if test="partnerId != null and partnerId != ''"> | 
|             AND locate(${partnerId},a.partner_id)>0 | 
|         </if> | 
|         <if test="startTime != null and startTime != ''"> | 
|             AND a.regist_time<![CDATA[>= ]]>#{startTime} | 
|         </if> | 
|         <if test="phone != null and phone != ''"> | 
|             AND a.mobile_phone=#{phone} | 
|         </if> | 
|         <if test="endTime != null and endTime != ''"> | 
|             AND a.regist_time<![CDATA[<= ]]>#{endTime} | 
|         </if> | 
|         <if test="isProhibit != null and isProhibit != ''"> | 
|             AND a.is_prohibit=false | 
|         </if> | 
|         order by a.regist_time desc | 
|     </select> | 
|   | 
|     <select id="queryCuserForTimeListCount" resultType="java.lang.Integer"> | 
|         SELECT | 
|         count(*) | 
|         FROM xzx_user_info a | 
|         LEFT JOIN xzx_sys_config_info b ON a.user_type = b.config_value | 
|         AND b.config_type_code = 'USER_TYPE' | 
|         where a.del_flag=0 | 
|         <if test="partnerId != null and partnerId != ''"> | 
|             AND locate(${partnerId},a.partner_id)>0 | 
|         </if> | 
|         <if test="startTime != null and startTime != ''"> | 
|             AND a.regist_time<![CDATA[>= ]]>#{startTime} | 
|         </if> | 
|         <if test="phone != null and phone != ''"> | 
|             AND a.mobile_phone=#{phone} | 
|         </if> | 
|         <if test="endTime != null and endTime != ''"> | 
|             AND a.regist_time<![CDATA[<= ]]>#{endTime} | 
|         </if> | 
|         order by a.regist_time desc | 
|     </select> | 
|   | 
|     <update id="UpdateUserApiByUserId"> | 
|         update xzx_user_info set is_prohibit=#{flag} where user_id=#{userId} | 
|     </update> | 
|   | 
|     <select id="queryCuserDetail" resultType="java.util.HashMap"> | 
|         SELECT e.mobile_phone tgrPhone,a.*, b.money,b.collect_score collectScore, b.withdraw_money, c.pay_type, SUM(c.money) as moneyx FROM xzx_user_info a | 
|             LEFT JOIN xzx_account_info b ON a.user_id=b.user_id | 
|             LEFT JOIN xzx_pay_info c ON b.account_id=c.account_id | 
|             LEFT JOIN xzx_sys_config_info d ON c.pay_type=d.config_value AND d.config_type_code='PAY_TYPE' | 
|             LEFT JOIN xzx_user_share_info e ON e.register_mobile_phone=a.mobile_phone | 
|         WHERE a.mobile_phone=#{phone} AND a.user_type=#{userType} AND a.del_flag=0 GROUP BY c.pay_type | 
|     </select> | 
|   | 
|     <update id="updateUserName"> | 
|         update xzx_user_info set name=#{name} where mobile_phone=#{mobile} | 
|     </update> | 
|   | 
|     <select id="queryUserByUsertype" resultType="com.xzx.gc.model.admin.UserModel"> | 
|         select * from xzx_user_info | 
|         where 1=1 | 
|         <if test="delFlag != null"> | 
|             and del_flag=#{delFlag} | 
|         </if> | 
|         <if test="phone != null and phone != ''"> | 
|             and (mobile_phone like concat("%",#{phone},"%") or nick_name =#{nickName}) | 
|         </if> | 
|         <if test="userType != null and userType != ''"> | 
|             and user_type=#{userType} | 
|         </if> | 
|         <if test="normal != null"> | 
|             and regist_type=3 | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="queryAllUserByPid" resultType="com.xzx.gc.model.admin.UserModel"> | 
|         select b.* from xzx_user_info b | 
|         where b.del_flag=0 | 
|         <if test="userName != null and userName != ''"> | 
|             and (b.name like concat("%",#{userName} ,"%") or b.mobile_phone like concat("%",#{userName} ,"%")) | 
|         </if> | 
|         <if test="roleType != null and roleType != ''"> | 
|             AND b.user_type =#{roleType} | 
|         </if> | 
|         <!--<if test="townIds != null and townIds.size() != 0">--> | 
|         <!--AND c.township_id in--> | 
|         <!--<foreach collection="townIds" index="index" item="id" separator="," open="(" close=")">--> | 
|         <!--#{id}--> | 
|         <!--</foreach>--> | 
|         <!--</if>--> | 
|         <if test="partnerId != null and partnerId != ''"> | 
|             and LOCATE(#{partnerId} ,b.partner_id)>0 | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="queryUserById" resultType="com.xzx.gc.model.admin.UserModel"> | 
|         select * from xzx_user_info where del_flag = 0 | 
|         <if test="userId != null and userId != ''"> | 
|             and user_id=#{userId} | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="tgmxInfo" resultType="com.xzx.gc.user.vo.TgmxInfoListVo"> | 
|         SELECT | 
|             a.mobile_phone yqrPhone, | 
|             from_base64(b.nick_name) yqrName, | 
|             from_base64(c.nick_name) zcName, | 
|             a.register_mobile_phone zcPhone, | 
|             a.register_time zcDate | 
|         FROM xzx_user_share_info a | 
|         LEFT JOIN xzx_user_info b ON a.mobile_phone=b.mobile_phone | 
|         LEFT JOIN xzx_user_info c ON a.register_mobile_phone=c.mobile_phone | 
|         <where> | 
|             1=1 | 
|             <if test="record.yqrName != null and record.yqrName != ''"> | 
|                 and from_base64(b.nick_name) like concat('%',#{record.yqrName},'%') | 
|             </if> | 
|             <if test="record.zcName != null and record.zcName != ''"> | 
|                 and from_base64(c.nick_name) like concat('%',#{record.zcName},'%') | 
|             </if> | 
|             <if test="record.phone != null and record.phone != ''"> | 
|                 and (a.register_mobile_phone like concat('%',#{record.phone},'%') | 
|                     or a.mobile_phone like concat('%',#{record.phone},'%')) | 
|             </if> | 
|         </where> | 
|         order by a.register_time desc | 
|     </select> | 
| </mapper> |