xuhy
2025-04-09 d66b806d685672f2f817986e89f69fb09d130f11
ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml
@@ -45,6 +45,7 @@
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        LEFT JOIN t_bill_type_sort_weight sw on sw.code=b.pay_fees_status
        <where>
            b.disabled=0
            <if test="query.payFeesStatus != null">
@@ -69,8 +70,50 @@
                and b.bill_type = #{query.billType}
            </if>
        </where>
        order by b.payable_fees_time desc,b.create_time desc
        order by sw.sort_weight desc,b.payable_fees_time asc
<!--        order by b.payable_fees_time desc,b.create_time desc-->
    </select>
    <select id="pageForApplet" resultType="com.ruoyi.system.dto.TBillDto">
        SELECT
        b.*,
        t.resident_name as residentName,
        t.phone,
        t.account,
        h.house_name as houseName
        FROM
        t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        LEFT JOIN t_bill_type_sort_weight sw on sw.code=b.pay_fees_status
        <where>
            b.disabled=0
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
            </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
        order by sw.sort_weight desc,b.payable_fees_time asc
    </select>
    <select id="getBillList" resultType="com.ruoyi.system.dto.TBillDto">
        SELECT
        b.*,
@@ -157,31 +200,128 @@
    </select>
    <select id="statisticsAllRent" resultType="java.math.BigDecimal">
        SELECT ifnull(sum(payable_fees_money),0) as amount FROM t_bill where pay_fees_status!='5'
        <if test='busDeptId != null and busDeptId != "" and busDeptId!="0"'>
            and business_dept_id = #{busDeptId}
        </if>
        SELECT ifnull(sum(payable_fees_money),0) as amount FROM t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        <where>
            b.disabled=0 and b.pay_fees_status!='5'
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
            </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
    </select>
    <select id="statisticsNoPay" resultType="java.math.BigDecimal">
        SELECT ifnull(sum(outstanding_money),0) as amount FROM t_bill where pay_fees_status!='3' and pay_fees_status!='5'
        <if test='busDeptId != null and busDeptId != "" and busDeptId!="0"'>
            and business_dept_id = #{busDeptId}
        </if>
        SELECT ifnull(sum(outstanding_money),0) as amount FROM t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        <where>
            b.disabled=0 and b.pay_fees_status!='3' and b.pay_fees_status!='5'
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
            </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
    </select>
    <select id="statisticsPayed" resultType="java.math.BigDecimal">
        SELECT ifnull(sum(pay_fees_money),0) as amount FROM t_bill where pay_fees_status!='5'
        <if test='busDeptId != null and busDeptId != "" and busDeptId!="0"'>
            and business_dept_id = #{busDeptId}
        </if>
        SELECT ifnull(sum(pay_fees_money),0) as amount FROM t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        <where>
            b.disabled=0 and b.pay_fees_status!='5'
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
            </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
    </select>
    <select id="statisticsOverdue" resultType="java.math.BigDecimal">
        SELECT ifnull(sum(outstanding_money),0) as amount FROM t_bill where pay_fees_status='4'
        <if test='busDeptId != null and busDeptId != "" and busDeptId!="0"'>
            and business_dept_id = #{busDeptId}
        </if>
        SELECT ifnull(sum(outstanding_money),0) as amount FROM t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        <where>
            b.disabled=0 and b.pay_fees_status='4'
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
            </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            <if test='query.businessDeptId != null and query.businessDeptId != "" and query.businessDeptId!="0"'>
                and b.business_dept_id = #{query.businessDeptId}
            </if>
            <if test="query.billType != null">
                and b.bill_type = #{query.billType}
            </if>
        </where>
    </select>
    <select id="batchBillCount" resultType="java.lang.Integer">
        SELECT