Helius
2021-06-16 4e51778362c2130598a4c73ec4cebe6629dbc53f
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
<?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.pay.mapper.PayRequestMapper">
 
    <select id="selectByPayType" resultType="com.xzx.gc.entity.PayRequestInfo">
        SELECT
            a.create_user_id "createUserId",
            a.money,
            a.pay_order_id "payOrderId",
            a.create_time "createTime",
            a.`status`,
            a.update_time "examineTime",
            a.pay_type "payType",
            d.`name` "auditer",
            a.unpass_reason "unpassReason",
            b.NAME "userName",
            b.mobile_phone "mobilePhone",
            IFNULL(c.new_limit,0)  "fixedLimit",
            (cast(IFNULL(c.new_fixed_limit,0) as decimal(9,2))-cast(IFNULL(c.new_limit,0) as decimal(9,2))) as  "overdraftLimit",
            a.open_id "openId"
        FROM
            xzx_pay_request_info a
            left join xzx_account_log c on a.pay_order_id=c.order_id
            LEFT JOIN xzx_user_other_info b ON a.create_user_id = b.user_id
            LEFT JOIN xzx_user_other_info d ON a.update_user_id = d.user_id
        WHERE
            a.pay_type = #{payType} and b.partner_id=#{partnerId}
            <if test="keyword != null and keyword != ''">
                and (b.name like concat('%',#{keyword} ,'%') or b.mobile_phone like concat('%',#{keyword},'%') )
            </if>
            <!--<if test="userIds != null and userIds.size()>0">-->
                <!--and a.create_user_id in-->
                <!--<foreach collection="userIds" item="id" index="index" open="(" close=")" separator=",">-->
                    <!--#{id}-->
                <!--</foreach>-->
            <!--</if>-->
        ORDER BY
            a.create_time DESC,
            a.`status` ASC
    </select>
 
    <select id="selectByArea" resultType="com.xzx.gc.entity.UserInfo">
        SELECT
            a.create_user_id "userId",
            b.nick_name "nickName",
            b.mobile_phone "mobilePhone",
        1 as "userType",
            sum( cast( IFNULL(a.money,0) AS DECIMAL ( 9, 2 ) ) )  as withdrawalMoney
        FROM
            xzx_pay_request_info a
            inner JOIN xzx_user_info b ON a.create_user_id = b.user_id AND b.del_flag = 0 and b.is_prohibit=0
            LEFT JOIN xzx_user_address_info c on b.user_id=c.user_id
                                                 and c.del_flag=0 and c.flag='1'
        WHERE
            a.pay_type = '4'
            AND a.`status` = '2'  and a.money>0
        <if test="cityId != null and cityId != ''">
            and c.city_id=#{cityId}
        </if>
 
        <if test="mobile != null and mobile != ''">
            and b.mobile_phone like  concat('%',#{mobile} ,'%')
        </if>
 
        <if test="provinceId != null and provinceId != ''">
              and c.province_id=#{provinceId}
        </if>
 
        <if test="townShipId != null and townShipId != ''">
            and c.township_id=#{townShipId}
        </if>
 
        <if test="startDate != null and startDate != ''">
            and a.update_time<![CDATA[>= ]]>#{startDate}
        </if>
 
        <if test="endDate != null and endDate != ''">
            and a.update_time &lt;=#{endDate}
        </if>
 
        GROUP BY
        a.create_user_id
 
 
        union ALL
 
        SELECT
        a.create_user_id "userId",
        b.name "nickName",
        b.mobile_phone "mobilePhone",
        2 as "userType",
        sum( cast( IFNULL(a.money,0) AS DECIMAL ( 9, 2 ) ) )  as withdrawalMoney
        FROM
        xzx_pay_request_info a
        inner JOIN xzx_user_other_info b ON a.create_user_id = b.user_id AND b.del_flag = 0 and b.is_prohibit=0
        LEFT JOIN xzx_user_address_info c on b.user_id=c.user_id
        and c.del_flag=0 and c.flag='1'
        WHERE
        a.pay_type = '4'
        AND a.`status` = '2'  and a.money>0
        <if test="cityId != null and cityId != ''">
            and c.city_id=#{cityId}
        </if>
 
        <if test="mobile != null and mobile != ''">
            and b.mobile_phone like  concat('%',#{mobile} ,'%')
        </if>
 
        <if test="provinceId != null and provinceId != ''">
            and c.province_id=#{provinceId}
        </if>
 
        <if test="townShipId != null and townShipId != ''">
            and c.township_id=#{townShipId}
        </if>
 
        <if test="startDate != null and startDate != ''">
            and a.update_time<![CDATA[>= ]]>#{startDate}
        </if>
 
        <if test="endDate != null and endDate != ''">
            and a.update_time &lt;=#{endDate}
        </if>
 
        GROUP BY
        a.create_user_id
 
 
        ORDER BY withdrawalMoney desc
    </select>
 
 
    <update id="updateMoney" parameterType="com.xzx.gc.model.admin.MoneyModel">
        UPDATE `xzx_pay_request_info`
        <set>
            <if test="status!= null and status!=''">
                status=#{status},
            </if>
            <if test="payFlag!= null and payFlag != ''">
                pay_flag=#{payFlag},
            </if>
            <if test="unpassReason!= null and unpassReason != ''">
                unpass_reason=#{unpassReason},
            </if>
            <if test="updateTime!= null">
                update_time=#{updateTime},
            </if>
            <if test="updateUserId!= null">
                update_user_id=#{updateUserId},
            </if>
        </set>
        WHERE pay_order_id =#{payOrderId}
    </update>
 
    <select id="queryMoney" resultType="com.xzx.gc.model.admin.MoneyModel">
        SELECT * FROM xzx_pay_request_info a where 1=1
        <if test="payOrderId!= null and payOrderId != ''">
            and a.pay_order_id=#{payOrderId}
        </if>
    </select>
 
    <select id="queryMoneyList" resultType="com.xzx.gc.model.admin.MoneyModel">
        SELECT a.pay_order_id,a.create_time,a.money,a.unpass_reason,a.pay_flag, a.wxpay_flag,a.examine_time,
        b.mobile_phone,b.nick_name,b.user_type,c.order_status,a.examine_time,a.`status`,a.pay_type
        FROM xzx_pay_request_info a
        LEFT JOIN xzx_user_info b ON a.create_user_id = b.user_id
        LEFT JOIN xzx_order_info c ON a.order_id = c.order_id
        where 1=1
        <if test="status!= null and status!=''">
            and a.status=#{status}
        </if>
        <if test="nickName!= null and nickName!=''">
            and b.nick_name=#{nickName}
        </if>
        <if test="mobilePhone!= null and mobilePhone!=''">
            and b.mobile_phone=#{mobilePhone}
        </if>
        <if test="payType!= null and payType!=''">
            and a.pay_type=#{payType}
        </if>
        group by a.create_time desc
    </select>
 
    <select id="queryOtherMoneyList" resultType="com.xzx.gc.model.admin.MoneyModel">
        SELECT a.pay_order_id,a.create_time,a.money,a.unpass_reason,a.pay_flag, a.wxpay_flag,a.examine_time,
        b.mobile_phone,b.nick_name,b.user_type,c.order_status,a.examine_time,a.`status`,a.pay_type,a.create_user_id
        FROM xzx_pay_request_info a
        LEFT JOIN xzx_user_other_info b ON a.create_user_id = b.user_id
        LEFT JOIN xzx_order_info c ON a.order_id = c.order_id
        where 1=1
        <if test="status!= null and status!=''">
            and a.status=#{status}
        </if>
        <if test="nickName!= null and nickName!=''">
            and b.nick_name=#{nickName}
        </if>
        <if test="mobilePhone!= null and mobilePhone!=''">
            and b.mobile_phone=#{mobilePhone}
        </if>
        <if test="payType!= null and payType!=''">
            and a.pay_type=#{payType}
        </if>
        group by a.create_time desc
    </select>
 
 
    <insert id="addReason">
        update `xzx_pay_request_info` set status=3,unpass_reason=#{reason} where pay_order_id=#{payOrderId}
    </insert>
 
    <select id="queryPayInfoDetail" resultType="java.util.Map">
    select a.*,b.nick_name as nickName ,
    b.user_type as userType,
    b.avatar as avatar,
    b.mobile_phone as mobilePhone
    from xzx_pay_request_info a,xzx_user_info b   where a.pay_order_id=#{payOrderId} and a.create_user_id = b.user_id
    </select>
 
    <update id="updateMoneyApi" parameterType="com.xzx.gc.model.admin.MoneyModel">
        UPDATE xzx_pay_request_info SET pay_flag=#{payFlag},unpass_reason=#{unpassReason},update_time=SYSDATE()
        WHERE pay_order_id = #{payOrderId}
    </update>
 
    <select id="queryMoneyList2" parameterType="com.xzx.gc.model.admin.MoneyModel"
            resultType="com.xzx.gc.model.admin.MoneyModel">
        SELECT a.pay_order_id,a.create_time,a.money,a.unpass_reason,a.pay_flag,
        a.wxpay_flag,a.examine_time,a.update_time,
        a.update_user_id,(select k.name from core_user k where k.id=a.update_user_id) as updateUserName,
        b.mobile_phone,IFNULL(b.nick_name,f.name) as
        nickName,b.user_type,c.order_status,c.order_id,a.`status`,a.pay_type,a.create_user_id ,
        IFNULL((select d.role_name from xzx_user_role_info d where d.role_code= f.user_type and d.del_flag=0),'普通用户') as
        roleName,
        IFNULL(f.user_type,b.user_type) as userType,
        f.del_flag as delFlag
        FROM xzx_pay_request_info a
        LEFT JOIN xzx_user_info b ON a.create_user_id = b.user_id
        LEFT JOIN xzx_order_info c ON a.order_id = c.order_id
        LEFT JOIN xzx_user_other_info f ON a.create_user_id = f.user_id
        where 1=1
        <if test="status!= null and status!=''">
            and a.status=#{status}
        </if>
        <if test="nickName!= null  and nickName!=''">
            and (b.nick_name=#{nickName} or f.name=#{name})
        </if>
        <if test="mobilePhone!= null  and mobilePhone!=''">
            and b.mobile_phone=#{mobilePhone}
        </if>
        <if test="payType!= null and payType!=''">
            and a.pay_type=#{payType}
        </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 f.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        group by a.pay_order_id
        order by a.create_time desc
 
    </select>
 
    <select id="queryPayOrderIds" resultType="java.lang.String">
        SELECT a.pay_order_id
        FROM xzx_pay_request_info a
        LEFT JOIN xzx_user_info b ON a.create_user_id = b.user_id
        LEFT JOIN xzx_user_other_info f ON a.create_user_id = f.user_id
        where 1=1
        <if test="status!= null and status!=''">
            and a.status=#{status}
        </if>
        <if test="nickName!= null  and nickName!=''">
            and (b.nick_name=#{nickName} or f.name=#{name})
        </if>
        <if test="mobilePhone!= null  and mobilePhone!=''">
            and b.mobile_phone=#{mobilePhone}
        </if>
        <if test="payType!= null and payType!=''">
            and a.pay_type=#{payType}
        </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 f.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        group by a.pay_order_id
        order by a.create_time desc
    </select>
 
    <select id="queryMoneyTodayList" parameterType="com.xzx.gc.model.admin.MoneyModel"
            resultType="java.lang.String">
        SELECT IFNULL(sum(c.money),0)
        FROM xzx_pay_request_info c
        LEFT JOIN xzx_pay_request_info a ON a.pay_order_id=c.pay_order_id
        LEFT JOIN xzx_user_info b ON a.create_user_id = b.user_id
        LEFT JOIN xzx_user_other_info f ON a.create_user_id = f.user_id
        where 1=1 and c.pay_type=4
        <if test="status!= null and status!=''">
            and a.status=#{status}
        </if>
        <if test="nickName!= null  and nickName!=''">
            and (b.nick_name=#{nickName} or f.name=#{name})
        </if>
        <if test="mobilePhone!= null  and mobilePhone!=''">
            and b.mobile_phone=#{mobilePhone}
        </if>
        <if test="payType!= null and payType!=''">
            and a.pay_type=#{payType}
        </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 f.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
 
    <select id="queryPayInfoDetailHS" resultType="java.util.HashMap">
        select a.*,b.nick_name as nickName ,
                   b.user_type as userType,
                   b.avatar as avatar,
                   a.create_user_id as createUserId,
                   b.mobile_phone as mobilePhone
        from xzx_pay_request_info a,xzx_user_other_info b
        where a.pay_order_id=#{payOrderId} and a.create_user_id = b.user_id
    </select>
 
    <insert id="insertPayRequestInfo">
        INSERT INTO `xzx_pay_request_info`
        (`pay_order_id`, `order_id`, `create_user_id`, `money`, `account_id`, `pay_type`,
         `open_id`, `status`, `create_time`,
         `wxpay_flag`, `pay_flag`, `unpass_reason`, `examine_time`, `account_bind_id`,
         `update_time`, `update_user_id`)
        VALUES (#{payOrderId},#{orderId},#{createUserId},#{money},#{accountId},#{payType},
                              #{openId},#{status},#{createTime},#{wxpayFlag},#{payFlag},
                #{unpassReason},#{examineTime},#{accountBindId},#{updateTime},#{updateUserId})
 
    </insert>
 
    <select id="queryDetailsPresentation" resultType="com.xzx.gc.model.admin.PartnerPayMsgModel">
        select x.flowNo,x.payName,x.payTime,x.money,x.partnerName,x.payStatus,x.mobilePhone,x.partnerType,x.delFlag from (
        select a.pay_order_id as flowNo,'充值' as payName,a.create_time as payTime,a.money as money,b.partner_name as
        partnerName,b.del_flag as delFlag,
        a.status as payStatus,b.mobile_phone as mobilePhone,b.partner_type as partnerType
        from xzx_pay_info a
        LEFT JOIN xzx_city_partner b ON a.create_user_id = b.user_id
        where 1=1 and a.pay_type=1 and b.user_id is not null
 
        <if test="userId != null and userId != ''">
            and a.create_user_id =#{userId}
        </if>
 
        <if test="payType != null and payType != ''">
            and a.pay_type = #{payType}
        </if>
 
        <if test="payStatus != null and payStatus != ''">
            and a.status = #{payStatus}
        </if>
 
        <if test="startTime != null and startTime != ''">
            and a.create_time >= #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            and a.create_time &lt;= #{endTime}
        </if>
 
        <if test="name != null and name != ''">
            and (b.partner_name like concat("%",#{name} ,"%") or b.mobile_phone like concat("%",#{name} ,"%"))
        </if>
 
        <if test=" partnerIds != null and partnerIds.size() != 0">
            and b.id in
            <foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")" >
                #{id}
            </foreach>
        </if>
 
        UNION ALL
        select c.pay_order_id as flowNo,'提现' as payName,c.create_time as payTime,c.money as money,d.partner_name as
        partnerName,d.del_flag as delFlag,
        c.status as payStatus,d.mobile_phone as mobilePhone,d.partner_type as partnerType
        from xzx_pay_request_info c
        LEFT JOIN xzx_city_partner d ON c.create_user_id=d.user_id
        where 1=1 and c.pay_type=4 and d.user_id is not null
 
        <if test="userId != null and userId != ''">
            and c.create_user_id =#{userId}
        </if>
 
        <if test="payType != null and payType != ''">
            and c.pay_type = #{payType}
        </if>
 
        <if test="payStatus != null and payStatus != ''">
            and c.status = #{payStatus}
        </if>
 
        <if test="startTime != null and startTime != ''">
            and c.create_time >= #{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            and c.create_time &lt;= #{endTime}
        </if>
 
        <if test="name != null and name != ''">
            and (d.partner_name like concat("%",#{name} ,"%") or d.mobile_phone like concat("%",#{name} ,"%"))
        </if>
 
        <if test=" partnerIds != null and partnerIds.size() != 0">
            and d.id in
            <foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
 
        ) x order by x.payTime desc
    </select>
 
    <select id="rkMessage" resultType="com.xzx.gc.model.pay.RkLimitDto">
        select * from (SELECT
                           '额度恢复' AS "title",
                           create_time "createTime",
                           pay_type AS "msgType",
                           STATUS,
                           unpass_reason "reason",
                           money
                       FROM
                           xzx_pay_request_info
                       WHERE
                           pay_type = '9'
                           AND create_user_id = #{userId}  UNION ALL
                       SELECT
                           '额度支出' AS "title",
                           create_time "createTime",
                           pay_type AS "msgType",
                           STATUS,
                           '' as reason,
                           money
                       FROM
                           xzx_pay_info
                       WHERE
                           (pay_type = '2' or pay_type='6')
                           AND create_user_id = #{userId}) a order by a.createTime desc
    </select>
 
</mapper>