3 小时以前 55d694aaae4e421b5e55cd941500e08f85cb5d4d
src/main/resources/mapper/sales/SalesLedgerMapper.xml
@@ -56,6 +56,7 @@
        T1.attachment_materials,
        T1.tenant_id,
        T1.contract_amount,
        T1.net_contract_amount,
        T1.contract_amount AS noInvoiceAmountTotal,
        T1.execution_date,
        T2.nick_name AS entry_person_name,
@@ -137,7 +138,31 @@
                and c.customer_name like concat('%',#{customerName},'%')
            </if>
        </where>
        order by sl.create_time desc
        order by sl.entry_date desc
    </select>
    <select id="listFrameworkOrders" resultType="com.ruoyi.sales.vo.FrameworkOrderVo">
        select sl.*, IFNULL(shipped.shipped_quantity, 0) AS shippedQuantity
        from sales_ledger sl
        left join (
            select slp.sales_ledger_id, SUM(spd.quantity) AS shipped_quantity
            from sales_ledger_product slp
            inner join shipping_info si on slp.id = si.sales_ledger_product_id and si.status = '已发货'
            inner join shipping_product_detail spd on si.id = spd.shipping_info_id
            group by slp.sales_ledger_id
        ) shipped on sl.id = shipped.sales_ledger_id
        where sl.parent_contract_id = #{parentContractId}
          and sl.contract_type = 3
        order by sl.execution_date desc
    </select>
    <select id="sumShippedByParentContract" resultType="java.math.BigDecimal">
        select IFNULL(SUM(spd.quantity), 0)
        from sales_ledger slo
        inner join sales_ledger_product slp on slo.id = slp.sales_ledger_id
        inner join shipping_info si on slp.id = si.sales_ledger_product_id and si.status = '已发货'
        inner join shipping_product_detail spd on si.id = spd.shipping_info_id
        where slo.parent_contract_id = #{parentContractId}
    </select>
</mapper>