| | |
| | | * @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)); |
| | | // 获得金额 |
| | |
| | | .inIfPresent(ErpFinancePaymentDO::getStatus, statuses)); |
| | | } |
| | | |
| | | } |
| | | } |