wuxw
2025-03-05 8db9f4357be1761feb6355bff8d1374b58bfbd4f
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
<?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="reportCommunityServiceDaoImpl">
 
    <!-- 查询房屋个数 add by wuxw 2018-07-03 -->
    <select id="getRoomCount" parameterType="com.java110.dto.report.ReportRoomDto" resultType="Map">
        select count(1) count
        from building_room t
        where t.status_cd = '0'
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
    </select>
 
    <!-- 查询 房屋 楼栋 单元 业主 -->
    <select id="getRoomFloorUnitAndOwner" parameterType="com.java110.dto.report.ReportRoomDto"
            resultType="com.java110.dto.report.ReportRoomDto">
        select t.apartment,t.built_up_area builtUpArea,t.community_id communityId,t.create_time createTime,
        t.fee_coefficient feeCoefficient,t.layer,t.room_id roomId,t.room_num roomNum,t.section,
        t.state,bu.unit_id unitId,bu.unit_num unitNum,ff.floor_id floorId,ff.floor_num floorNum,
        bo.age,bo.id_card idCard,bo.link,bo.member_id memberId,bo.`name`,bo.`name` ownerName,bo.owner_id
        ownerId,t.room_type roomType,
        t.room_sub_type roomSubType,t.room_rent roomRent,t.room_area roomArea
        from building_room t
        INNER JOIN building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join f_floor ff on bu.floor_id = ff.floor_id and ff.status_cd = '0'
        LEFT JOIN building_owner_room_rel borr on t.room_id = borr.room_id and borr.status_cd = '0'
        left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
        where t.status_cd = '0'
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
 
    <select id="queryRoomStructures" parameterType="Map" resultType="Map">
        select t.apartment,
               t.built_up_area   builtUpArea,
               t.community_id    communityId,
               t.create_time     createTime,
               t.fee_coefficient feeCoefficient,
               t.layer,
               t.room_id         roomId,
               t.room_num        roomNum,
               t.section,
               t.state,
               bu.unit_id        unitId,
               bu.unit_num       unitNum,
               ff.floor_id       floorId,
               ff.floor_num      floorNum,
               bo.age,
               bo.id_card        idCard,
               bo.link,
               bo.member_id      memberId,
               bo.`name`,
               bo.`name`         ownerName,
               bo.owner_id       ownerId,
               t.room_type       roomType,
               t.room_sub_type   roomSubType,
               t.room_rent       roomRent,
               t.room_area       roomArea,
               td.name           stateName,
               (
                   select if(SUM(rof.amount_owed)!='', SUM(rof.amount_owed), 0)
                   from report_owe_fee rof
                   where rof.payer_obj_id = t.room_id
                     and rof.payer_obj_type = '3333'
               )                 oweAmount
        from building_room t
                 INNER JOIN building_unit bu on t.unit_id = bu.unit_id and bu.status_cd = '0'
                 inner join f_floor ff on bu.floor_id = ff.floor_id and ff.status_cd = '0'
                 LEFT JOIN building_owner_room_rel borr on t.room_id = borr.room_id and borr.status_cd = '0'
                 left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
                 left join t_dict td
                           on t.state = td.status_cd and td.table_name = 'building_room' and td.table_columns = 'state'
        where t.status_cd = '0'
          and t.community_id = #{communityId}
          and bu.unit_id = #{unitId}
        order by CONVERT(t.layer, SIGNED), CONVERT(t.room_num, SIGNED) asc
    </select>
 
    <select id="queryCarStructures" parameterType="Map" resultType="Map">
        select pa.num       areaNum,
               ps.num,
               t.car_num    carNum,
               br.room_id   roomId,
               br.room_num  roomNum,
               br.section,
               br.state,
               bu.unit_id   unitId,
               bu.unit_num  unitNum,
               ff.floor_id  floorId,
               ff.floor_num floorNum,
               bo.age,
               bo.id_card   idCard,
               bo.link,
               bo.member_id memberId,
               bo.`name`,
               bo.`name`    ownerName,
               bo.owner_id  ownerId,
               (
                   select if(SUM(rof.amount_owed)!='', SUM(rof.amount_owed), 0)
                   from report_owe_fee rof
                   where rof.payer_obj_id = t.car_id
                     and rof.payer_obj_type = '6666'
               )            oweAmount
        from owner_car t
                 INNER join building_owner bo on t.owner_id = bo.member_id and bo.status_cd = '0'
                 INNER JOIN building_owner_room_rel borr on bo.owner_id = borr.owner_id and borr.status_cd = '0'
                 INNER join building_room br on borr.room_id = br.room_id and br.status_cd = '0'
                 INNER JOIN building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
                 inner join f_floor ff on bu.floor_id = ff.floor_id and ff.status_cd = '0'
                 LEFT JOIN parking_space ps on t.ps_id = ps.ps_id and ps.status_cd = '0'
                 LEFT JOIN parking_area pa on ps.pa_id = pa.pa_id and pa.status_cd = '0'
        where t.status_cd = '0'
          and t.community_id = #{communityId}
          and bu.unit_id = #{unitId}
        order by t.car_num
    </select>
 
    <!-- 查询房屋个数 add by wuxw 2018-07-03 -->
    <select id="getCarCount" parameterType="com.java110.dto.report.ReportCarDto" resultType="Map">
        select count(1) count
        from owner_car t
        where t.status_cd = '0'
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="leaseTypes !=null ">
            and t.lease_type in
            <foreach collection="leaseTypes" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
    </select>
 
    <!-- 查询 房屋 楼栋 单元 业主 -->
    <select id="getCarParkingSpace" parameterType="com.java110.dto.report.ReportCarDto"
            resultType="com.java110.dto.report.ReportCarDto">
        select t.car_brand carBrand,t.car_color carColor,t.car_id carId,t.car_num carNum,t.car_type carType,
        t.community_id communityId,bo.`name` ownerName,bo.id_card idCard,bo.link,bo.owner_id ownerId,ps.ps_id psId,
        ps.num,pa.pa_id paId,pa.num areaNum,ps.state,t.start_time startTime,t.end_time endTime
        from owner_car t
        INNER JOIN building_owner bo on t.owner_id = bo.member_id and t.status_cd = '0'
        left join parking_space ps on t.ps_id = ps.ps_id and ps.status_cd = '0'
        left join parking_area pa on ps.pa_id = pa.pa_id and pa.status_cd = '0'
        where t.status_cd = '0'
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        <if test="leaseTypes !=null ">
            and t.lease_type in
            <foreach collection="leaseTypes" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
 
    <!-- 查询小区信息 add by wuxw 2018-07-03 -->
    <select id="getCommunitys" parameterType="Map" resultType="Map">
        select t.address,t.nearby_landmarks,t.nearby_landmarks nearbyLandmarks,
        t.city_code,t.city_code cityCode,t.name,t.status_cd,t.status_cd statusCd,t.tel,
        t.community_id,t.community_id communityId,t.b_id,t.b_id bId,t.map_y,t.map_y mapY,
        t.map_x,t.map_x mapX,t.state,ca.area_code areaCode,ca.area_name areaName,
        ca.parent_area_code parentAreaCode,ca.parent_area_name parentAreaName,
        t.community_area communityArea
        from s_community t,city_area ca
        where t.status_cd = '0'
        and t.city_code = ca.area_code
        and ca.status_cd = '0'
        <if test="address !=null and address != ''">
            and t.address= #{address}
        </if>
        <if test="nearbyLandmarks !=null and nearbyLandmarks != ''">
            and t.nearby_landmarks= #{nearbyLandmarks}
        </if>
        <if test="cityCode !=null and cityCode != ''">
            and t.city_code= #{cityCode}
        </if>
        <if test="name !=null and name != ''">
            and t.name like concat('%',#{name},'%')
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="communityIds !=null">
            and t.community_id in
            <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="bId !=null and bId != ''">
            and t.b_id= #{bId}
        </if>
        <if test="mapY !=null and mapY != ''">
            and t.map_y= #{mapY}
        </if>
        <if test="mapX !=null and mapX != ''">
            and t.map_x= #{mapX}
        </if>
        <if test="state !=null and state != ''">
            and t.state= #{state}
        </if>
        order by t.create_time ASC
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
 
    <!-- 查询无效费用 add by wuxw 2018-07-03 -->
    <select id="queryInvalidFeeMonthStatistics" parameterType="Map" resultType="Map">
        select t.fee_id feeId
        from pay_fee t
                 inner join pay_fee_config pfc on t.config_id = pfc.config_id
                 inner join report_fee_year_collection rfyc on t.fee_id = rfyc.fee_id and rfyc.status_cd = '0'
        where (t.status_cd = '1' or pfc.status_cd = '1')
          and t.community_id = #{communityId}
    </select>
 
    <!--清理报表 无效数据-->
    <update id="deleteInvalidFee" parameterType="Map">
        delete from report_fee_year_collection where fee_id in
        <foreach collection="feeIds" item="item" open="(" close=")" separator=",">
            #{item}
        </foreach>
        and community_id = #{communityId}
    </update>
 
    <!-- 查询无效费用 add by wuxw 2018-07-03 -->
    <select id="queryRoomsTree" parameterType="Map" resultType="Map">
        SELECT distinct t.room_id,
               t.room_id        roomId,
               t.layer,
               t.room_num,
               t.room_num       roomNum,
               t.unit_id,
               u.`unit_num`     unitNum,
               u.unit_id        unitId,
               f.floor_id       floorId,
               f.floor_num      floorNum,
               t.`community_id` communityId,
               bo.owner_id      ownerId ,
               bo.`name`        ownerName,
               bo.link          link
        FROM building_room t
                 inner join building_unit u on t.`unit_id` = u.`unit_id` and u.`status_cd` = '0'
                 inner JOIN f_floor f on u.`floor_id` = f.`floor_id` AND f.`community_id` = t.`community_id` AND f.`status_cd` = '0'
                 left join building_owner_room_rel borr on t.room_id = borr.room_id and borr.status_cd = '0'
                 left join building_owner bo on borr.owner_id = bo.member_id and bo.status_cd = '0'
        WHERE 1 = 1
          and t.status_cd = '0'
          and u.unit_id = #{unitId}
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        order by CONVERT(t.layer, SIGNED), CONVERT(t.room_num, SIGNED)
    </select>
 
    <!-- 查询无效费用 add by wuxw 2018-07-03 -->
    <select id="queryCommunityUnitTree" parameterType="Map" resultType="Map">
        select s.community_id communityId,s.name communityName,f.floor_num floorNum,f.`name`,f.floor_id floorId,
        t.unit_num unitNum,t.unit_id unitId
        from building_unit t
        left join f_floor f on t.floor_id = f.floor_id and f.status_cd = '0'
        left join s_community s on f.community_id = s.community_id and s.status_cd = '0'
        where t.status_cd = '0'
        and f.status_cd = '0'
        and s.status_cd = '0'
        <if test="communityIds !=null ">
            and s.community_id in
            <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        order by f.seq ,CONVERT(t.unit_num, SIGNED)
    </select>
 
    <select id="queryCommunityParkingTree" parameterType="Map" resultType="Map">
        select s.community_id communityId,s.name communityName,t.num,t.pa_id paId
        from parking_area t
        left join s_community s on t.community_id = s.community_id and s.status_cd = '0'
        where t.status_cd = '0'
        and s.status_cd ='0'
        <if test="communityIds !=null ">
            and s.community_id in
            <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        order by t.num
    </select>
 
    <!-- 查询报修数-->
    <select id="queryCommunityRepairTree" parameterType="Map" resultType="Map">
        select s.community_id communityId,s.name communityName,t.repair_type repairType,t.repair_type_name repairTypeName
        from r_repair_setting t
        left join s_community s on t.community_id = s.community_id and s.status_cd = '0'
        where t.status_cd = '0'
        and s.status_cd = '0'
        <if test="communityIds !=null ">
            and s.community_id in
            <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        order by t.repair_type_name
    </select>
    <select id="queryCommunityInspectionTree" parameterType="Map" resultType="Map">
        select s.community_id communityId,s.`name` communityName,ip.inspection_plan_id inspectionPlanId,
        ip.inspection_plan_name inspectionPlanName ,t.staff_id staffId,t.staff_name staffName
        from inspection_plan_staff t
        left join inspection_plan ip on t.inspection_plan_id = ip.inspection_plan_id and ip.status_cd = '0'
        left join s_community s on t.community_id = s.community_id and s.status_cd = '0'
        where t.status_cd = '0'
        and ip.status_cd = '0'
        and s.status_cd = '0'
        <if test="communityIds !=null ">
            and s.community_id in
            <foreach collection="communityIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        order by ip.create_time desc
    </select>
 
 
    <select id="queryHisOwnerCarCount" parameterType="Map" resultType="Map">
        select count(1) count
        from business_owner_car t
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        left join t_dict t1 on t.car_type=t1.status_cd and t1.table_name='owner_car' and t1.table_columns = 'car_type'
        left join t_dict t2 on t.state=t2.status_cd and t2.table_name='owner_car' and t2.table_columns = 'state'
        left join t_dict t3 on t.lease_type = t3.status_cd and t3.table_name = 'owner_car' and t3.table_columns =
        'lease_type'
        left join t_dict t4 on t.car_type_cd=t4.status_cd and t4.table_name='owner_car' and t4.table_columns =
        'car_type_cd'
        left join building_owner bo on t.owner_id = bo.member_id and bo.status_cd = '0'
        where 1=1
        <if test="carNum != null and carNum != ''">
            and t.car_num = #{carNum}
        </if>
        <if test="carNumLike != null and carNumLike != ''">
            and t.car_num like concat('%',#{carNumLike},'%')
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and t.start_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and t.end_time &lt;= #{logEndTime}
        </if>
        and t.community_id= #{communityId}
    </select>
 
    <select id="queryHisOwnerCars" parameterType="Map" resultType="Map">
        select t.car_color carColor,t.car_brand carBrand,t.car_type carType,t1.name
        carTypeName,
        t.car_num carNum,t.ps_id psId,t.remark,
        t.owner_id ownerId,t.b_id bId,t.user_id userId,t.car_id carId ,t.create_time
        createTime,t.community_id communityId,t2.name stateName,
        t.start_time startTime,t.end_time endTime,t.state,
        t.car_type_cd carTypeCd,t.member_id memberId,t.lease_type leaseType,
        t3.name leaseTypeName,t4.name carTypeCdName,t.operate,uu.`name` userName,bo.`name` ownerName,bo.link
        from business_owner_car t
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        left join t_dict t1 on t.car_type=t1.status_cd and t1.table_name='owner_car' and t1.table_columns = 'car_type'
        left join t_dict t2 on t.state=t2.status_cd and t2.table_name='owner_car' and t2.table_columns = 'state'
        left join t_dict t3 on t.lease_type = t3.status_cd and t3.table_name = 'owner_car' and t3.table_columns =
        'lease_type'
        left join t_dict t4 on t.car_type_cd=t4.status_cd and t4.table_name='owner_car' and t4.table_columns =
        'car_type_cd'
        left join building_owner bo on t.owner_id = bo.member_id and bo.status_cd = '0'
        where 1=1
        <if test="carNum != null and carNum != ''">
            and t.car_num = #{carNum}
        </if>
        <if test="carNumLike != null and carNumLike != ''">
            and t.car_num like concat('%',#{carNumLike},'%')
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and t.start_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and t.end_time &lt;= #{logEndTime}
        </if>
        and t.community_id= #{communityId}
        order by t.create_time desc,t.operate
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
 
    <select id="queryHisOwnerCount" parameterType="Map" resultType="Map">
        select count(1) count
        from business_building_owner t
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        where 1=1
        <if test="memberId != null and memberId != ''">
            and t.member_id = #{memberId}
        </if>
        <if test="ownerNameLike != null and ownerNameLike != ''">
            and t.name like concat('%',#{ownerNameLike},'%')
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and co.create_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and co.create_time &lt;= #{logEndTime}
        </if>
        and t.community_id = #{communityId}
    </select>
 
    <select id="queryHisOwners" parameterType="Map" resultType="Map">
        select t.operate,t.sex,t.name,t.link,t.remark,t.owner_id ownerId,t.b_id bId,
        t.age,t.member_id memberId,
        t.owner_type_cd ownerTypeCd,t.community_id communityId,t.owner_flag ownerFlag,
        t.id_card idCard,t.state,t.address,co.create_time createTime,uu.`name` userName,t.operate
        from business_building_owner t
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        where 1=1
        <if test="memberId != null and memberId != ''">
            and t.member_id = #{memberId}
        </if>
        <if test="ownerNameLike != null and ownerNameLike != ''">
            and t.name like concat('%',#{ownerNameLike},'%')
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and co.create_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and co.create_time &lt;= #{logEndTime}
        </if>
        and t.community_id = #{communityId}
        order by t.create_time desc,t.operate
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
 
    <select id="queryHisFeeCount" parameterType="Map" resultType="Map">
        select count(1) count
        from business_pay_fee t
        left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        <if test="payerObjName != null and payerObjName != ''">
            left join pay_fee_attrs pfa on pfa.fee_id = t.fee_id and pfa.spec_cd = '390012'
        </if>
        <if test="deleteFlag != null and deleteFlag != ''">
            inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '1' and pf.b_id = t.b_id
        </if>
        where 1=1
        <if test="feeId != null and feeId != ''">
            and t.fee_id = #{feeId}
        </if>
        <if test="deleteFlag != null and deleteFlag != ''">
            and t.operate = 'DEL'
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="feeNameLike != null and feeNameLike != ''">
            and pfc.fee_name like concat('%',#{feeNameLike},'%')
        </if>
        <if test="payerObjName != null and payerObjName != ''">
            and pfa.value = #{payerObjName}
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and t.start_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and t.end_time &lt;= #{logEndTime}
        </if>
        and t.community_id = #{communityId}
    </select>
 
    <select id="queryHisFees" parameterType="Map" resultType="Map">
        select t.operate,t.start_time startTime,t.end_time endTime,t.create_time createTime,pfc.fee_name feeName,
        t.amount,
        uu.`name` userName,pfa.`value` payerObjName,pfa1.value ownerName,t.b_id bId,co.create_time createTime
        from business_pay_fee t
        left join pay_fee_config pfc on t.config_id = pfc.config_id
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        left join pay_fee_attrs pfa on pfa.fee_id = t.fee_id and pfa.spec_cd = '390012'
        left join pay_fee_attrs pfa1 on pfa1.fee_id = t.fee_id and pfa1.spec_cd = '390008'
        <if test="deleteFlag != null and deleteFlag != ''">
            inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '1' and pf.b_id = t.b_id
        </if>
        where 1=1
        <if test="feeId != null and feeId != ''">
            and t.fee_id = #{feeId}
        </if>
        <if test="deleteFlag != null and deleteFlag != ''">
            and t.operate = 'DEL'
        </if>
        <if test="payerObjName != null and payerObjName != ''">
            and pfa.value = #{payerObjName}
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="feeNameLike != null and feeNameLike != ''">
            and pfc.fee_name like concat('%',#{feeNameLike},'%')
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and t.start_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and t.end_time &lt;= #{logEndTime}
        </if>
        and t.community_id = #{communityId}
        order by t.create_time desc,t.operate
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
 
    <select id="queryHisFeeConfigCount" parameterType="Map" resultType="Map">
        select count(1) count
        from business_pay_fee_config t
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        <if test="deleteFlag != null and deleteFlag != ''">
            inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '1' and pfc.b_id = t.b_id
        </if>
        where 1=1
        <if test="configId != null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="deleteFlag != null and deleteFlag != ''">
            and t.operate = 'DEL'
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="feeNameLike != null and feeNameLike != ''">
            and t.fee_name like concat('%',#{feeNameLike},'%')
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and t.start_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and t.end_time &lt;= #{logEndTime}
        </if>
        and t.community_id = #{communityId}
    </select>
 
    <select id="queryHisFeeConfigs" parameterType="Map" resultType="Map">
        select t.operate,t.fee_type_cd feeTypeCd,t.computing_formula
        computingFormula,t.additional_amount additionalAmount,t.bill_type
        billType,t.computing_formula_text computingFormulaText,t.square_price squarePrice,t.payment_cd
        paymentCd,t.is_default
        isDefault,t.config_id configId,t.fee_flag feeFlag,t.fee_name
        feeName,t.payment_cycle paymentCycle,t.start_time startTime,t.end_time
        endTime,t.community_id communityId,t.deduct_from deductFrom,
        t.pay_online payOnline,t.scale,t.decimal_place decimalPlace,t.units,t.b_id bId,
        td1.name feeTypeCdName,td2.name feeFlagName,td3.name billTypeName,td4.name computingFormulaName,
        uu.`name` userName,co.create_time createTime,t.b_id bId
        from business_pay_fee_config t
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        left join t_dict td1 on t.fee_type_cd = td1.status_cd and td1.table_name = 'pay_fee_config' and
        td1.table_columns = 'fee_type_cd'
        left join t_dict td2 on t.fee_flag = td2.status_cd and td2.table_name = 'pay_fee_config' and td2.table_columns =
        'fee_flag'
        left join t_dict td3 on t.bill_type = td3.status_cd and td3.table_name = 'pay_fee_config' and td3.table_columns
        = 'bill_type'
        left join t_dict td4 on t.computing_formula = td4.status_cd and td4.table_name = 'pay_fee_config' and
        td4.table_columns = 'computing_formula'
        <if test="deleteFlag != null and deleteFlag != ''">
            inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '1' and pfc.b_id = t.b_id
        </if>
        where 1=1
        <if test="configId != null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="deleteFlag != null and deleteFlag != ''">
            and t.operate = 'DEL'
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="feeNameLike != null and feeNameLike != ''">
            and t.fee_name like concat('%',#{feeNameLike},'%')
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and t.start_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and t.end_time &lt;= #{logEndTime}
        </if>
        and t.community_id = #{communityId}
        order by t.create_time desc,t.operate
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
 
 
    <select id="queryHisRoomCount" parameterType="Map" resultType="Map">
        select count(1) count
        from business_building_room t
        left join building_unit bu on t.unit_id = bu.unit_id
        left join f_floor f on f.floor_id = bu.floor_id
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        where 1=1
        <if test="roomId != null and roomId != ''">
            and t.room_id = #{roomId}
        </if>
        <if test="floorNum != null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
        <if test="unitNum != null and unitNum != ''">
            and bu.unit_num = #{unitNum}
        </if>
        <if test="roomNum != null and roomNum != ''">
            and t.room_num = #{roomNum}
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and co.create_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and co.create_time &lt;= #{logEndTime}
        </if>
        and t.community_id = #{communityId}
    </select>
 
    <select id="queryHisRooms" parameterType="Map" resultType="Map">
        select t.operate,co.create_time createTime,uu.`name` userName,t.section,t.remark,t.room_sub_type
        roomSubType,td1.name roomSubTypeName, t.room_area roomArea,t.room_id
        roomId,t.layer,t.fee_coefficient feeCoefficient,t.built_up_area
        builtUpArea,t.room_num roomNum,t.unit_id unitId,t.state,td.name stateName,t.community_id
        communityId,t.apartment,t.room_type roomType,t.room_rent roomRent,f.floor_num floorNum,bu.unit_num
        unitNum,t.b_id bId
        from business_building_room t
        left join building_unit bu on t.unit_id = bu.unit_id
        left join f_floor f on f.floor_id = bu.floor_id
        left join c_business cb on t.b_id = cb.b_id
        left join c_orders co on cb.o_id = co.o_id
        left join u_user uu on co.user_id = uu.user_id
        left join t_dict td on t.state = td.status_cd and td.table_name = 'building_room' and td.table_columns = 'state'
        left join t_dict td1 on t.room_sub_type = td1.status_cd and td1.table_name = 'building_room' and
        td1.table_columns = 'room_sub_type'
        where 1=1
        <if test="roomId != null and roomId != ''">
            and t.room_id = #{roomId}
        </if>
        <if test="floorNum != null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
        <if test="unitNum != null and unitNum != ''">
            and bu.unit_num = #{unitNum}
        </if>
        <if test="roomNum != null and roomNum != ''">
            and t.room_num = #{roomNum}
        </if>
        <if test="staffNameLike != null and staffNameLike != ''">
            and uu.name like concat('%',#{staffNameLike},'%')
        </if>
        <if test="logStartTime != null and logStartTime != ''">
            and co.create_time &gt;= #{logStartTime}
        </if>
        <if test="logEndTime != null and logEndTime != ''">
            and co.create_time &lt;= #{logEndTime}
        </if>
        and t.community_id = #{communityId}
        order by t.create_time desc,t.operate
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
</mapper>