java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="reportFeeMonthStatisticsServiceDaoImpl">
@@ -111,7 +110,6 @@
        </if>
    </update>
    <!-- 修改费用月统计信息 add by wuxw 2018-07-03 -->
    <update id="updateReportFeeMonthStatisticsInfo" parameterType="Map">
        update report_fee_month_statistics t set t.status_cd = #{statusCd}
@@ -205,7 +203,6 @@
            and t.config_id= #{configId}
        </if>
    </update>
    <!-- 查询费用月统计数量 add by wuxw 2018-07-03 -->
    <select id="queryReportFeeMonthStatisticssCount" parameterType="Map" resultType="Map">
@@ -952,9 +949,7 @@
        </if>
    </select>
    <!--
    and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0
    -->
    <!-- and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0 -->
    <select id="queryFeeBreakdownCount" parameterType="Map" resultType="Map">
        select count(1) count
        from (
@@ -1022,8 +1017,7 @@
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03
     and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0
     -->
     and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0-->
    <select id="queryFeeBreakdown" parameterType="Map" resultType="Map">
        select t.fee_name feeName,td.name feeTypeCd,pfc.fee_type_cd,t.config_id configId,SUM(t.his_owe_amount)
        hisOweAmount,SUM(t.cur_receivable_amount) curReceivableAmount,
@@ -1158,8 +1152,7 @@
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03
     and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0
     -->
     and t.receivable_amount >= 0 and t.received_amount >= 0 and t.owe_amount >= 0-->
    <select id="queryFeeBreakdownDetail" parameterType="Map" resultType="Map">
        select t.obj_name objName,t.fee_name feeName,t.fee_year feeYear,t.fee_month feeMonth,t.create_time createTime
        ,t.config_id configId,t.his_owe_amount hisOweAmount,t.obj_name_num objNameNum,t.cur_receivable_amount
@@ -1362,7 +1355,8 @@
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryFeeDetail" parameterType="Map" resultType="Map">
        select t.config_id configId,t.obj_id objId,t.obj_name objName,t.obj_type objType,t.fee_name feeName,t.fee_create_time feeCreateTime,pfa.`value`
        select t.config_id configId,t.obj_id objId,t.obj_name objName,t.obj_type objType,t.fee_name
        feeName,t.fee_create_time feeCreateTime,pfa.`value`
        ownerName,br.built_up_area builtUpArea ,max(t.deadline_time)
        deadlineTime,max(t.create_time) createTime,max(t.update_time) updateTime,SUM(t.his_owe_amount)
        hisOweAmount,SUM(t.cur_receivable_amount) curReceivableAmount,
@@ -1370,7 +1364,7 @@
        hisOweReceivedAmount,SUM(t.pre_received_amount) preReceivedAmount,
        sum(t.his_owe_amount+t.cur_receivable_amount) receivableAmount,
        sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount,
        t.obj_type objType,t.obj_name_num objNameNum
        t.obj_type objType
        from report_fee_month_statistics t
        inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
@@ -1379,7 +1373,6 @@
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
        left join pay_fee_attrs pfa on pf.fee_id = pfa.fee_id and pfa.spec_cd = '390008' and pfa.status_cd ='0'
        where t.status_cd = '0'
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
@@ -1391,9 +1384,6 @@
        </if>
        <if test="objName !=null and objName != ''">
            and t.obj_name= #{objName}
        </if>
        <if test="objNameNum != null and objNameNum != ''">
            and t.obj_name_num= #{objNameNum}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and t.fee_year= #{feeYear}
@@ -1537,9 +1527,9 @@
        <if test="endTime !=null and endTime != ''">
            and t.create_time &lt;= #{endTime}
        </if>
        and t.amount_owed > 0 and pf.end_time &lt; now()
        and t.amount_owed != 0 and pf.end_time &lt; now()
        group by t.payer_obj_name ,t.fee_name ,pf.end_time ,t.create_time
        HAVING oweAmount > 0
        HAVING oweAmount != 0
        ) t
    </select>
@@ -1595,14 +1585,15 @@
        <if test="endTime !=null and endTime != ''">
            and t.create_time &lt;= #{endTime}
        </if>
        and t.amount_owed > 0 and pf.end_time &lt; now()
        and t.amount_owed != 0 and pf.end_time &lt; now()
        group by t.payer_obj_name ,t.fee_name ,pf.end_time ,t.update_time,pfa.`value` ,br.built_up_area
        HAVING oweAmount > 0
        HAVING oweAmount != 0
        order by t.payer_obj_name
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryOweFeeDetailMajor" parameterType="Map" resultType="Map">
        select SUM(t.amount_owed) oweAmount
@@ -1651,99 +1642,23 @@
    <select id="queryPayFeeDetailCount" parameterType="Map" resultType="Map">
        select count(1) count,SUM(receivedAmount) totalReceivedAmount,SUM(receivableAmount) totalReceivableAmount
        from (
        select pfc.fee_name feeName,f.floor_num floorNum,bu.unit_num unitNum,br.room_num roomNum,oc.car_num carNum,
        pf.payer_obj_type payerObjType,t.start_time startTime,t.end_time endTime,t.create_time createTime,
        t.receivable_amount receivableAmount,t.received_amount receivedAmount,d.name,d2.name feeTypeCdName,
        pfc.fee_type_cd feeTypeCd,t.state,d3.name stateName
        from pay_fee_detail t
        left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
        left join building_room br on pf.payer_obj_id = br.room_id and pf.payer_obj_type = '3333' and br.status_cd = '0'
        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.car_type_cd='1001'
        left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
        left join t_dict d on t.prime_rate = d.status_cd and d.table_name="pay_fee_detail" and
        d.table_columns="prime_rate"
        left join t_dict d2 on pfc.fee_type_cd = d2.status_cd and d2.table_name = "pay_fee_config" and d2.table_columns
        = "fee_type_cd"
        left join t_dict d3 on t.state = d3.status_cd and d3.table_name = "pay_fee_detail" and d3.table_columns =
        "state"
        where t.status_cd = '0'  and pf.status_cd = '0'
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="unitId !=null and unitId != ''">
            and bu.unit_id= #{unitId}
        </if>
        <if test="unitNum !=null and unitNum != ''">
            and bu.unit_num= #{unitNum}
        </if>
        <if test="floorId !=null and floorId != ''">
            and f.floor_id = #{floorId}
        </if>
        <if test="floorNum !=null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
        <if test="objName !=null and objName != ''">
            and t.obj_name= #{objName}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and t.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and t.fee_month= #{feeMonth}
        </if>
        <if test="feeId !=null and feeId != ''">
            and t.fee_id= #{feeId}
        </if>
        <if test="configId !=null and configId != ''">
            and pfc.config_id= #{configId}
        </if>
        <if test="objId !=null and objId != ''">
            and pf.payer_obj_id= #{objId}
        </if>
        <if test="feeName !=null and feeName != ''">
            and t.fee_name= #{feeName}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="primeRate != null and primeRate != ''">
            and t.prime_rate = #{primeRate}
        </if>
        <if test="state != null and state != ''">
            and t.state = #{state}
        </if>
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pfc.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="startTime !=null and startTime != ''">
            and t.create_time &gt;= #{startTime}
        </if>
        <if test="endTime !=null and endTime != ''">
            and t.create_time &lt;= #{endTime}
        </if>
        <if test="cashierId !=null and cashierId != ''">
            and t.cashier_id= #{cashierId}
        </if>
        <if test="cashierName !=null and cashierName != ''">
            and t.cashier_name= #{cashierName}
        </if>
        ) t
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryPayFeeDetail" parameterType="Map" resultType="Map">
        select pfc.fee_name feeName,f.floor_num floorNum,bu.unit_num unitNum,br.room_num roomNum,br.built_up_area
        builtUpArea ,oc.car_num carNum,
        pf.payer_obj_type payerObjType,t.start_time startTime,t.end_time endTime,t.create_time createTime,
        t.receivable_amount receivableAmount,t.received_amount receivedAmount,pfa.`value`
        importFeeName,t.prime_rate,d.name primeRate,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName,pfdd.discount_price discountPrice,co.contract_code contractCode,pfo.`value` ownerName,cb.o_id oId,
        importFeeName,t.prime_rate,d.name primeRate,co.contract_code contractCode,pfo.`value` ownerName,t.pay_order_id
        oId,
        d2.name feeTypeCdName,pfc.fee_type_cd feeTypeCd,t.state,d3.name stateName,t.fee_id feeId,pft.`value` repairId,
        t.detail_id,t.detail_id detailId,pf.payer_obj_id,pfb.value ownerId,concat(pa.num,'停车场',ps.num,'车位') psName,
        fad.amount withholdAmount,t.cashier_id cashierId,t.cashier_name cashierName,t.payable_amount payableAmount
        fad.amount withholdAmount,t.cashier_id cashierId,t.cashier_name cashierName,t.payable_amount
        payableAmount,pfc.fee_flag feeFlag,dt1.discountPrice discountPriceOne,dt1.discountSmallType
        discountSmallTypeOne,
        dt1.ruleName ruleNameOne,dt2.discountPrice discountPriceTwo,dt2.discountSmallType discountSmallTypeTwo,
        dt2.ruleName ruleNameTwo,dt3.discountPrice discountPriceThree,dt3.discountSmallType discountSmallTypeThree,
        dt3.ruleName ruleNameThree,dt4.discountPrice discountPriceFour,dt4.discountSmallType discountSmallTypeFour,
        dt4.ruleName ruleNameFour,dt5.discountPrice discountPriceFive,dt5.discountSmallType discountSmallTypeFive,
        dt5.ruleName ruleNameFive,dt6.discountPrice discountPriceSix,dt6.discountSmallType discountSmallTypeSix,
        dt6.ruleName ruleNameSix
        from pay_fee_detail t
        left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
@@ -1757,9 +1672,90 @@
        left join pay_fee_attrs pfb on t.fee_id = pfb.fee_id and pfb.spec_cd = '390007'
        left join pay_fee_attrs pfo on t.fee_id = pfo.fee_id and pfo.spec_cd = '390008'
        left join pay_fee_attrs pft on t.fee_id = pft.fee_id and pft.spec_cd = '390001'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt1
        on t.detail_id = dt1.detailId and dt1.discountSmallType = '1'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt2
        on t.detail_id = dt2.detailId and dt2.discountSmallType = '2'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt3
        on t.detail_id = dt3.detailId and dt3.discountSmallType = '3'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt4
        on t.detail_id = dt4.detailId and dt4.discountSmallType = '4'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt5
        on t.detail_id = dt5.detailId and dt5.discountSmallType = '5'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt6
        on t.detail_id = dt6.detailId and dt6.discountSmallType = '6'
        left join t_dict d on t.prime_rate = d.status_cd and d.table_name="pay_fee_detail" and
        d.table_columns="prime_rate"
        left join t_dict d2 on pfc.fee_type_cd = d2.status_cd and d2.table_name = "pay_fee_config" and d2.table_columns
@@ -1767,10 +1763,14 @@
        left join t_dict d3 on t.state = d3.status_cd and d3.table_name = "pay_fee_detail" and d3.table_columns =
        "state"
        LEFT JOIN contract co on pf.payer_obj_id = co.contract_id and co.status_cd = '0' and pf.payer_obj_type='7777'
        LEFT JOIN c_business cb on t.b_id = cb.b_id
        left join fee_account_detail fad on t.detail_id = fad.detail_id and t.community_id = fad.community_id and fad.status_cd = '0' and fad.state = '1002'
        left join fee_account_detail fad on t.detail_id = fad.detail_id and t.community_id = fad.community_id and
        fad.status_cd = '0' and fad.state = '1002'
        where t.status_cd = '0'
        and pf.status_cd = '0'
        and t.state != '1500'
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
@@ -1825,29 +1825,152 @@
        <if test="endTime !=null and endTime != ''">
            and t.create_time &lt;= #{endTime}
        </if>
        <if test="feeStartTime !=null and feeStartTime != ''">
            and t.start_time &gt;= #{feeStartTime}
        </if>
        <if test="feeEndTime !=null and feeEndTime != ''">
            and t.end_time &lt;= #{feeEndTime}
        </if>
        <if test="cashierId !=null and cashierId != ''">
            and t.cashier_id= #{cashierId}
        </if>
        <if test="cashierName !=null and cashierName != ''">
            and t.cashier_name= #{cashierName}
        </if>
        order by t.create_time desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
        ) t
    </select>
    <select id="queryAllPayFeeDetail" parameterType="Map" resultType="Map">
        select SUM(t.receivable_amount) allReceivableAmount,SUM(t.received_amount) allReceivedAmount
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryPayFeeDetail" parameterType="Map" resultType="Map">
        select pfc.fee_name feeName,f.floor_num floorNum,bu.unit_num unitNum,br.room_num roomNum,br.built_up_area
        builtUpArea ,oc.car_num carNum,
        pf.payer_obj_type payerObjType,t.start_time startTime,t.end_time endTime,t.create_time createTime,
        t.receivable_amount receivableAmount,t.received_amount receivedAmount,pfa.`value`
        importFeeName,t.prime_rate,d.name primeRate,co.contract_code contractCode,pfo.`value` ownerName,t.pay_order_id
        oId,
        d2.name feeTypeCdName,pfc.fee_type_cd feeTypeCd,t.state,d3.name stateName,t.fee_id feeId,pft.`value` repairId,
        t.detail_id,t.detail_id detailId,pf.payer_obj_id,pfb.value ownerId,concat(pa.num,'停车场',ps.num,'车位') psName,
        fad.amount withholdAmount,t.cashier_id cashierId,t.cashier_name cashierName,t.payable_amount
        payableAmount,pfc.fee_flag feeFlag,dt1.discountPrice discountPriceOne,dt1.discountSmallType
        discountSmallTypeOne,
        dt1.ruleName ruleNameOne,dt2.discountPrice discountPriceTwo,dt2.discountSmallType discountSmallTypeTwo,
        dt2.ruleName ruleNameTwo,dt3.discountPrice discountPriceThree,dt3.discountSmallType discountSmallTypeThree,
        dt3.ruleName ruleNameThree,dt4.discountPrice discountPriceFour,dt4.discountSmallType discountSmallTypeFour,
        dt4.ruleName ruleNameFour,dt5.discountPrice discountPriceFive,dt5.discountSmallType discountSmallTypeFive,
        dt5.ruleName ruleNameFive,dt6.discountPrice discountPriceSix,dt6.discountSmallType discountSmallTypeSix,
        dt6.ruleName ruleNameSix
        from pay_fee_detail t
        left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
        left join building_room br on pf.payer_obj_id = br.room_id and pf.payer_obj_type = '3333' and br.status_cd = '0'
        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.status_cd = '0' and oc.car_type_cd='1001'
        left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.car_type_cd='1001'
        LEFT JOIN parking_space ps on oc.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'
        left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
        left join pay_fee_attrs pfb on t.fee_id = pfb.fee_id and pfb.spec_cd = '390007'
        left join pay_fee_attrs pfo on t.fee_id = pfo.fee_id and pfo.spec_cd = '390008'
        left join pay_fee_attrs pft on t.fee_id = pft.fee_id and pft.spec_cd = '390001'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt1
        on t.detail_id = dt1.detailId and dt1.discountSmallType = '1'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt2
        on t.detail_id = dt2.detailId and dt2.discountSmallType = '2'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt3
        on t.detail_id = dt3.detailId and dt3.discountSmallType = '3'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt4
        on t.detail_id = dt4.detailId and dt4.discountSmallType = '4'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt5
        on t.detail_id = dt5.detailId and dt5.discountSmallType = '5'
        left JOIN
        (select t.detail_id detailId,t.receivable_amount receivableAmount,t.received_amount receivedAmount,
        pfdd.discount_price discountPrice,fdr.discount_small_type discountSmallType,fdr.rule_name
        ruleName
        from pay_fee_detail t
        left join pay_fee_detail_discount pfdd on t.detail_id = pfdd.detail_id and pfdd.status_cd = '0'
        left join fee_discount fd on pfdd.discount_id = fd.discount_id and fd.status_cd = '0'
        left join fee_discount_rule fdr on fd.rule_id = fdr.rule_id and fdr.status_cd = '0'
        where 1=1
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        ) dt6
        on t.detail_id = dt6.detailId and dt6.discountSmallType = '6'
        left join t_dict d on t.prime_rate = d.status_cd and d.table_name="pay_fee_detail" and
        d.table_columns="prime_rate"
        left join t_dict d2 on pfc.fee_type_cd = d2.status_cd and d2.table_name = "pay_fee_config" and d2.table_columns
        = "fee_type_cd"
        left join t_dict d3 on t.state = d3.status_cd and d3.table_name = "pay_fee_detail" and d3.table_columns =
        "state"
        LEFT JOIN contract co on pf.payer_obj_id = co.contract_id and co.status_cd = '0' and pf.payer_obj_type='7777'
        left join fee_account_detail fad on t.detail_id = fad.detail_id and t.community_id = fad.community_id and
        fad.status_cd = '0' and fad.state = '1002'
        where t.status_cd = '0'
        and pf.status_cd = '0'
        and t.state != '1500'
        <if test="detailId !=null and detailId != ''">
            and t.detail_id= #{detailId}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
@@ -1877,6 +2000,92 @@
        </if>
        <if test="configId !=null and configId != ''">
            and pfc.config_id= #{configId}
        </if>
        <if test="objId !=null and objId != ''">
            and pf.payer_obj_id = #{objId}
        </if>
        <if test="feeName !=null and feeName != ''">
            and t.fee_name= #{feeName}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="primeRate != null and primeRate != ''">
            and t.prime_rate = #{primeRate}
        </if>
        <if test="state != null and state != ''">
            and t.state = #{state}
        </if>
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pfc.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="startTime !=null and startTime != ''">
            and t.create_time &gt;= #{startTime}
        </if>
        <if test="endTime !=null and endTime != ''">
            and t.create_time &lt;= #{endTime}
        </if>
        <if test="feeStartTime !=null and feeStartTime != ''">
            and t.start_time &gt;= #{feeStartTime}
        </if>
        <if test="feeEndTime !=null and feeEndTime != ''">
            and t.end_time &lt;= #{feeEndTime}
        </if>
        <if test="cashierId !=null and cashierId != ''">
            and t.cashier_id= #{cashierId}
        </if>
        <if test="cashierName !=null and cashierName != ''">
            and t.cashier_name= #{cashierName}
        </if>
        order by t.create_time desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <select id="queryAllPayFeeDetail" parameterType="Map" resultType="Map">
        select SUM(t.receivable_amount) allReceivableAmount,SUM(t.received_amount) allReceivedAmount
        from pay_fee_detail t
        left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0'
        left join building_room br on pf.payer_obj_id = br.room_id and pf.payer_obj_type = '3333' and br.status_cd = '0'
        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        left join owner_car oc on pf.payer_obj_id = oc.car_id and oc.status_cd = '0' and oc.car_type_cd='1001'
        left join pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390002'
        where t.status_cd = '0' and t.state != '1500'
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="unitId !=null and unitId != ''">
            and bu.unit_id= #{unitId}
        </if>
        <if test="unitNum !=null and unitNum != ''">
            and bu.unit_num= #{unitNum}
        </if>
        <if test="floorId !=null and floorId != ''">
            and f.floor_id = #{floorId}
        </if>
        <if test="floorNum !=null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
        <if test="objName !=null and objName != ''">
            and t.obj_name= #{objName}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and t.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and t.fee_month= #{feeMonth}
        </if>
        <if test="feeId !=null and feeId != ''">
            and t.fee_id= #{feeId}
        </if>
        <if test="configId !=null and configId != ''">
            and pfc.config_id= #{configId}
        </if>
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pfc.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="objId !=null and objId != ''">
            and pf.payer_obj_id= #{objId}
@@ -1919,6 +2128,7 @@
        left join t_dict d on t.prime_rate = d.status_cd and d.table_name="pay_fee_detail" and
        d.table_columns="prime_rate"
        where t.status_cd = '0'
        and pfdd.discount_price > 0
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
@@ -1949,6 +2159,9 @@
        <if test="configId !=null and configId != ''">
            and pfc.config_id= #{configId}
        </if>
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pfc.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="objId !=null and objId != ''">
            and pf.payer_obj_id= #{objId}
        </if>
@@ -1976,113 +2189,55 @@
    <select id="queryDeadlineFeeCount" parameterType="Map" resultType="Map">
        select count(1) count
        from (
        SELECT
        t.obj_name objName,
        t.fee_name feeName,
        t.deadline_time deadlineTime
        FROM
        report_fee_month_statistics t
        inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
        where t.status_cd = '0'
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="unitId !=null and unitId != ''">
            and bu.unit_id= #{unitId}
        </if>
        <if test="floorId !=null and floorId != ''">
            and f.floor_id = #{floorId}
        from pay_fee_detail_month t
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and t.detail_id = '-1'
        <if test="configId !=null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="objName !=null and objName != ''">
            and t.obj_name= #{objName}
            and t.obj_name like CONCAT('%',#{objName},'%')
        </if>
        <if test="objNameNum != null and objNameNum != ''">
            and t.obj_name_num= #{objNameNum}
        <if test="ownerName !=null and ownerName != ''">
            and t.owner_name like CONCAT('%',#{ownerName},'%')
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and t.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and t.fee_month= #{feeMonth}
        </if>
        <if test="feeId !=null and feeId != ''">
            and t.fee_id= #{feeId}
        </if>
        <if test="configId !=null and configId != ''">
            and t.config_id= #{configId}
        </if>
        <if test="objId !=null and objId != ''">
            and t.obj_id= #{objId}
        </if>
        <if test="feeName !=null and feeName != ''">
            and t.fee_name= #{feeName}
        <if test="link !=null and link != ''">
            and t.link = #{link}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="startTime !=null and startTime != ''">
        <if test="startTime !=null and startTime !=''">
            and t.deadline_time &gt;= #{startTime}
        </if>
        <if test="endTime !=null and endTime != ''">
            and t.deadline_time &lt;= #{endTime}
        </if>
        ) t
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryDeadlineFee" parameterType="Map" resultType="Map">
        SELECT
        select
        t.obj_name objName,
        t.obj_name_num objNameNum,
        t.obj_type objType,
        pf.payer_obj_type objType,
        t.fee_name feeName,
        t.deadline_time deadlineTime,
        t.update_time updateTime
        FROM
        report_fee_month_statistics t
        inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        left join building_room br on t.obj_id = br.room_id and t.obj_type = '3333' and br.status_cd = '0'
        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        left join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.community_id = t.community_id and pf.status_cd = '0'
        where t.status_cd = '0'
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="unitId !=null and unitId != ''">
            and bu.unit_id= #{unitId}
        </if>
        <if test="floorId !=null and floorId != ''">
            and f.floor_id = #{floorId}
        t.deadline_time deadlineTime
        from pay_fee_detail_month t
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and t.detail_id = '-1'
        <if test="configId !=null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="objName !=null and objName != ''">
            and t.obj_name= #{objName}
            and t.obj_name like CONCAT('%',#{objName},'%')
        </if>
        <if test="objNameNum != null and objNameNum != ''">
            and t.obj_name_num= #{objNameNum}
        <if test="ownerName !=null and ownerName != ''">
            and t.owner_name like CONCAT('%',#{ownerName},'%')
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and t.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and t.fee_month= #{feeMonth}
        </if>
        <if test="feeId !=null and feeId != ''">
            and t.fee_id= #{feeId}
        </if>
        <if test="configId !=null and configId != ''">
            and t.config_id= #{configId}
        </if>
        <if test="objId !=null and objId != ''">
            and t.obj_id= #{objId}
        </if>
        <if test="feeName !=null and feeName != ''">
            and t.fee_name= #{feeName}
        <if test="link !=null and link != ''">
            and t.link = #{link}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
@@ -2102,24 +2257,34 @@
    <select id="queryPrePaymentNewCount" parameterType="Map" resultType="Map">
        select count(1) count
        from (
        select pfc.fee_name feeName, f.floor_num floorNum,bu.unit_num unitNum,br.room_num roomNum,t.end_time endTime
        ,oc.car_num carNum
        select pfc.fee_name feeName,pfa.`value` objName,pfa1.`value` link,pfa2.`value` ownerName, t.end_time endTime ,
        t.payer_obj_type payerObjType
        from pay_fee t
        inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        left join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
        left join owner_car oc on t.payer_obj_id = oc.car_id and t.payer_obj_type = '6666' and oc.status_cd = '0' and
        oc.car_type_cd='1001'
        LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390012' and pfa.status_cd = '0'
        LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390009' and pfa1.status_cd = '0'
        LEFT JOIN pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008' and pfa2.status_cd = '0'
        where t.state = '2008001'
        and t.status_cd = '0'
        <if test="ownerName != null and ownerName != ''">
            and pfa2.value like concat('%' #{ownerName} ,'%')
        </if>
        <if test="objName != null and objName != ''">
            and pfa.`value` like concat('%',#{objName},'%')
        </if>
        <if test="link != null and link != ''">
            and pfa1.`value` = #{link}
        </if>
        <if test="configId !=null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="startTime !=null and startTime != ''">
            and t.end_time &gt;= #{startTime}
        </if>
        <if test="endTime !=null and endTime != ''">
        <if test="endTime !=null  and endTime != ''">
            and t.end_time &lt;= #{endTime}
        </if>
        ) t
@@ -2127,17 +2292,27 @@
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryPrePayment" parameterType="Map" resultType="Map">
        select pfc.fee_name feeName, f.floor_num floorNum,bu.unit_num unitNum,br.room_num roomNum,t.end_time endTime ,
        oc.car_num carNum,t.payer_obj_type payerObjType
        select pfc.fee_name feeName,pfa.`value` objName,pfa1.`value` link,pfa2.`value` ownerName, t.end_time endTime ,
        t.payer_obj_type payerObjType
        from pay_fee t
        inner join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        left join building_room br on t.payer_obj_id = br.room_id and t.payer_obj_type = '3333' and br.status_cd = '0'
        left join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        left join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
        left join owner_car oc on t.payer_obj_id = oc.car_id and t.payer_obj_type = '6666' and oc.status_cd = '0' and
        oc.car_type_cd='1001'
        LEFT JOIN pay_fee_attrs pfa on t.fee_id = pfa.fee_id and pfa.spec_cd = '390012' and pfa.status_cd = '0'
        LEFT JOIN pay_fee_attrs pfa1 on t.fee_id = pfa1.fee_id and pfa1.spec_cd = '390009' and pfa1.status_cd = '0'
        LEFT JOIN pay_fee_attrs pfa2 on t.fee_id = pfa2.fee_id and pfa2.spec_cd = '390008' and pfa2.status_cd = '0'
        where t.state = '2008001'
        and t.status_cd = '0'
        <if test="ownerName != null and ownerName != ''">
            and pfa2.value like concat('%' #{ownerName} ,'%')
        </if>
        <if test="objName != null and objName != ''">
            and pfa.`value` like concat('%',#{objName},'%')
        </if>
        <if test="link != null and link != ''">
            and pfa1.`value` = #{link}
        </if>
        <if test="configId !=null and configId != ''">
            and t.config_id = #{configId}
        </if>
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
@@ -2352,9 +2527,9 @@
    </select>
    <select id="getRepairWithOutPage" parameterType="Map" resultType="Map">
        select r.staff_id staffId,r.staff_name staffName,r.state, t.name stateName,u.score, count(*) amount from
        select r.staff_id staffId,u.name staffName,r.state,u.score, count(*) amount from
        r_repair_user r
        left join t_dict t on t.table_name="r_repair_user" and t.table_columns="state" and t.status_cd=r.state
        left join t_dict td on td.table_name="r_repair_user" and td.table_columns="state" and td.status_cd=r.state
        left join u_user u on u.user_id = r.staff_id and u.status_cd = '0'
        where r.state != '10005' and r.status_cd = '0'
        <if test="ruId != null and ruId != ''">
@@ -2406,12 +2581,12 @@
            and r.create_time = #{createTime}
        </if>
        group by r.staff_id,r.state
        order by r.create_time desc
    </select>
    <select id="queryRepairForStaff" parameterType="Map" resultType="Map">
        SELECT r.staff_id staffId,r.staff_name staffName,r.state FROM r_repair_user r
        SELECT r.staff_id staffId,u.name staffName,r.state,td.name stateName FROM r_repair_user r
        inner join u_user u on u.user_id = r.staff_id and u.status_cd = '0'
        left join t_dict td on r.state = td.status_cd and td.table_name = 'r_repair_user' and td.table_columns = 'state'
        WHERE r.state!='10005' AND r.state!='10009' AND r.state!='11000' AND
        r.state!='12000' AND r.state != '10007' AND r.status_cd = '0' AND
        r.repair_event != 'payUser' AND r.repair_event != 'startUser' AND r.staff_id != '-1'
@@ -2421,69 +2596,102 @@
        <if test="staffId != null and staffId != ''">
            and r.staff_id = #{staffId}
        </if>
        <if test="state != null and state != ''">
            and r.state = #{state}
        </if>
        <if test="beginStartTime != null and beginStartTime !=''">
            and r.start_time &gt;= #{beginStartTime}
        </if>
        <if test="beginEndTime != null and beginEndTime !=''">
            and r.start_time &lt;= #{beginEndTime}
        </if>
        <if test="finishStartTime != null and finishStartTime !=''">
            and r.end_time &gt;= #{finishStartTime}
        </if>
        <if test="finishEndTime != null and finishEndTime !=''">
            and r.end_time &lt;= #{finishEndTime}
        </if>
        group by r.staff_id
        order by r.create_time desc
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <select id="getReceivableInformation" parameterType="Map" resultType="Map">
        select a.receivableAmount,a.receivedAmount, IF(a.receivableAmount &lt;
        a.oweReceivedAmount,'0',a.receivableAmount-a.oweReceivedAmount) oweAmount
        select a.receivableAmount,
               a.receivedAmount,
               IF(a.receivableAmount &lt;
                  a.oweReceivedAmount, '0', a.receivableAmount - a.oweReceivedAmount) oweAmount
        from (
        select sum(t.his_owe_amount+t.cur_receivable_amount)
        receivableAmount,sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount,
        sum(t.cur_received_amount+t.his_owe_received_amount) oweReceivedAmount
        from report_fee_month_statistics t
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and t.fee_year= #{feeYear}
        and t.fee_month= #{feeMonth}
        and t.community_id = #{communityId}
        ) a
                 select sum(t.his_owe_amount + t.cur_receivable_amount)
                                                                                                       receivableAmount,
                        sum(t.cur_received_amount + t.his_owe_received_amount + t.pre_received_amount) receivedAmount,
                        sum(t.cur_received_amount + t.his_owe_received_amount)                         oweReceivedAmount
                 from report_fee_month_statistics t
                          inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
                 where 1 = 1
                   and t.fee_year = #{feeYear}
                   and t.fee_month = #{feeMonth}
                   and t.community_id = #{communityId}
             ) a
    </select>
    <select id="getFloorReceivableInformation" parameterType="Map" resultType="Map">
        select a.floorNum,a.`name`,a.receivableAmount,a.receivedAmount, IF(a.receivableAmount &lt;
        a.oweReceivedAmount,'0',a.receivableAmount-a.oweReceivedAmount) oweAmount
        select a.floorNum,
               a.`name`,
               a.receivableAmount,
               a.receivedAmount,
               IF(a.receivableAmount &lt;
                  a.oweReceivedAmount, '0', a.receivableAmount - a.oweReceivedAmount) oweAmount
        from (
        select f.floor_num floorNum,f.`name`,sum(t.his_owe_amount+t.cur_receivable_amount)
        receivableAmount,sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount,
        sum(t.cur_received_amount+t.his_owe_received_amount) oweReceivedAmount
        from report_fee_month_statistics t
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        inner join building_room br on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
        t.community_id and br.status_cd = '0'
        inner join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
        inner join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
        where 1=1
        and t.fee_year= #{feeYear}
        and t.fee_month= #{feeMonth}
        and t.community_id = #{communityId}
        group by f.floor_num ,f.`name`
        ) a
                 select f.floor_num                                                                    floorNum,
                        f.`name`,
                        sum(t.his_owe_amount + t.cur_receivable_amount)
                                                                                                       receivableAmount,
                        sum(t.cur_received_amount + t.his_owe_received_amount + t.pre_received_amount) receivedAmount,
                        sum(t.cur_received_amount + t.his_owe_received_amount)                         oweReceivedAmount
                 from report_fee_month_statistics t
                          inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
                          inner join building_room br
                                     on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
                                                                                          t.community_id and
                                        br.status_cd = '0'
                          inner join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
                          inner join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
                 where 1 = 1
                   and t.fee_year = #{feeYear}
                   and t.fee_month = #{feeMonth}
                   and t.community_id = #{communityId}
                 group by f.floor_num, f.`name`
             ) a
    </select>
    <select id="getFeeConfigReceivableInformation" parameterType="Map" resultType="Map">
        select a.feeName,a.receivableAmount,a.receivedAmount, IF(a.receivableAmount &lt;
        a.oweReceivedAmount,'0',a.receivableAmount-a.oweReceivedAmount) oweAmount
        select a.feeName,
               a.receivableAmount,
               a.receivedAmount,
               IF(a.receivableAmount &lt;
                  a.oweReceivedAmount, '0', a.receivableAmount - a.oweReceivedAmount) oweAmount
        from (
        select t.fee_name feeName,sum(t.his_owe_amount+t.cur_receivable_amount)
        receivableAmount,sum(t.cur_received_amount+t.his_owe_received_amount+t.pre_received_amount) receivedAmount,
        sum(t.cur_received_amount+t.his_owe_received_amount) oweReceivedAmount
        from report_fee_month_statistics t
        inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        left join building_room br on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
        t.community_id and br.status_cd = '0'
        left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
        left join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
        where 1=1
        and t.fee_year= #{feeYear}
        and t.fee_month= #{feeMonth}
        and t.community_id = #{communityId}
        group by t.fee_name
        ) a
                 select t.fee_name                                                                     feeName,
                        sum(t.his_owe_amount + t.cur_receivable_amount)
                                                                                                       receivableAmount,
                        sum(t.cur_received_amount + t.his_owe_received_amount + t.pre_received_amount) receivedAmount,
                        sum(t.cur_received_amount + t.his_owe_received_amount)                         oweReceivedAmount
                 from report_fee_month_statistics t
                          inner join pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
                          left join building_room br
                                    on br.room_id = t.obj_id and t.obj_type = '3333' and br.community_id =
                                                                                         t.community_id and
                                       br.status_cd = '0'
                          left join building_unit bu on bu.unit_id = br.unit_id and bu.status_cd = '0'
                          left join f_floor f on f.floor_id = bu.floor_id and f.status_cd = '0'
                 where 1 = 1
                   and t.fee_year = #{feeYear}
                   and t.fee_month = #{feeMonth}
                   and t.community_id = #{communityId}
                 group by t.fee_name
             ) a
    </select>
@@ -2491,16 +2699,35 @@
    <select id="queryNoFeeRoomsCount" parameterType="Map" resultType="Map">
        select count(1) count
        from building_room t
            inner join building_unit bu
        inner join building_unit bu
        on t.unit_id = bu.unit_id and bu.status_cd = '0'
            inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        left join building_owner_room_rel borr on borr.room_id = t.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'
          and not exists (
            select 1 from pay_fee pf where t.room_id = pf.payer_obj_id
          and pf.status_cd = '0'
          and pf.state = '2008001'
            )
          and t.community_id = #{communityId}
        and not exists (
        select 1 from pay_fee pf where t.room_id = pf.payer_obj_id
        and pf.status_cd = '0'
        and pf.state = '2008001'
        )
        <if test="communityId != null and communityId !=''">
            and t.community_id = #{communityId}
        </if>
        <if test="floorId != null and floorId !=''">
            and f.floor_id = #{floorId}
        </if>
        <if test="unitId != null and unitId !=''">
            and bu.unit_id = #{unitId}
        </if>
        <if test="roomId != null and roomId !=''">
            and t.room_id = #{roomId}
        </if>
        <if test="ownerName != null and ownerName !=''">
            and bo.name like '%${ownerName}%'
        </if>
        <if test="link != null and link !=''">
            and bo.link = #{link}
        </if>
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
@@ -2516,7 +2743,24 @@
        and not exists(
        select 1 from pay_fee pf where t.room_id = pf.payer_obj_id and pf.status_cd = '0' and pf.state = '2008001'
        )
        and t.community_id = #{communityId}
        <if test="communityId != null and communityId !=''">
            and t.community_id = #{communityId}
        </if>
        <if test="floorId != null and floorId !=''">
            and f.floor_id = #{floorId}
        </if>
        <if test="unitId != null and unitId !=''">
            and bu.unit_id = #{unitId}
        </if>
        <if test="roomId != null and roomId !=''">
            and t.room_id = #{roomId}
        </if>
        <if test="ownerName != null and ownerName !=''">
            and bo.name like '%${ownerName}%'
        </if>
        <if test="link != null and link !=''">
            and bo.link = #{link}
        </if>
        order by bo.name
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
@@ -2779,122 +3023,135 @@
        group by pfd.state
    </select>
    <select id="queryHuaningOweFeeCount" parameterType="Map" resultType="Map">
        select count(1) count
        from (
        select a.floorNum,a.oweAmount,b.curOweAmount
        from
        (select t.floor_num floorNum,SUM(rfms.owe_amount) oweAmount
        from f_floor t
        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        LEFT JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.obj_type = '3333' and
        rfms.status_cd = '0'
        where t.status_cd = '0'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="objName !=null and objName != ''">
            and rfms.obj_name= #{objName}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and rfms.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and rfms.fee_month= #{feeMonth}
        </if>
        GROUP BY t.floor_num
        ) a,
        (select t.floor_num floorNum,SUM(curT.owe_amount) curOweAmount
        from f_floor t
        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner join report_fee_month_statistics curT on curT.obj_id = br.room_id and curT.obj_type = '3333' and
        curT.status_cd = '0' and curT.community_id = t.community_id
        where t.status_cd = '0'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and curT.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and curT.fee_month= #{feeMonth}
        </if>
        GROUP BY t.floor_num
        ) b
        where a.floorNum = b.floorNum
        <if test="floorId !=null and floorId != ''">
            and a.floor_id = #{floorId}
        </if>
        ) t
        from f_floor f
        where 1=1
          and f.community_id = #{communityId}
          and f.status_cd = '0'
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryHuaningOweFee" parameterType="Map" resultType="Map">
        select a.floorNum,a.oweAmount,b.curOweAmount
        from
        (select t.floor_num floorNum,SUM(rfms.owe_amount) oweAmount
        from f_floor t
        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        LEFT JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.obj_type = '3333' and
        rfms.status_cd = '0'
        where t.status_cd = '0'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        select
        f.floor_num floorNum,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{endTime}
        ) oweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="objName !=null and objName != ''">
            and rfms.obj_name= #{objName}
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{endTime}
        and t.cur_month_time &gt;= #{startTime}
        ) curOweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and rfms.fee_year= #{feeYear}
        and t.detail_id = '-1'
        and t.cur_month_time &lt; #{startTime}
        ) preOweAmount
        from f_floor f
        where 1=1
        and f.community_id = #{communityId}
        <if test="floorNum != null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and rfms.fee_month= #{feeMonth}
        </if>
        GROUP BY t.floor_num
        ) a,
        (select t.floor_num floorNum,SUM(curT.owe_amount) curOweAmount
        from f_floor t
        left join building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        left join building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner join report_fee_month_statistics curT on curT.obj_id = br.room_id and curT.obj_type = '3333' and
        curT.status_cd = '0' and curT.community_id = t.community_id
        where t.status_cd = '0'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        </if>
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
        <if test="feeYear !=null and feeYear != ''">
            and curT.fee_year= #{feeYear}
        </if>
        <if test="feeMonth !=null and feeMonth != ''">
            and curT.fee_month= #{feeMonth}
        </if>
        GROUP BY t.floor_num
        ) b
        where a.floorNum = b.floorNum
        <if test="floorId !=null and floorId != ''">
            and a.floor_id = #{floorId}
        </if>
        and f.status_cd = '0'
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <select id="queryHuaningOweFeeCounts" parameterType="Map" resultType="Map">
        select count(1) count from (
        select
        f.floor_num floorNum,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{endTime}
        ) oweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{endTime}
        and t.cur_month_time &gt;= #{startTime}
        ) curOweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and t.detail_id = '-1'
        and t.cur_month_time &lt; #{startTime}
        ) preOweAmount
        from f_floor f
        where 1=1
        and f.community_id = #{communityId}
        <if test="floorNum != null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
        and f.status_cd = '0'
        ) st
    </select>
    <select id="queryHuaningPayFeeCount" parameterType="Map" resultType="Map">
        select count(1) count
@@ -2910,95 +3167,232 @@
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryHuaningPayFee" parameterType="Map" resultType="Map">
        select
        a.floorNum,f.receivableAmount,a.receivedAmount,b.receivedAmount1,c.receivedAmount2,d.receivedAmount3,e.receivedAmount4
        from
        (select t.floor_num floorNum,sum(pfd.received_amount) receivedAmount
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        f.floor_num floorNum,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) a,
        (select t.floor_num floorNum,sum(pfdm1.received_amount ) receivedAmount1
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        LEFT JOIN pay_fee_detail_month pfdm1 on pf.fee_id = pfdm1.fee_id and pfd.detail_id = pfdm1.detail_id and
        pfdm1.status_cd = '0' and pfdm1.detail_year = #{year} and pfdm1.detail_month &lt; #{month}
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.cur_month_time = #{endTime}
        ) receivableAmount,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) b,
        (select t.floor_num floorNum,sum(pfdm2.received_amount ) receivedAmount2
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        LEFT JOIN pay_fee_detail_month pfdm2 on pf.fee_id = pfdm2.fee_id and pfd.detail_id = pfdm2.detail_id and
        pfdm2.status_cd = '0' and pfdm2.detail_year = #{year} and pfdm2.detail_month = #{month}
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.detail_id != '-1'
        ) receivedAmount,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) c,
        (select t.floor_num floorNum,sum(pfdm3.received_amount ) receivedAmount3
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        LEFT JOIN pay_fee_detail_month pfdm3 on pf.fee_id = pfdm3.fee_id and pfd.detail_id = pfdm3.detail_id and
        pfdm3.status_cd = '0' and pfdm3.detail_year = #{nextYear} and pfdm3.detail_month = #{nextMonth}
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time &lt; #{endTime}
        and t.cur_month_time &gt;= #{startTime}
        and t.detail_id != '-1'
        ) receivedAmount1,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) d,
        (select t.floor_num floorNum,sum(pfdm4.received_amount ) receivedAmount4
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN pay_fee pf on pf.payer_obj_id = br.room_id and pf.status_cd = '0'
        inner join pay_fee_detail pfd on pf.fee_id = pfd.fee_id and pfd.status_cd = '0'
        LEFT JOIN pay_fee_detail_month pfdm4 on pf.fee_id = pfdm4.fee_id and pfd.detail_id = pfdm4.detail_id and
        pfdm4.status_cd = '0' and pfdm4.detail_year &lt; #{year}
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time = #{endTime}
        and t.detail_id != '-1'
        ) receivedAmount2,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and t.status_cd = '0'
        and DATE_FORMAT(pfd.create_time,'%Y-%m') = #{yearMonth}
        and t.community_id= #{communityId}
        GROUP BY floor_num
        ) e,
        (select t.floor_num floorNum,SUM(rfms.receivable_amount) receivableAmount
        from f_floor t
        inner JOIN building_unit bu on t.floor_id = bu.floor_id and bu.status_cd = '0'
        inner JOIN building_room br on br.unit_id = bu.unit_id and br.status_cd = '0'
        inner JOIN report_fee_month_statistics rfms on rfms.obj_id = br.room_id and rfms.status_cd = '0'
        where t.community_id = #{communityId}
        and rfms.fee_year = #{year}
        and rfms.fee_month = #{month}
        group by t.floor_num
        ) f
        where a.floorNum = b.floorNum
        and b.floorNum = c.floorNum
        and c.floorNum = d.floorNum
        and d.floorNum = e.floorNum
        and e.floorNum = f.floorNum
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time &gt;= #{nextMonthTime}
        and t.detail_id != '-1'
        ) receivedAmount3,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time &lt; #{startTime}
        and t.detail_id != '-1'
        ) receivedAmount4
        from f_floor f
        where 1=1
        and f.community_id = #{communityId}
        <if test="floorNum != null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
        and f.status_cd = '0'
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <select id="queryHuaningPayFeeCounts" parameterType="Map" resultType="Map">
        select count(1) count
        from (
        select
        f.floor_num floorNum,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.cur_month_time = #{endTime}
        ) receivableAmount,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.detail_id != '-1'
        ) receivedAmount,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time &lt; #{endTime}
        and t.cur_month_time &gt;= #{startTime}
        and t.detail_id != '-1'
        ) receivedAmount1,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time = #{endTime}
        and t.detail_id != '-1'
        ) receivedAmount2,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time &gt;= #{nextMonthTime}
        and t.detail_id != '-1'
        ) receivedAmount3,
        (
        select ifnull(SUM(t.received_amount),0)
        from pay_fee_detail_month t
        inner join building_room br on t.obj_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 pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        and bu.floor_id = f.floor_id
        and t.community_id = f.community_id
        and t.pay_fee_time &gt;= #{endTime}
        and t.pay_fee_time &lt; #{nextMonthTime}
        and t.cur_month_time &lt; #{startTime}
        and t.detail_id != '-1'
        ) receivedAmount4
        from f_floor f
        where 1=1
        and f.community_id = #{communityId}
        <if test="floorNum != null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
        and f.status_cd = '0'
        ) st
    </select>
    <select id="queryHuaningPayFeeTwoCount" parameterType="Map" resultType="Map">
        select count(1) count
        from (
@@ -3121,38 +3515,90 @@
            limit #{page}, #{row}
        </if>
    </select>
    <select id="queryHuaningOweFeeDetailCount" parameterType="Map" resultType="Map">
        select count(1) count
        from (
        select t.payer_obj_name payerObjName,br.built_up_area builtUpArea,pfc.square_price squarePrice, t.fee_id
        feeId,t.end_time startTime,t.deadline_time endTime,t.amount_owed oweAmount
        from report_owe_fee t
        left join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
        left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        where t.amount_owed > 0
        and pfc.fee_type_cd = '888800010001'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        select
        count(1) count
        from building_room br
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
        inner join pay_fee pf on rof.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and br.community_id = #{communityId}
        and br.status_cd = '0'
        and rof.amount_owed > 0
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        ) tt
        <if test="floorId != null and floorId != ''">
            and f.floor_id = #{floorId}
        </if>
        <if test="floorNum != null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="queryHuaningOweFeeDetail" parameterType="Map" resultType="Map">
        select t.payer_obj_name payerObjName,br.built_up_area builtUpArea,pfc.square_price squarePrice, t.fee_id
        feeId,t.end_time startTime,t.deadline_time endTime,t.amount_owed oweAmount
        from report_owe_fee t
        left join building_room br on t.payer_obj_id = br.room_id and br.status_cd = '0'
        left join pay_fee_config pfc on t.config_id = pfc.config_id and pfc.status_cd = '0'
        where t.amount_owed > 0
        and pfc.fee_type_cd = '888800010001'
        <if test="communityId !=null and communityId != ''">
            and t.community_id= #{communityId}
        select
        f.floor_num floorNum,
        concat(f.floor_num,'-',bu.unit_num,'-',br.room_num) roomName,
        br.built_up_area builtUpArea,
        rof.fee_name feeName,
        rof.end_time endTime,
        rof.deadline_time deadlineTime,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        where 1=1
        and t.fee_id = rof.fee_id
        and t.community_id = f.community_id
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{startTime}
        ) oweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        where 1=1
        and t.fee_id = rof.fee_id
        and t.community_id = f.community_id
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{startTime}
        and t.cur_month_time &gt;= #{endTime}
        ) curOweAmount,
        (
        select ifnull(SUM(t.receivable_amount),0)
        from pay_fee_detail_month t
        where 1=1
        and t.fee_id = rof.fee_id
        and t.community_id = f.community_id
        and t.detail_id = '-1'
        and t.cur_month_time &lt;= #{startTime}
        ) preOweAmount
        from building_room br
        inner join building_unit bu on br.unit_id = bu.unit_id and bu.status_cd = '0'
        inner join f_floor f on bu.floor_id = f.floor_id and f.status_cd = '0'
        inner join report_owe_fee rof on br.room_id = rof.payer_obj_id
        inner join pay_fee pf on rof.fee_id = pf.fee_id and pf.status_cd = '0'
        where 1=1
        and br.community_id = #{communityId}
        and br.status_cd = '0'
        and rof.amount_owed > 0
        <if test="feeTypeCd != null and feeTypeCd != ''">
            and pf.fee_type_cd = #{feeTypeCd}
        </if>
        <if test="floorId != null and floorId != ''">
            and f.floor_id = #{floorId}
        </if>
        <if test="floorNum != null and floorNum != ''">
            and f.floor_num = #{floorNum}
        </if>
        <if test="page != -1 and page != null ">
            limit #{page}, #{row}
        </if>
    </select>
    <!-- 查询费用月统计信息 add by wuxw 2018-07-03 -->
    <select id="getReceivedAmountByMonth" parameterType="Map" resultType="Map">
        select ifnull(sum(t.received_amount),0) total