gaoluyang
昨天 8c65f898ed6e5b0c7a94c792c4562f6ec831dccd
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/finance/ErpFinancePaymentMapper.java
@@ -73,14 +73,20 @@
     * @return key 为来票编号,value 为已付款金额
     */
    default Map<Long, BigDecimal> selectPaymentPriceMapByInvoiceId(Collection<Long> invoiceIds) {
        return selectPaymentPriceMapByInvoiceIdAndStatus(invoiceIds, List.of(
                ErpAuditStatus.PROCESS.getStatus(), ErpAuditStatus.APPROVING.getStatus(),
                ErpAuditStatus.APPROVE.getStatus()));
    }
    default Map<Long, BigDecimal> selectPaymentPriceMapByInvoiceIdAndStatus(
            Collection<Long> invoiceIds, Collection<Integer> statuses) {
        if (CollUtil.isEmpty(invoiceIds)) {
            return Collections.emptyMap();
        }
        // SQL sum 查询
        List<Map<String, Object>> result = selectMaps(new QueryWrapper<ErpFinancePaymentDO>()
                .select("invoice_id, SUM(payment_price) AS total_payment_price")
                .in("status", ErpAuditStatus.PROCESS.getStatus(), // 未审核 + 审批中 + 已审核
                        ErpAuditStatus.APPROVING.getStatus(), ErpAuditStatus.APPROVE.getStatus())
                .in("status", statuses)
                .groupBy("invoice_id")
                .in("invoice_id", invoiceIds));
        // 获得金额
@@ -115,4 +121,4 @@
                .inIfPresent(ErpFinancePaymentDO::getStatus, statuses));
    }
}
}