wujianwei
2026-03-20 3ffbb4756bbddcf101d367fdde3dfc7f7ced6bb6
service/src/main/resources/mapper/cwgl/ReceivableBillManagementMapper.xml
@@ -9,6 +9,12 @@
        <result property="systemNo"    column="system_no"    />
        <result property="billName"    column="bill_name"    />
        <result property="customerName"    column="customer_name"    />
        <result property="payee"    column="payee"    />
        <result property="responsiblePerson"    column="responsible_person"    />
        <result property="responsibleLeader"    column="responsible_leader"    />
        <result property="settlementMethod"    column="settlement_method"    />
        <result property="businessType"    column="business_type"    />
        <result property="promotionRequirement"    column="promotion_requirement"    />
        <result property="isInternalSettlement"    column="is_internal_settlement"    />
        <result property="internalSettlementUnit"    column="internal_settlement_unit"    />
        <result property="documentCount"    column="document_count"    />
@@ -36,8 +42,54 @@
        <result property="deleted"    column="deleted"    />
    </resultMap>
    <resultMap type="com.ruoyi.cwgl.domain.vo.ReceivableBillAgingAnalysisVo" id="ReceivableBillAgingAnalysisVoResult">
        <result property="id"    column="id"    />
        <result property="systemNo"    column="system_no"    />
        <result property="billName"    column="bill_name"    />
        <result property="customerName"    column="customer_name"    />
        <result property="payee"    column="payee"    />
        <result property="responsiblePerson"    column="responsible_person"    />
        <result property="responsibleLeader"    column="responsible_leader"    />
        <result property="settlementMethod"    column="settlement_method"    />
        <result property="businessType"    column="business_type"    />
        <result property="promotionRequirement"    column="promotion_requirement"    />
        <result property="isInternalSettlement"    column="is_internal_settlement"    />
        <result property="internalSettlementUnit"    column="internal_settlement_unit"    />
        <result property="documentCount"    column="document_count"    />
        <result property="totalAmount"    column="total_amount"    />
        <result property="currency"    column="currency"    />
        <result property="discountAmount"    column="discount_amount"    />
        <result property="receivedAmount"    column="received_amount"    />
        <result property="pendingAmount"    column="pending_amount"    />
        <result property="exchangeRate"    column="exchange_rate"    />
        <result property="cnyAmount"    column="cny_amount"    />
        <result property="periodType"    column="period_type"    />
        <result property="businessStartDate"    column="business_start_date"    />
        <result property="businessEndDate"    column="business_end_date"    />
        <result property="billingStartDate"    column="billing_start_date"    />
        <result property="billingEndDate"    column="billing_end_date"    />
        <result property="billGenerateDate"    column="bill_generate_date"    />
        <result property="billSendDate"    column="bill_send_date"    />
        <result property="billDueDate"    column="bill_due_date"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="dueIn30Days"    column="due_in_30_days"    />
        <result property="overdueAmount"    column="overdue_amount"    />
        <result property="overdue1To30Days"    column="overdue_1_to_30_days"    />
        <result property="overdue31To60Days"    column="overdue_31_to_60_days"    />
        <result property="overdue61To90Days"    column="overdue_61_to_90_days"    />
        <result property="overdue91To180Days"    column="overdue_91_to_180_days"    />
        <result property="overdue181To365Days"    column="overdue_181_to_365_days"    />
        <result property="overdueOver1Year"    column="overdue_over_1_year"    />
        <result property="overdueDays"    column="overdue_days"    />
    </resultMap>
    <sql id="selectReceivableBillManagementVo">
        select thisTab.id, thisTab.system_no, thisTab.bill_name, thisTab.customer_name, thisTab.is_internal_settlement, thisTab.internal_settlement_unit, thisTab.document_count, thisTab.total_amount, thisTab.currency, thisTab.discount_amount, thisTab.received_amount, thisTab.pending_amount, thisTab.exchange_rate, thisTab.cny_amount, thisTab.period_type, thisTab.business_start_date, thisTab.business_end_date, thisTab.billing_start_date, thisTab.billing_end_date, thisTab.bill_generate_date, thisTab.bill_send_date, thisTab.bill_due_date, thisTab.status, thisTab.remark, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.deleted from receivable_bill_management AS thisTab
        select thisTab.id, thisTab.system_no, thisTab.bill_name, thisTab.customer_name, thisTab.payee, thisTab.responsible_person, thisTab.responsible_leader, thisTab.settlement_method, thisTab.business_type, thisTab.promotion_requirement, thisTab.is_internal_settlement, thisTab.internal_settlement_unit, thisTab.document_count, thisTab.total_amount, thisTab.currency, thisTab.discount_amount, thisTab.received_amount, thisTab.pending_amount, thisTab.exchange_rate, thisTab.cny_amount, thisTab.period_type, thisTab.business_start_date, thisTab.business_end_date, thisTab.billing_start_date, thisTab.billing_end_date, thisTab.bill_generate_date, thisTab.bill_send_date, thisTab.bill_due_date, thisTab.due_in_30_days, thisTab.overdue_amount, thisTab.overdue_1_to_30_days, thisTab.overdue_31_to_60_days, thisTab.overdue_61_to_90_days, thisTab.overdue_91_to_180_days, thisTab.overdue_181_to_365_days, thisTab.overdue_over_1_year, thisTab.overdue_days, thisTab.status, thisTab.remark, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.deleted from receivable_bill_management AS thisTab
    </sql>
    <sql id="selectReceivableBillManagementVoCount">
        select count(0) from receivable_bill_management as thisTab
@@ -47,6 +99,12 @@
        <if test="systemNo != null  and systemNo != ''"> and thisTab.system_no = #{systemNo}</if>
        <if test="billName != null  and billName != ''"> and  thisTab.bill_name like concat('%', #{billName}, '%')</if>
        <if test="customerName != null  and customerName != ''"> and  thisTab.customer_name like concat('%', #{customerName}, '%')</if>
        <if test="payee != null  and payee != ''"> and  thisTab.payee like concat('%', #{payee}, '%')</if>
        <if test="responsiblePerson != null  and responsiblePerson != ''"> and  thisTab.responsible_person like concat('%', #{responsiblePerson}, '%')</if>
        <if test="responsibleLeader != null  and responsibleLeader != ''"> and  thisTab.responsible_leader like concat('%', #{responsibleLeader}, '%')</if>
        <if test="settlementMethod != null  and settlementMethod != ''"> and thisTab.settlement_method = #{settlementMethod}</if>
        <if test="businessType != null  and businessType != ''"> and thisTab.business_type = #{businessType}</if>
        <if test="promotionRequirement != null  and promotionRequirement != ''"> and thisTab.promotion_requirement like concat('%', #{promotionRequirement}, '%')</if>
        <if test="isInternalSettlement != null  and isInternalSettlement != ''"> and thisTab.is_internal_settlement = #{isInternalSettlement}</if>
        <if test="internalSettlementUnit != null  and internalSettlementUnit != ''"> and thisTab.internal_settlement_unit = #{internalSettlementUnit}</if>
        <if test="documentCount != null "> and thisTab.document_count = #{documentCount}</if>
@@ -65,7 +123,16 @@
        <if test="billGenerateDate != null "> and thisTab.bill_generate_date = #{billGenerateDate}</if>
        <if test="billSendDate != null "> and thisTab.bill_send_date = #{billSendDate}</if>
        <if test="billDueDate != null "> and thisTab.bill_due_date = #{billDueDate}</if>
        <if test="status != null  and status != ''"> and thisTab.status = #{status}</if>
        <if test="status != null and status != ''">
            <choose>
                <when test="status == -1">
                    and thisTab.status in (0, 1)
                </when>
                <when test="status > 0">
                    and thisTab.status = #{status}
                </when>
            </choose>
        </if>
        <if test="deleted != null "> and thisTab.deleted = #{deleted}</if>
    </sql>
@@ -90,6 +157,11 @@
        order by thisTab.id desc
    </select>
    <select id="selectReceivableBillManagementBySystemNo" parameterType="String" resultMap="ReceivableBillManagementResult">
        <include refid="selectReceivableBillManagementVo"/>
        where system_no = #{systemNo}
    </select>
    <!-- 新增 -->
    <insert id="insertReceivableBillManagement" parameterType="com.ruoyi.cwgl.domain.ReceivableBillManagement"  useGeneratedKeys="true" keyProperty="id">
        insert into receivable_bill_management
@@ -97,6 +169,12 @@
            <if test="systemNo != null and systemNo != ''">system_no,</if>
            <if test="billName != null and billName != ''">bill_name,</if>
            <if test="customerName != null and customerName != ''">customer_name,</if>
            <if test="payee != null and payee != ''">payee,</if>
            <if test="responsiblePerson != null and responsiblePerson != ''">responsible_person,</if>
            <if test="responsibleLeader != null and responsibleLeader != ''">responsible_leader,</if>
            <if test="settlementMethod != null and settlementMethod != ''">settlement_method,</if>
            <if test="businessType != null and businessType != ''">business_type,</if>
            <if test="promotionRequirement != null and promotionRequirement != ''">promotion_requirement,</if>
            <if test="isInternalSettlement != null and isInternalSettlement != ''">is_internal_settlement,</if>
            <if test="internalSettlementUnit != null">internal_settlement_unit,</if>
            <if test="documentCount != null">document_count,</if>
@@ -127,6 +205,12 @@
            <if test="systemNo != null and systemNo != ''">#{systemNo},</if>
            <if test="billName != null and billName != ''">#{billName},</if>
            <if test="customerName != null and customerName != ''">#{customerName},</if>
            <if test="payee != null and payee != ''">#{payee},</if>
            <if test="responsiblePerson != null and responsiblePerson != ''">#{responsiblePerson},</if>
            <if test="responsibleLeader != null and responsibleLeader != ''">#{responsibleLeader},</if>
            <if test="settlementMethod != null and settlementMethod != ''">#{settlementMethod},</if>
            <if test="businessType != null and businessType != ''">#{businessType},</if>
            <if test="promotionRequirement != null and promotionRequirement != ''">#{promotionRequirement},</if>
            <if test="isInternalSettlement != null and isInternalSettlement != ''">#{isInternalSettlement},</if>
            <if test="internalSettlementUnit != null">#{internalSettlementUnit},</if>
            <if test="documentCount != null">#{documentCount},</if>
@@ -158,11 +242,11 @@
    <insert id="insertReceivableBillManagementBatch" parameterType="java.util.List"  useGeneratedKeys="true" keyProperty="id">
        insert into receivable_bill_management
        <trim prefix="(" suffix=") values" suffixOverrides=",">
            system_no,bill_name,customer_name,is_internal_settlement,internal_settlement_unit,document_count,total_amount,currency,discount_amount,received_amount,pending_amount,exchange_rate,cny_amount,period_type,business_start_date,business_end_date,billing_start_date,billing_end_date,bill_generate_date,bill_send_date,bill_due_date,status,remark,create_by,create_time,update_by,update_time,deleted,
            system_no,bill_name,customer_name,payee,responsible_person,responsible_leader,settlement_method,business_type,promotion_requirement,is_internal_settlement,internal_settlement_unit,document_count,total_amount,currency,discount_amount,received_amount,pending_amount,exchange_rate,cny_amount,period_type,business_start_date,business_end_date,billing_start_date,billing_end_date,bill_generate_date,bill_send_date,bill_due_date,status,remark,create_by,create_time,update_by,update_time,deleted,
        </trim>
        <foreach item="item" index="index" collection="list" separator=",">
            <trim prefix="(" suffix=") " suffixOverrides=",">
                #{item.systemNo},#{item.billName},#{item.customerName},#{item.isInternalSettlement},#{item.internalSettlementUnit},#{item.documentCount},#{item.totalAmount},#{item.currency},#{item.discountAmount},#{item.receivedAmount},#{item.pendingAmount},#{item.exchangeRate},#{item.cnyAmount},#{item.periodType},#{item.businessStartDate},#{item.businessEndDate},#{item.billingStartDate},#{item.billingEndDate},#{item.billGenerateDate},#{item.billSendDate},#{item.billDueDate},#{item.status},#{item.remark},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.deleted},
                #{item.systemNo},#{item.billName},#{item.customerName},#{item.payee},#{item.responsiblePerson},#{item.responsibleLeader},#{item.settlementMethod},#{item.businessType},#{item.promotionRequirement},#{item.isInternalSettlement},#{item.internalSettlementUnit},#{item.documentCount},#{item.totalAmount},#{item.currency},#{item.discountAmount},#{item.receivedAmount},#{item.pendingAmount},#{item.exchangeRate},#{item.cnyAmount},#{item.periodType},#{item.businessStartDate},#{item.businessEndDate},#{item.billingStartDate},#{item.billingEndDate},#{item.billGenerateDate},#{item.billSendDate},#{item.billDueDate},#{item.status},#{item.remark},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime},#{item.deleted},
            </trim>
        </foreach>
    </insert>
@@ -174,6 +258,12 @@
            <if test="systemNo != null and systemNo != ''">system_no = #{systemNo},</if>
            <if test="billName != null and billName != ''">bill_name = #{billName},</if>
            <if test="customerName != null and customerName != ''">customer_name = #{customerName},</if>
            <if test="payee != null and payee != ''">payee = #{payee},</if>
            <if test="responsiblePerson != null and responsiblePerson != ''">responsible_person = #{responsiblePerson},</if>
            <if test="responsibleLeader != null and responsibleLeader != ''">responsible_leader = #{responsibleLeader},</if>
            <if test="settlementMethod != null and settlementMethod != ''">settlement_method = #{settlementMethod},</if>
            <if test="businessType != null and businessType != ''">business_type = #{businessType},</if>
            <if test="promotionRequirement != null and promotionRequirement != ''">promotion_requirement = #{promotionRequirement},</if>
            <if test="isInternalSettlement != null and isInternalSettlement != ''">is_internal_settlement = #{isInternalSettlement},</if>
            <if test="internalSettlementUnit != null">internal_settlement_unit = #{internalSettlementUnit},</if>
            <if test="documentCount != null">document_count = #{documentCount},</if>
@@ -210,6 +300,12 @@
                <if test="item.systemNo != null and item.systemNo != ''">system_no = #{item.systemNo},</if>
                <if test="item.billName != null and item.billName != ''">bill_name = #{item.billName},</if>
                <if test="item.customerName != null and item.customerName != ''">customer_name = #{item.customerName},</if>
                <if test="item.payee != null and item.payee != ''">payee = #{item.payee},</if>
                <if test="item.responsiblePerson != null and item.responsiblePerson != ''">responsible_person = #{item.responsiblePerson},</if>
                <if test="item.responsibleLeader != null and item.responsibleLeader != ''">responsible_leader = #{item.responsibleLeader},</if>
                <if test="item.settlementMethod != null and item.settlementMethod != ''">settlement_method = #{item.settlementMethod},</if>
                <if test="item.businessType != null and item.businessType != ''">business_type = #{item.businessType},</if>
                <if test="item.promotionRequirement != null and item.promotionRequirement != ''">promotion_requirement = #{item.promotionRequirement},</if>
                <if test="item.isInternalSettlement != null and item.isInternalSettlement != ''">is_internal_settlement = #{item.isInternalSettlement},</if>
                <if test="item.internalSettlementUnit != null">internal_settlement_unit = #{item.internalSettlementUnit},</if>
                <if test="item.documentCount != null">document_count = #{item.documentCount},</if>
@@ -251,4 +347,29 @@
        </foreach>
    </delete>
    <!-- 查询应收账单客户汇总列表 -->
    <select id="selectReceivableBillCustomerSummaryList" parameterType="com.ruoyi.cwgl.domain.ReceivableBillManagement" resultType="com.ruoyi.cwgl.domain.ReceivableBillCustomerSummary">
        SELECT
            customer_name as customerName,
            SUM(total_amount) as totalEstimatedAmount,
            SUM(total_amount) as totalConfirmedAmount,
            SUM(pending_amount) as totalPendingAmount
        FROM receivable_bill_management
        <where>
            <if test="customerName != null  and customerName != ''"> and  customer_name like concat('%', #{customerName}, '%')</if>
        </where>
        GROUP BY customer_name
        ORDER BY customer_name
    </select>
    <!-- 查询应收账单账龄分析列表 -->
    <select id="selectReceivableBillAgingAnalysisList" parameterType="com.ruoyi.cwgl.domain.ReceivableBillManagement" resultMap="ReceivableBillAgingAnalysisVoResult">
        <include refid="selectReceivableBillManagementVo"/>
        <where>
            <include refid="whereCondition"/>
        </where>
        ORDER BY customer_name, bill_due_date
    </select>
</mapper>