wuxw
2021-04-23 fdf45f690fa4eca9191aa0fb6abf077e7b36ce06
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
<?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="feeReceiptServiceDaoImpl">
 
 
    <!-- 保存收据信息 add by wuxw 2018-07-03 -->
    <insert id="saveFeeReceiptInfo" parameterType="Map">
        insert into fee_receipt(
        amount,obj_id,remark,obj_name,community_id,receipt_id,obj_type,pay_obj_id,pay_obj_name
        ) values (
        #{amount},#{objId},#{remark},#{objName},#{communityId},#{receiptId},#{objType},#{payObjId},#{payObjName}
        )
    </insert>
 
 
    <!-- 批量插入费用 -->
    <insert id="saveFeeReceipts" parameterType="Map">
        insert into fee_receipt(
        amount,obj_id,remark,obj_name,community_id,receipt_id,obj_type,pay_obj_id,pay_obj_name
        ) values
        <foreach collection="feeReceiptPos" item="item" separator=",">
            (#{item.amount},#{item.objId},#{item.remark},#{item.objName},#{item.communityId},#{item.receiptId},#{item.objType},#{item.payObjId},#{item.payObjName})
        </foreach>
    </insert>
 
 
    <!-- 查询收据信息 add by wuxw 2018-07-03 -->
    <select id="getFeeReceiptInfo" parameterType="Map" resultType="Map">
        select t.amount,t.obj_id,t.obj_id objId,t.remark,t.status_cd,t.status_cd statusCd,t.obj_name,t.obj_name
        objName,t.community_id,t.community_id communityId,t.receipt_id,t.receipt_id receiptId,t.obj_type,t.obj_type
        objType,t.create_time createTime,frd.fee_name feeName,t.pay_obj_id payObjId,t.pay_obj_name payObjName
        from fee_receipt t
        inner join fee_receipt_detail frd on t.receipt_id = frd.receipt_id and frd.status_cd = '0'
        inner join pay_fee pf on frd.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1 =1
        <if test="amount !=null and amount != ''">
            and t.amount= #{amount}
        </if>
        <if test="objId !=null and objId != ''">
            and t.obj_id= #{objId}
        </if>
        <if test="payObjId !=null and payObjId != ''">
            and t.pay_obj_id= #{payObjId}
        </if>
        <if test="payObjName !=null and payObjName != ''">
            and t.pay_obj_name= #{payObjName}
        </if>
        <if test="remark !=null and remark != ''">
            and t.remark= #{remark}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="objName !=null and objName != ''">
            and t.obj_name= #{objName}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="receiptId !=null and receiptId != ''">
            and t.receipt_id= #{receiptId}
        </if>
        <if test="receiptIds !=null">
            and t.receipt_id in
            <foreach collection="receiptIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="objType !=null and objType != ''">
            and t.obj_type= #{objType}
        </if>
        order by t.create_time desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
 
    </select>
 
 
    <!-- 查询收据信息 add by wuxw 2018-07-03 -->
    <select id="getFeeReceiptInfoNew" parameterType="Map" resultType="Map">
        SELECT
        *
        FROM
        (
        SELECT
        t.obj_name AS objName,
        '' AS carNum,
        bo.NAME AS name,
        b.built_up_area AS roomArea,
        tt.fee_name feeName,
        tt.area num,
        SPLIT_STR ( tt.square_price, '/', 1 ) AS unit,
        CASE
        pf.fee_flag
        WHEN '1003006' THEN
        tt.start_time ELSE NULL
        END start,
        tt.start_time as startTime,
        CASE
        pf.fee_flag
        WHEN '1003006' THEN
        tt.end_time ELSE NULL
        END
        end,
        tt.end_time as endTime,
        tt.cycle as cycle,
        tt.amount amount,
        uu.NAME AS userName,
        t.create_time AS createTime,
        p.remark as remark
        FROM
        fee_receipt t
        LEFT JOIN fee_receipt_detail tt ON t.receipt_id = tt.receipt_id
        LEFT JOIN building_room b ON t.obj_id = b.room_id
        LEFT JOIN building_owner_room_rel borr ON b.room_id = borr.room_id
        LEFT JOIN building_owner bo ON borr.owner_id = bo.owner_id
        LEFT JOIN pay_fee pf ON tt.fee_id = pf.fee_id
        LEFT JOIN pay_fee_detail p ON tt.fee_id = p.fee_id
        AND tt.detail_id = p.detail_id
        LEFT JOIN c_business cb ON p.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
        t.status_cd = '0'
        AND t.obj_type = '3333'
        AND p.state='1400'
        AND tt.status_cd = '0'
        AND b.status_cd = '0'
        AND borr.status_cd = '0'
        AND bo.status_cd = '0'
        AND bo.owner_type_cd = '1001'
        AND p.status_cd = '0'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
 
        UNION ALL
 
        SELECT
        CONCAT( f.floor_num, '栋', bu.unit_num, '单元', b.room_num, '室' ) AS objName,
        oc.car_num AS carNum,
        bo.NAME AS name,
        b.built_up_area AS roomArea,
        tt.fee_name feeName,
        tt.cycle num,
        SPLIT_STR ( tt.square_price, '/', 1 ) AS unit,
        CASE
        pf.fee_flag
        WHEN '1003006' THEN
        tt.start_time ELSE NULL
        END start,
        tt.start_time as startTime,
        CASE
        pf.fee_flag
        WHEN '1003006' THEN
        tt.end_time ELSE NULL
        END
        end,
        tt.end_time as endTime,
        tt.cycle as cycle,
        tt.amount amount,
        uu.NAME AS userName,
        t.create_time AS createTime,
        p.remark as remark
        FROM
        fee_receipt t
        LEFT JOIN fee_receipt_detail tt ON t.receipt_id = tt.receipt_id
        LEFT JOIN owner_car oc ON oc.car_id = t.obj_id and oc.car_type_cd='1001'
        LEFT JOIN building_owner bo ON bo.member_id = oc.owner_id
        LEFT JOIN building_owner_room_rel borr ON bo.owner_id = borr.owner_id
        LEFT JOIN building_room b ON borr.room_id = b.room_id
        LEFT JOIN building_room_attr ba ON b.room_id = ba.room_id
        LEFT JOIN building_unit bu ON b.unit_id = bu.unit_id
        AND bu.status_cd = '0'
        LEFT JOIN f_floor f ON bu.floor_id = f.floor_id
        LEFT JOIN pay_fee pf ON tt.fee_id = pf.fee_id
        AND pf.status_cd = '0'
        LEFT JOIN pay_fee_detail p ON tt.fee_id = p.fee_id
        AND p.status_cd = '0'
        AND tt.detail_id = p.detail_id
        LEFT JOIN c_business cb ON p.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
        t.obj_type = '6666'
        AND p.state='1400'
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        AND bo.owner_type_cd = '1001'
        ) AS t
        WHERE 1=1
        <if test="type !=null and type == 1 ">
            AND feeName in ('预交物业管理费','装修垃圾清运费','装修电梯使用费','水费','电费')
        </if>
        <if test="type !=null and type == 2">
            AND feeName in ('装修保证金','施工进入证')
        </if>
        <if test="type !=null and type == 3">
            AND feeName in ('预交物业管理费','水费','电费','地下停车费','地上停车费')
        </if>
        <if test="type !=null and type == 4">
            AND feeName in ('地上停车费','地下停车费')
        </if>
        <if test="type !=null and type == 5">
            AND feeName in ('公共区域公摊电费','生活水泵公摊电费','走廊楼道应急公摊电费','电梯公摊电费')
        </if>
        <if test="qstartTime !=null and qstartTime != ''">
            AND DATE_FORMAT(t.createTime, '%Y-%m-%d') &gt;= DATE_FORMAT( #{qstartTime}, '%Y-%m-%d' )
        </if>
        <if test="qendTime !=null and qendTime != ''">
            AND DATE_FORMAT(t.createTime, '%Y-%m-%d') &lt;= DATE_FORMAT( #{qendTime}, '%Y-%m-%d' )
        </if>
        <if test="amount !=null and amount != ''">
            and t.amount= #{amount}
        </if>
        <if test="objId !=null and objId != ''">
            and t.obj_id= #{objId}
        </if>
        <if test="remark !=null and remark != ''">
            and t.remark= #{remark}
        </if>
        <if test="objName !=null and objName != ''">
            and t.objName= #{objName}
        </if>
        <if test="receiptId !=null and receiptId != ''">
            and t.receipt_id= #{receiptId}
        </if>
 
        <if test="objType !=null and objType != ''">
            and t.obj_type= #{objType}
        </if>
        order by t.createTime desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
 
    </select>
 
 
    <!-- 修改收据信息 add by wuxw 2018-07-03 -->
    <update id="updateFeeReceiptInfo" parameterType="Map">
        update fee_receipt t set t.status_cd = #{statusCd}
        <if test="newBId != null and newBId != ''">
            ,t.b_id = #{newBId}
        </if>
        <if test="amount !=null and amount != ''">
            , t.amount= #{amount}
        </if>
        <if test="objId !=null and objId != ''">
            , t.obj_id= #{objId}
        </if>
        <if test="remark !=null and remark != ''">
            , t.remark= #{remark}
        </if>
        <if test="objName !=null and objName != ''">
            , t.obj_name= #{objName}
        </if>
        <if test="communityId !=null and communityId != ''">
            , t.community_id= #{communityId}
        </if>
        <if test="objType !=null and objType != ''">
            , t.obj_type= #{objType}
        </if>
        where 1=1
        <if test="receiptId !=null and receiptId != ''">
            and t.receipt_id= #{receiptId}
        </if>
 
    </update>
 
    <!-- 查询收据数量 add by wuxw 2018-07-03 -->
    <select id="queryFeeReceiptsCount" parameterType="Map" resultType="Map">
        select count(1) count
        from fee_receipt t
        inner join fee_receipt_detail frd on t.receipt_id = frd.receipt_id and frd.status_cd = '0'
        inner join pay_fee pf on frd.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1 =1
        <if test="amount !=null and amount != ''">
            and t.amount= #{amount}
        </if>
        <if test="objId !=null and objId != ''">
            and t.obj_id= #{objId}
        </if>
        <if test="payObjId !=null and payObjId != ''">
            and t.pay_obj_id= #{payObjId}
        </if>
        <if test="payObjName !=null and payObjName != ''">
            and t.pay_obj_name= #{payObjName}
        </if>
        <if test="remark !=null and remark != ''">
            and t.remark= #{remark}
        </if>
        <if test="statusCd !=null and statusCd != ''">
            and t.status_cd= #{statusCd}
        </if>
        <if test="objName !=null and objName != ''">
            and t.obj_name= #{objName}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="receiptId !=null and receiptId != ''">
            and t.receipt_id= #{receiptId}
        </if>
        <if test="receiptIds !=null">
            and t.receipt_id in
            <foreach collection="receiptIds" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="objType !=null and objType != ''">
            and t.obj_type= #{objType}
        </if>
 
 
    </select>
 
</mapper>