| | |
| | | .in(CrmReceivableDO::getAuditStatus, auditStatuses)); |
| | | } |
| | | |
| | | default List<CrmReceivableDO> selectListByInvoiceIdAndStatus(Long invoiceId, Collection<Integer> auditStatuses) { |
| | | return selectList(new LambdaQueryWrapperX<CrmReceivableDO>() |
| | | .eq(CrmReceivableDO::getInvoiceId, invoiceId) |
| | | .in(CrmReceivableDO::getAuditStatus, auditStatuses)); |
| | | } |
| | | |
| | | default Map<Long, BigDecimal> selectReceivablePriceMapByInvoiceId(Collection<Long> invoiceIds) { |
| | | if (CollUtil.isEmpty(invoiceIds)) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | // SQL sum 查询 |
| | | List<Map<String, Object>> result = selectMaps(new QueryWrapper<CrmReceivableDO>() |
| | | .select("invoice_id, SUM(price) AS total_price") |
| | | .in("audit_status", CrmAuditStatusEnum.DRAFT.getStatus(), // 草稿 + 审批中 + 审批通过 |
| | | CrmAuditStatusEnum.PROCESS.getStatus(), CrmAuditStatusEnum.APPROVE.getStatus()) |
| | | .groupBy("invoice_id") |
| | | .in("invoice_id", invoiceIds)); |
| | | // 获得金额 |
| | | return convertMap(result, obj -> (Long) obj.get("invoice_id"), obj -> (BigDecimal) obj.get("total_price")); |
| | | } |
| | | |
| | | default Map<Long, BigDecimal> selectReceivablePriceMapByContractId(Collection<Long> contractIds) { |
| | | if (CollUtil.isEmpty(contractIds)) { |
| | | return Collections.emptyMap(); |