java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
@@ -1642,10 +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,
        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,d.name,d2.name feeTypeCdName,
        pfc.fee_type_cd feeTypeCd,t.state,d3.name stateName
        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'
@@ -1653,15 +1666,111 @@
        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 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"
        where t.status_cd = '0' and pf.status_cd = '0'
        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>
@@ -1693,7 +1802,7 @@
            and pfc.config_id= #{configId}
        </if>
        <if test="objId !=null and objId != ''">
            and pf.payer_obj_id= #{objId}
            and pf.payer_obj_id = #{objId}
        </if>
        <if test="feeName !=null and feeName != ''">
            and t.fee_name= #{feeName}
@@ -1737,12 +1846,19 @@
        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,t.pay_order_id
        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,t.remark
        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'
@@ -1756,9 +1872,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
@@ -1771,6 +1968,9 @@
        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>
@@ -1853,8 +2053,7 @@
        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 in ('1400','1000','1200')
        where t.status_cd = '0' and t.state != '1500'
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
@@ -1884,6 +2083,9 @@
        </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}
@@ -1926,7 +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
        and pfdd.discount_price > 0
        <if test="roomNum !=null and roomNum != ''">
            and br.room_num= #{roomNum}
        </if>
@@ -1956,6 +2158,9 @@
        </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}
@@ -2494,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 -->
@@ -2519,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}