2 天以前 684e4306a08feeae188070f264148e6765da8dcf
src/main/resources/mapper/sales/SalesLedgerMapper.xml
@@ -13,6 +13,22 @@
    </select>
    <!-- 代储金额:该客户全部「类型=代储」台账合同金额合计。跨客户汇总,加 /*data_scope*/ 跳过数据权限,
         否则非管理员看到的是被 dept_id 过滤过的部分金额,会把「已超信托基金」误判成未超 -->
    <select id="selectDepositAmountByCustomerIds" resultType="com.ruoyi.sales.dto.CustomerDepositAmountDto">
        select /*data_scope*/ customer_id as customerId,
        IFNULL(sum(contract_amount), 0) as depositTotalAmount
        from sales_ledger
        where ledger_type = '代储'
        <if test="customerIds != null and customerIds.size() > 0">
            and customer_id in
            <foreach collection="customerIds" item="cid" open="(" separator="," close=")">
                #{cid}
            </foreach>
        </if>
        group by customer_id
    </select>
    <select id="selectSalesLedgerList" resultType="com.ruoyi.sales.pojo.SalesLedger">
        SELECT
        T1.id,
@@ -23,6 +39,12 @@
        T1.salesman,
        T1.customer_id,
        T1.customer_name,
        T1.ledger_type,
        T1.oil_depot_id,
        T1.oil_depot_name,
        T1.tank_id,
        T1.tank_no,
        T1.approval_status,
        T1.entry_person,
        T1.remarks,
        T1.attachment_materials,
@@ -39,6 +61,12 @@
            <if test="salesLedgerDto.customerName != null and salesLedgerDto.customerName != '' ">
                T1.customer_name LIKE CONCAT('%',#{salesLedgerDto.customerName},'%')
            </if>
            <if test="salesLedgerDto.ledgerType != null and salesLedgerDto.ledgerType != '' ">
                AND T1.ledger_type = #{salesLedgerDto.ledgerType}
            </if>
            <if test="salesLedgerDto.approvalStatus != null and salesLedgerDto.approvalStatus != '' ">
                AND T1.approval_status = #{salesLedgerDto.approvalStatus}
            </if>
        </where>
    </select>
@@ -51,6 +79,12 @@
        T1.salesman,
        T1.customer_id,
        T1.customer_name,
        T1.ledger_type,
        T1.oil_depot_id,
        T1.oil_depot_name,
        T1.tank_id,
        T1.tank_no,
        T1.approval_status,
        T1.entry_person,
        T1.remarks,
        T1.attachment_materials,
@@ -95,6 +129,12 @@
            <if test="salesLedgerDto.entryDateEnd != null and salesLedgerDto.entryDateEnd != '' ">
                AND T1.entry_date &lt;= DATE_FORMAT(#{salesLedgerDto.entryDateEnd},'%Y-%m-%d')
            </if>
            <if test="salesLedgerDto.ledgerType != null and salesLedgerDto.ledgerType != '' ">
                AND T1.ledger_type = #{salesLedgerDto.ledgerType}
            </if>
            <if test="salesLedgerDto.approvalStatus != null and salesLedgerDto.approvalStatus != '' ">
                AND T1.approval_status = #{salesLedgerDto.approvalStatus}
            </if>
        </where>
        order by T1.entry_date desc
    </select>