Your Name
2023-05-16 b87cfce785e4c177ce9956a19e94e2f49dd9c995
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
<?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="reportFeeStatisticsServiceDaoImpl">
 
    <!-- 查询历史欠费 -->
    <select id="getHisMonthOweFee" parameterType="Map" resultType="Map">
        select ifnull(sum(t.receivable_amount - t.received_amount - t.discount_amount),0.0) hisOweFee
        from pay_fee_detail_month t
        INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        <if test="floorId != null and floorId != ''">
            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        </if>
        where
        1=1
        <if test="floorId != null and floorId != ''">
            and bu.floor_id = #{floorId}
        </if>
        <if test="configId != null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="objName != null and objName != ''">
            and t.obj_name like concat('%',#{objName},'%')
        </if>
        and t.status_cd = '0'
        and t.community_id= #{communityId}
        and t.cur_month_time &lt; #{startDate}
    </select>
 
    <!-- 查询单月欠费 -->
    <select id="getCurMonthOweFee" parameterType="Map" resultType="Map">
        select ifnull(sum(t.receivable_amount - t.received_amount - t.discount_amount),0.0) curOweFee
        from pay_fee_detail_month t
        INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        <if test="floorId != null and floorId != ''">
            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        </if>
        where
        1=1
        <if test="floorId != null and floorId != ''">
            and bu.floor_id = #{floorId}
        </if>
        <if test="configId != null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="objName != null and objName != ''">
            and t.obj_name like concat('%',#{objName},'%')
        </if>
        and t.status_cd = '0'
        and t.community_id= #{communityId}
        and t.cur_month_time &gt; #{startDate}
        and t.cur_month_time &lt; #{endDate}
    </select>
 
    <!-- 查询欠费追回 -->
    <select id="getHisReceivedFee" parameterType="Map" resultType="Map">
        select ifnull(sum(t.received_amount),0.0) hisReceivedFee
        from pay_fee_detail_month t
        INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        <if test="floorId != null and floorId != ''">
            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        </if>
        where
        1=1
        <if test="floorId != null and floorId != ''">
            and bu.floor_id = #{floorId}
        </if>
        <if test="configId != null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="objName != null and objName != ''">
            and t.obj_name like concat('%',#{objName},'%')
        </if>
        and t.status_cd = '0'
        and t.community_id= #{communityId}
        and t.pay_fee_time &gt;  #{startDate}
        and t.pay_fee_time &lt; #{endDate}
        and t.cur_month_time &lt;  #{startDate}
    </select>
 
    <!-- 查询 预交费用 -->
    <select id="getPreReceivedFee" parameterType="Map" resultType="Map">
        select ifnull(sum(t.received_amount),0.0) preReceivedFee
        from pay_fee_detail_month t
        INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        <if test="floorId != null and floorId != ''">
            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        </if>
        where
        1=1
        <if test="floorId != null and floorId != ''">
            and bu.floor_id = #{floorId}
        </if>
        <if test="configId != null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="objName != null and objName != ''">
            and t.obj_name like concat('%',#{objName},'%')
        </if>
        and t.status_cd = '0'
        and t.community_id= #{communityId}
        and t.pay_fee_time &gt;  #{startDate}
        and t.pay_fee_time &lt; #{endDate}
        and t.cur_month_time &gt;  #{endDate}
    </select>
 
    <!-- 查询实收费用 -->
    <select id="getReceivedFee" parameterType="Map" resultType="Map">
        select ifnull(sum(t.received_amount),0.0) receivedFee
        from pay_fee_detail_month t
        INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        <if test="floorId != null and floorId != ''">
            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        </if>
        where
        1=1
        <if test="floorId != null and floorId != ''">
            and bu.floor_id = #{floorId}
        </if>
        <if test="configId != null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="objName != null and objName != ''">
            and t.obj_name like concat('%',#{objName},'%')
        </if>
        and t.status_cd = '0'
        and t.community_id= #{communityId}
        and t.pay_fee_time &gt;  #{startDate}
        and t.pay_fee_time &lt; #{endDate}
    </select>
 
    <!-- 查询欠费户数 -->
    <select id="getOweRoomCount" parameterType="Map" resultType="Map">
        select count(1) oweRoomCount
        from
        (
        select t.obj_id from pay_fee_detail_month t
        INNER JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        <if test="floorId != null and floorId != ''">
            LEFT JOIN building_room br on t.obj_id = br.room_id and br.status_cd = '0'
            left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        </if>
        where
        1=1
        <if test="floorId != null and floorId != ''">
            and bu.floor_id = #{floorId}
        </if>
        <if test="configId != null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="objName != null and objName != ''">
            and t.obj_name like concat('%',#{objName},'%')
        </if>
        and t.status_cd = '0'
        and pf.payer_obj_type = '3333'
        and t.community_id= #{communityId}
        and t.cur_month_time &lt; #{endDate}
        and (t.receivable_amount - t.received_amount - t.discount_amount) > 0
        group by t.obj_id
        ) a
    </select>
 
 
 
</mapper>