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
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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
<?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.OtherUserMapper">
 
    <select id="queryRKOrderIds" resultType="java.lang.String">
        select a.user_id from xzx_user_other_info a
        LEFT JOIN xzx_account_info b on a.user_id=b.user_id
        where 1=1
        <choose>
            <when test="type != null and type != ''">
                and a.user_type=2
            </when>
            <when test="type == null or type == ''">
                and a.user_type=4
            </when>
        </choose>
 
        <if test="limitPrice != null and limitPrice != ''">
            and b.fixed_limit=#{limitPrice}
        </if>
    </select>
 
    <update id="UpdateUserApiByOtherUserId">
        update xzx_user_other_info set is_prohibit=#{flag} where user_id=#{userId} and user_type=#{userType}
    </update>
 
    <select id="queryPromoterApiList" resultType="com.xzx.gc.model.admin.UserModel">
        select IFNULL(a.nick_name,k.nick_name) as nickName,c.mobile_phone as mobilePhone,a.user_id as
        userId,c.is_prohibit,c.avatar as avatar,
        c.regist_time as registTime,c.name,
        c.partner_id as partnerId,
        (select m.partner_name from xzx_city_partner m where m.id=c.partner_id) as partnerName,
        count(a.id) as registNum,count(f.id) as finishNum,count(j.id) as unRegistNum,IFNULL(c.del_flag,0) as delFlag
        from xzx_user_other_info c
        LEFT JOIN xzx_user_target_info a ON a.user_id=c.user_id
        LEFT JOIN xzx_user_target_info d ON a.id=d.id and d.regster_type>1
        LEFT JOIN xzx_user_target_info f ON a.id=f.id and f.regster_type=3
        LEFT JOIN xzx_user_target_info j ON a.id=j.id and j.regster_type=1
        LEFT JOIN xzx_user_info k ON a.mobile=k.mobile_phone
        where (c.user_type=6 or c.user_type=2)
        <if test=" phone!= null and phone != ''">
            AND c.mobile_phone=#{phone}
        </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="isProhibit != null and isProhibit != ''">
            AND a.is_prohibit=false
        </if>
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND c.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        group by c.user_id
    </select>
 
    <select id="queryCollectorApiList" parameterType="com.xzx.gc.model.admin.CollectorModel"
            resultType="com.xzx.gc.model.admin.CollectorModel">
        select a.name as name,a.town_id as townId,a.nick_name as nickName,a.mobile_phone as mobilePhone,a.avatar as
        avatar,a.user_id as userId,a.del_flag as delFlag,
        (select m.partner_name from xzx_city_partner m where a.partner_id=m.id) as partnerName,
        (select count(b.order_id) from xzx_order_info b where 1=1
        <if test=" userType != null and userType != ''">
            and b.receiver=a.user_id
        </if>
        ) as orderNum,
        (select g.sys_storage_id from xzx_order_storage_info g where 1=1
        <if test="userType != null and userType != ''">
            <if test="userType==2">
                and g.receiver=a.user_id
            </if>
            <if test="userType==4">
                and g.storage_user_id=a.user_id
            </if>
            <if test="userType==7">
                and g.storage_user_id=a.user_id
            </if>
        </if>
        limit 1) as sysStorageId,
        (select sum(c.storage_weight) from xzx_order_storage_info c where 1=1
        <if test="userType != null and userType != ''">
            <if test="userType==2">
                and c.receiver=a.user_id
            </if>
            <if test="userType==4">
                and c.storage_user_id=a.user_id
            </if>
            <if test="userType==7">
                and c.storage_user_id=a.user_id
            </if>
        </if>
        )as storageWeight,
        (select sum(d.storage_money) from xzx_order_storage_info d where 1=1
        <if test=" userType != null and userType != ''">
            <if test="userType==2">
                and d.receiver=a.user_id
            </if>
            <if test=" userType==4">
                and d.storage_user_id=a.user_id
            </if>
            <if test="userType==7">
                and d.storage_user_id=a.user_id
            </if>
        </if>
        ) as storageMoney,
        a.is_prohibit as isProhibit,
        IFNULL(a.regist_time,(select f.regist_time
        from xzx_user_info f
        where f.user_id=a.user_id)) as registTime,
        (select j.login_time from xzx_user_login_info j where j.mobile_phone=a.mobile_phone
        <if test=" userType!= null and userType != ''">
            and j.user_type=#{userType}
        </if>
        group by j.mobile_phone order by login_time desc) as loginTime
        from xzx_user_other_info a
        where 1=1
        <if test="userType != null and userType != ''">
            AND a.user_type=#{userType}
        </if>
        <if test="startTime != null and startTime != ''">
            AND IFNULL(a.regist_time,(select f.regist_time
            from xzx_user_info f
            where f.user_id=a.user_id))<![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND IFNULL(a.regist_time,(select f.regist_time
            from xzx_user_info f
            where f.user_id=a.user_id))<![CDATA[<= ]]>#{endTime}
        </if>
        <if test="mobilePhone != null and mobilePhone != ''">
            AND a.mobile_phone=#{mobilePhone}
        </if>
        <if test="area != null and area != ''">
            AND a.township_id=#{area}
        </if>
        <if test="isProhibit != null and isProhibit != ''">
            AND a.is_prohibit=#{isProhibit}
        </if>
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND a.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        order by a.user_id desc
    </select>
 
    <update id="updateOtherUserByPhone">
        update xzx_user_other_info set password=#{password},salt=#{salt} where mobile_phone=#{phone}
    </update>
 
    <update id="updateOtherUserName">
        update xzx_user_other_info set name=#{name} where mobile_phone=#{mobile}
    </update>
 
    <select id="queryCuserByPhoneRedisDelList" resultType="java.util.HashMap">
        SELECT user_id AS userId FROM xzx_user_other_info WHERE del_flag=0
        <if test="phone != null and phone != ''">
            AND mobile_phone=#{phone}
        </if>
    </select>
 
    <select id="queryUserByUsertype1" resultType="com.xzx.gc.model.admin.UserModel">
        select * from xzx_user_other_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>
 
    <update id="updateDelflag">
        update xzx_user_other_info set del_flag = 0
        <if test="password != null">
            ,password=#{password}
        </if>
        <if test="salt != null">
            ,salt = #{salt}
        </if>
        <if test="area != null and area != ''">
            ,town_id=#{area}
        </if>
        <if test="name != null">
            ,name=#{name}
        </if>
        <if test="roleId != null">
            ,role_ids=#{roleId}
        </if>
        <if test="partnerId!= null and partnerId != ''">
            ,partner_id=#{partnerId}
        </if>
        <if test="cityId != null">
            ,city_id=#{cityId}
        </if>
        <if test="storageId != null">
            ,storage_id=#{storageId}
        </if>
        <if test="provinceId != null and provinceId != ''">
            , province_id=#{provinceId}
        </if>
        <if test="townshipId != null and townshipId != ''">
            , township_id=#{townshipId}
        </if>
        <if test="province != null and province != ''">
            ,province=#{province}
        </if>
        <if test="city != null and city != ''">
            ,city=#{city}
        </if>
        <if test="township != null and township != ''">
            ,township=#{township}
        </if>
        where mobile_phone=#{phone}
        <if test="userType != null and userType != ''">
            and user_type=#{userType}
        </if>
    </update>
 
    <insert id="addCuserRole">
        INSERT INTO xzx_user_other_info (
            user_id,
            mobile_phone,
            `password`,
            salt,
            `name`,
            user_type,
            regist_time,
            town_id,
            partner_id,
            role_ids,
            avatar,
            city_id,
            storage_id,
            township_id,
            province_id,
            province,
            city,
            township
        )
        values
            (#{id},#{mobilephone},#{password},#{salt},#{name},#{userType},SYSDATE(),#{area},#{partnerId},#{roleId},'https://res.cnxzx.com/resource/static/img/icon-loadlogo.png',#{cityId},#{storageId},#{townshipId} ,#{provinceId},#{province} ,#{city} ,#{township} )
    </insert>
 
    <select id="checkOtherUserByType" resultType="com.xzx.gc.model.admin.UserModel">
        select * from xzx_user_other_info where del_flag=0
        <if test="userType != null and userType != ''">
            and user_type=#{userType}
        </if>
        <if test="mobilePhone != null and mobilePhone != ''">
            and mobile_phone=#{mobilePhone}
        </if>
    </select>
 
    <select id="queryQromoterLeven" resultType="com.xzx.gc.model.admin.PromoterModel">
        SELECT
        IFNULL( k.regist_type, 0 ) AS regsterType,
        c.partner_id AS partnerId,
        ( SELECT n.partner_name FROM xzx_city_partner n WHERE c.partner_id = n.id ) AS partnerName,
        IFNULL( m.registCount, 0 ) AS registCount,
        IFNULL( m.count, 0 ) AS count,
        IFNULL( m.totalNum, 0 ) AS totalNum,
        c.nick_name,
        c.mobile_phone,
        c.user_id,
        c.regist_time,
        IFNULL( c.NAME, '-' ) AS NAME,
        c.del_flag AS delFlag
        FROM
        xzx_user_other_info c
        LEFT JOIN (
        SELECT
        count( a.id ) AS totalNum,
        count( f.id ) AS count,
        count( j.id ) AS registCount,
        a.real_user_id,
        a.mobile
        FROM
        xzx_user_target_info a
        LEFT JOIN xzx_user_target_info f ON a.id = f.id
        AND f.regster_type = 3
        LEFT JOIN xzx_user_target_info j ON a.id = j.id
        AND j.regster_type = 2
        LEFT JOIN xzx_user_other_info l ON a.real_user_id = l.user_id
        <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>
        group by l.user_id
        ) m ON m.real_user_id=c.user_id
        LEFT JOIN xzx_user_info k ON m.mobile=k.mobile_phone
 
        where 1=1
        <if test="delFlag != null and delFlag != ''">
            and c.del_flag=#{delFlag}
        </if>
        <if test="userId != null and userId != ''">
            AND c.user_id=#{userId}
        </if>
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND c.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <if test="nickName != null and nickName != ''">
            AND c.nick_name like concat("%",#{nickName},"%")
        </if>
        <if test="mobilePhone != null and mobilePhone != ''">
            AND c.mobile_phone like concat("%",#{mobilePhone},"%")
        </if>
        <if test="name != null and name != ''">
            AND c.name like concat("%",#{name},"%")
        </if>
        <if test="paramName != null and paramName != ''">
            AND (c.name like concat("%",#{paramName},"%") or c.mobile_phone like concat("%",#{paramName},"%") )
        </if>
        group by c.user_id
        <if test="exp != null and exp != ''">
            limit #{page}, #{limit}
        </if>
    </select>
 
    <select id="queryCollectorNum" parameterType="java.util.List" resultType="java.lang.String">
        select user_id from xzx_user_other_info
        where user_type=2
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
 
    <select id="queryCollectorPageList" resultType="com.xzx.gc.model.admin.UserModel">
        select b.user_id as userId,
        b.mobile_phone as mobilePhone,
        (select c.partner_name from xzx_city_partner c where c.id=b.partner_id) as partnerName,
        IFNULL(sum(a.storage_weight),0) as storageWeight,
        IFNULL(sum(a.storage_money),0) as storageMoney,
        IFNULL(sum(a.recycle_weight),0) as recycleWeight,
        IFNULL(sum(a.recycle_money),0) as recycleMoney,
        (IFNULL(sum(a.storage_weight),0) - IFNULL(sum(a.recycle_weight),0)) as weightError,
        (IFNULL(sum(a.storage_money),0) - IFNULL(sum(a.recycle_money),0)) as moneyError,
        b.name as name,
        b.del_flag as delFlag,
        b.origin_type as originType
        from xzx_user_other_info b
        left join xzx_order_storage_info a on a.receiver=b.user_id
        where  b.user_type=2
        <if test="delFlag != null and delFlag != ''">
            and b.del_flag=#{delFlag}
        </if>
        <if test="userId != null and userId != ''">
            AND b.user_id=#{userId}
        </if>
        <choose>
            <when test="originType==1">
                and b.origin_type=1
            </when>
            <when test="originType==0">
                and b.origin_type is null
            </when>
        </choose>
        <if test="startTime != null and startTime != ''">
            AND a.storage_time<![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND a.storage_time<![CDATA[<= ]]>#{endTime}
        </if>
        <if test="name != null">
            AND (b.name like concat("%",#{name},"%") or b.mobile_phone like concat("%",#{name},"%") )
        </if>
        <if test="nickName != null">
            AND b.nick_name like concat("%",#{nickName},"%")
        </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 b.user_id
    </select>
 
    <select id="queryStorageByUserId" resultType="com.xzx.gc.model.admin.StorageModel">
        select a.storage_id as storageId,
        (select b.storage_name from xzx_sys_storage b where a.sys_storage_id=b.id) as storageName,
        a.storage_time as createTime,
        IFNULL(a.recycle_weight,0) as recycleWeight,
        (IFNULL(a.storage_weight,0) - IFNULL(a.recycle_weight,0)) as weightError,
        IFNULL(a.recycle_money,0) as recycleMoney,
        (IFNULL(a.storage_money,0) - IFNULL(a.recycle_money,0)) as moneyError
        from xzx_order_storage_info a
        left join xzx_user_other_info b on a.receiver=b.user_id
        where a.storage_status=0
        <if test="receiver != null">
            AND a.receiver=#{receiver}
        </if>
        <if test="startTime != null and startTime != ''">
            AND a.storage_time<![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND a.storage_time<![CDATA[<= ]]>#{endTime}
        </if>
        <if test="recycleWeight != null and recycleWeight != ''">
            AND a.recycle_weight<![CDATA[>= ]]> CONVERT(#{recycleWeight},SIGNED)
        </if>
        <if test="weightError != null">
            AND (IFNULL(a.storage_weight,0) - IFNULL(a.recycle_weight,0))<![CDATA[>= ]]> CONVERT(#{weightError},SIGNED)
        </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>
    </select>
 
 
    <select id="queryStorageList" resultType="java.util.Map">
        select
        IFNULL((select b.storage_name from xzx_sys_storage b where a.sys_storage_id=b.id),"-") as storageName,
        a.storage_time as createTime,
        IFNULL(sum(a.recycle_weight),0) as recycleWeight,
        IFNULL(sum(a.storage_weight),0) as storageWeight,
        IFNULL(sum(a.recycle_money),0) as recycleMoney,
        IFNULL(sum(a.storage_money),0) as storageMoney,
        (select c.partner_name from xzx_city_partner c where c.id=t.partner_id ) as partnerName,
        count(a.storage_id) as orderId,
        a.storage_user_id as storageUserId,
        t.name as name,
        t.mobile_phone as storageUserPhone,
        t.del_flag as delFlag
        from xzx_user_other_info t
        left join xzx_order_storage_info a on t.user_id=a.storage_user_id and a.sys_storage_type=1
        where t.user_type =4
        <if test="delFlag != null and delFlag != ''">
            and t.del_flag=#{delFlag}
        </if>
        <if test="name != null and name != ''">
            AND (t.name like concat("%",#{name},"%") or a.storage_user_phone like concat("%",#{name},"%") )
        </if>
        <if test="nickName != null and nickName != ''">
            AND t.nick_name =#{nickName}
        </if>
        <if test="startTime != null and startTime != ''">
            AND a.storage_time <![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND a.storage_time<![CDATA[<= ]]>#{endTime}
        </if>
        <if test="userType != null and userType != ''">
            AND t.user_type =#{userType}
        </if>
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND t.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        group by t.user_id
    </select>
 
    <select id="queryStorageList1" resultType="java.util.Map">
        select
        IFNULL((select b.partner_name from xzx_city_partner b where a.sys_storage_id=b.id and partner_type=2),"-") as
        storageName,
        a.storage_time as createTime,
        IFNULL(sum(a.recycle_weight),0) as recycleWeight,
        IFNULL(sum(a.storage_weight),0) as storageWeight,
        IFNULL(sum(a.recycle_money),0) as recycleMoney,
        IFNULL(sum(a.storage_money),0) as storageMoney,
        count(a.storage_id) as orderId,
        a.storage_user_id as storageUserId,
        t.name as name,
        t.mobile_phone as storageUserPhone,
        t.del_flag as delFlag,
        a.sys_storage_id as sysStorageId
        from xzx_user_other_info t
        left join xzx_order_storage_info a on t.user_id=a.storage_user_id and a.sys_storage_type=2
        where t.user_type =7
        <if test=" name!= null and name != ''">
            AND (t.name like concat("%",#{name},"%") or a.storage_user_phone like concat("%",#{name},"%") )
        </if>
        <if test="nickName != null and nickName != ''">
            AND t.nick_name =#{nickName}
        </if>
        <if test="startTime != null and startTime != ''">
            AND a.storage_time <![CDATA[>= ]]>#{startTime}
        </if>
        <if test="endTime != null and endTime != ''">
            AND a.storage_time<![CDATA[<= ]]>#{endTime}
        </if>
        <if test="userType != null and userType != ''">
            AND t.user_type =#{userType}
        </if>
        <if test=" partnerIds != null and partnerIds.size() != 0">
            AND t.partner_id in
            <foreach collection="partnerIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        group by a.storage_user_id
    </select>
 
    <select id="queryPackageStorageNum" parameterType="java.util.List" resultType="java.lang.Integer">
        select count(a.user_id)
        from xzx_city_partner a
        left join xzx_partner_gaode b on a.id=b.partner_id
        where a.partner_type='2'
        <if test="townIds != null">
            AND town_id in
            <foreach collection="townIds" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
 
    <select id="queryStorageObjectList" resultType="java.util.Map">
        select a.storage_id as storageId,
        b.mobile_phone AS receiverPhone,
        a.storage_time as storageTime,
        IFNULL(sum(a.storage_weight),0) as storageWeight,
        IFNULL(sum(a.storage_money),0) as storageMoney,
        IFNULL(sum(a.recycle_weight),0) as recycleWeight,
        IFNULL(sum(a.recycle_money),0) as recycleMoney,
        b.name AS NAME
        from xzx_order_storage_info a
        left join xzx_user_other_info b on a.receiver = b.user_id
        where a.storage_status=0
        <if test=" storageUserId!= null">
            AND a.storage_user_id =#{storageUserId}
        </if>
        <if test=" startTime!= null and startTime!=''">
            AND a.storage_time <![CDATA[>= ]]>#{startTime}
        </if>
        <if test=" endTime!= null and endTime!=''">
            AND a.storage_time <![CDATA[<= ]]>#{endTime}
        </if>
        <if test="sysStorageId != null and sysStorageId != ''">
            and a.sys_storage_id=#{sysStorageId}
        </if>
        group by a.storage_id
        <choose>
            <when test="recycleWeight != null and recycleWeight!=''">
                HAVING
                IFNULL(sum(a.recycle_weight),0)<![CDATA[>= ]]>#{recycleWeight}
                <choose>
                    <when test="storageWeight != null and storageWeight!=''">
                        and
                        IFNULL(sum(a.storage_weight),0)<![CDATA[>= ]]>#{storageWeight}
                    </when>
                </choose>
            </when>
            <otherwise>
                HAVING IFNULL(sum(a.recycle_weight),0)<![CDATA[>= ]]>0
                <choose>
                    <when test="storageWeight != null and storageWeight!=''">
                        and
                        IFNULL(sum(a.storage_weight),0) <![CDATA[>= ]]>#{storageWeight}
                    </when>
                </choose>
            </otherwise>
        </choose>
    </select>
 
    <select id="queryOtherUserByPid" resultType="com.xzx.gc.model.admin.UserModel">
        select * from xzx_user_other_info
        where del_flag=0
 
        <if test="pid != null and pid != ''">
            AND (partner_id =#{pid} or partner_id in
            <choose>
                <when test="packageStationList != null and packageStationList.size() != 0">
                    <foreach collection="packageStationList" index="index" item="id" separator="," open="(" close=")">
                        #{id}
                    </foreach>
                </when>
                <otherwise>
                    ("0")
                </otherwise>
            </choose>
            )
        </if>
 
        <if test="userName != null and userName != ''">
            and (name like concat("%",#{userName} ,"%") or mobile_phone like concat("%",#{userName} ,"%"))
        </if>
 
        <if test="roleType != null and roleType != ''">
            AND user_type =#{roleType}
        </if>
    </select>
 
    <select id="queryCityPartnerForOtherUser" resultType="com.xzx.gc.model.admin.UserModel">
        select * from xzx_user_other_info where del_flag=0 and user_type=#{userType}
        <if test=" partnerIds != null and partnerIds.size() != 0">
            and partner_id in
            <foreach collection="partnerIds" index="index" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
    </select>
 
    <select id="queryUserOtherById" resultType="com.xzx.gc.model.admin.UserModel">
        select * from xzx_user_other_info where 1=1
        <if test="userId != null and userId != ''">
            and user_id=#{userId}
        </if>
    </select>
 
    <select id="queryUserModelbyPartnerId" resultType="com.xzx.gc.model.admin.UserModel">
        select a.* from xzx_user_other_info a
        left join xzx_order_info b on b.receiver=a.user_id
        where a.del_flag=0
        <if test="partnerId != null and partnerId.size() != 0">
            and a.partner_id in
            <foreach collection="partnerId" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <if test="userType != null and userType != ''">
            and a.user_type=#{userType}
        </if>
 
        <if test="userId != null and userId != ''">
            and a.user_id=#{userId}
        </if>
 
        <if test="orderId != null and orderId != ''">
            and b.order_id=#{orderId}
        </if>
    </select>
 
    <delete id="deleteUserByPartnerId">
        update xzx_user_other_info
        set del_flag = 1
        where partner_id = #{id} and del_flag = 0
    </delete>
 
    <select id="queryUserOtherByIdC" resultType="com.xzx.gc.model.admin.UserModel">
        select * from xzx_user_other_info where del_flag = 0 and user_type in (2,4)
        <if test="userId != null and userId != ''">
            and user_id=#{userId}
        </if>
    </select>
 
    <insert id="insertUserOtherInfo" parameterType="com.xzx.gc.model.admin.UserModel">
        insert into xzx_user_other_info (user_id, mobile_phone, login_account, password, salt, name,
                                         user_type, open_id, country, regist_time, del_flag, is_prohibit, role_ids, partner_id, avatar)
        values (
            #{userId}, #{mobilePhone},
                       #{loginAccount}, #{password}, #{salt}, #{name}, #{userType}, null, 'China', SYSDATE(), 0, 0,
            #{roleIds}, #{partnerId}, #{avatar}
        )
    </insert>
 
    <update id="updateOtherUserById1">
        update xzx_user_other_info
        set is_prohibit = 1
        where partner_id = #{partnerId}
    </update>
 
 
 
    <select id="findOfferByPartnerId" resultType="com.xzx.gc.entity.OtherUserInfo">
        SELECT
            a.user_id AS userId,
            a.NAME,
            a.avatar,
            b.id AS itemId,
            a.partner_id AS partnerId,
            a.township_id AS townshipId,
            a.latitude,
            a.longitude
        FROM
            xzx_user_other_info a
            INNER JOIN xzx_sys_item_user b ON a.user_id = b.user_id
        WHERE a.del_flag=0 and a.partner_id=#{partnerId} and a.user_type='2' and  a.is_prohibit=0 and b.del_flag=0
              and b.item_type=#{paperWasteItemType}
              AND (a.leave_start_time IS NULL OR now() &lt; a.leave_start_time OR  now() > a.leave_end_time )
    </select>
 
    <select id="findOfferByFenceId" resultType="com.xzx.gc.entity.OtherUserInfo">
        SELECT
            a.user_id AS userId,
            a.NAME,
            a.avatar,
            b.id AS itemId,
            a.partner_id AS partnerId,
            a.township_id AS townshipId,
            a.latitude,
            a.longitude
        FROM
            xzx_user_other_info a
            INNER JOIN xzx_sys_item_user b ON a.user_id = b.user_id
        WHERE a.del_flag=0 and locate(#{fenceId},a.town_id)>0 and a.user_type='2' and  a.is_prohibit=0 and b.del_flag=0
              and b.item_type=#{paperWasteItemType}
              AND (a.leave_start_time IS NULL OR now() &lt; a.leave_start_time OR  now() > a.leave_end_time )
    </select>
 
    <select id="findAllOfferByPartnerId" resultType="com.xzx.gc.entity.OtherUserInfo">
        SELECT
            a.user_id AS userId,
            a.NAME,
            a.avatar,
            b.id AS itemId,
            a.partner_id AS partnerId,
            a.township_id AS townshipId,
            a.mobile_phone AS mobilePhone,
            a.latitude,
            a.longitude
        FROM
            xzx_user_other_info a
            LEFT JOIN xzx_sys_item_user b ON a.user_id = b.user_id
                                             AND b.del_flag = 0
                                             AND b.item_type = #{paperWasteItemType}
        WHERE a.del_flag=0 and a.partner_id=#{partnerId} and a.user_type='2' and  a.is_prohibit=0
              AND (a.leave_start_time IS NULL OR now() &lt; a.leave_start_time OR  now() > a.leave_end_time )
    </select>
 
    <select id="findAllOfferByFenceId" resultType="com.xzx.gc.entity.OtherUserInfo">
        SELECT
            a.user_id AS userId,
            a.NAME,
            a.avatar,
            b.id AS itemId,
            a.partner_id AS partnerId,
            a.township_id AS townshipId,
            a.mobile_phone AS mobilePhone,
            a.latitude,
            a.longitude
        FROM
            xzx_user_other_info a
            LEFT JOIN xzx_sys_item_user b ON a.user_id = b.user_id
                                             AND b.del_flag = 0
                                             AND b.item_type = #{paperWasteItemType}
        WHERE a.del_flag=0 and locate(#{fenceId},a.town_id)>0  and a.user_type='2' and  a.is_prohibit=0
              AND (a.leave_start_time IS NULL OR now() &lt; a.leave_start_time OR  now() > a.leave_end_time )
    </select>
 
 
 
 
    <select id="findNearestByLocationAndPartnerId" resultType="com.xzx.gc.entity.OtherUserInfo">
        SELECT
            user_id AS userId,
            NAME,
            avatar,
            partner_id AS partnerId,
            township_id AS townshipId,
            latitude,
            longitude
        FROM
            xzx_user_other_info
        WHERE
            del_flag = 0
            AND is_prohibit = 0
            AND partner_id = #{partnerId}
            and user_type='2'
            AND (leave_start_time IS NULL OR now() &lt; leave_start_time OR  now() > leave_end_time )
        order by ROUND(lat_lng_distance(#{lat}, #{lon}, latitude, longitude), 3) asc  limit  1
    </select>
 
    <select id="findNearestByLocationAndFenceId" resultType="com.xzx.gc.entity.OtherUserInfo">
        SELECT
            user_id AS userId,
            NAME,
            avatar,
            partner_id AS partnerId,
            township_id AS townshipId,
            latitude,
            longitude
        FROM
            xzx_user_other_info
        WHERE
            del_flag = 0
            AND is_prohibit = 0
            AND locate(#{fenceId},town_id)>0
            AND user_type = '2'
            AND (leave_start_time IS NULL OR now() &lt; leave_start_time OR  now() > leave_end_time )
        order by ROUND(lat_lng_distance(#{lat}, #{lon}, latitude, longitude), 3) asc  limit  1
    </select>
 
    <select id="findByUserTypeAndFenceIdForNotLeave" resultType="com.xzx.gc.entity.OtherUserInfo">
        SELECT
            user_id AS userId,
            NAME,
            avatar,
            partner_id AS partnerId,
            township_id AS townshipId,
            latitude,
            longitude
        FROM
            xzx_user_other_info
        WHERE
            del_flag = 0
            AND is_prohibit = 0
            AND locate(#{fenceId},town_id)>0
            AND user_type = '2'
            AND (leave_start_time IS NULL OR now() &lt; leave_start_time OR  now() > leave_end_time )
    </select>
 
    <select id="findByUserTypeAndPartnerIdForNotLeave" resultType="com.xzx.gc.entity.OtherUserInfo">
        SELECT
            user_id AS userId,
            NAME,
            avatar,
            partner_id AS partnerId,
            township_id AS townshipId,
            latitude,
            longitude
        FROM
            xzx_user_other_info
        WHERE
            del_flag = 0
            AND is_prohibit = 0
            AND partner_id = #{partnerId}
            AND user_type = '2'
            AND (leave_start_time IS NULL OR now() &lt; leave_start_time OR  now() > leave_end_time )
    </select>
</mapper>