Helius
2022-02-21 f54f8a92c09a2cd76b3bbb796df680215b63ab8a
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<?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>