diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/TransportBusiConstant.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/TransportBusiConstant.java index bbe3679c..cf5e82b3 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/TransportBusiConstant.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/constant/TransportBusiConstant.java @@ -34,6 +34,21 @@ public final class TransportBusiConstant { /** 付款类型:结算付款(关联正式结算单的正式付款)。 */ public static final String PAYMENT_TYPE_SETTLEMENT = "settlement_payment"; + /** 审批状态:草稿(允许编辑、删除)。 */ + public static final String DRAFT = "draft"; + + /** 审批状态:审批中(审核节点,允许通过/驳回)。 */ + public static final String REVIEWING = "reviewing"; + + /** 审批状态:审批通过。 */ + public static final String APPROVED = "approved"; + + /** 审批状态:已驳回(允许再编辑后重新提交)。 */ + public static final String RETURNED = "returned"; + + /** 审批状态:已作废(终态)。 */ + public static final String VOIDED = "voided"; + private TransportBusiConstant() { } } diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/BillPaymentServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/BillPaymentServiceImpl.java index 180cb494..f0bd1f55 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/BillPaymentServiceImpl.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/BillPaymentServiceImpl.java @@ -35,6 +35,7 @@ import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.jackson.JsonUtil; import org.springblade.core.tool.utils.Func; import org.springblade.system.cache.SysCache; +import org.springblade.transport.constant.TransportBusiConstant; import org.springblade.transport.mapper.BillLedgerMapper; import org.springblade.transport.mapper.BillLedgerUsageMapper; import org.springblade.transport.mapper.BillPaymentMapper; @@ -61,11 +62,6 @@ import java.util.Objects; @RequiredArgsConstructor public class BillPaymentServiceImpl extends BaseServiceImpl implements IBillPaymentService { - private static final String DRAFT = "draft"; - private static final String REVIEWING = "reviewing"; - private static final String APPROVED = "approved"; - private static final String RETURNED = "returned"; - private static final String VOIDED = "voided"; private static final String RELEASED = "released"; private final BillLedgerMapper billLedgerMapper; @@ -103,7 +99,7 @@ public class BillPaymentServiceImpl extends BaseServiceImpllambdaQuery() .eq(BillLedgerUsage::getBillPaymentId, entity.getId()) - .eq(BillLedgerUsage::getUsageStatus, APPROVED) + .eq(BillLedgerUsage::getUsageStatus, TransportBusiConstant.APPROVED) .last("FOR UPDATE")); if (exists != null) { throw new ServiceException("该汇票付款已生成使用记录"); @@ -188,11 +184,11 @@ public class BillPaymentServiceImpl extends BaseServiceImpllambdaQuery() .eq(BillLedgerUsage::getBillPaymentId, entity.getId()) - .eq(BillLedgerUsage::getUsageStatus, APPROVED) + .eq(BillLedgerUsage::getUsageStatus, TransportBusiConstant.APPROVED) .last("FOR UPDATE")); if (usage == null) { throw new ServiceException("未找到汇票使用记录,无法作废"); @@ -233,7 +229,7 @@ public class BillPaymentServiceImpl extends BaseServiceImpl implements IFormalSettlementService { - private static final String DRAFT = "draft"; - private static final String REVIEWING = "reviewing"; - private static final String APPROVED = "approved"; - private static final String RETURNED = "returned"; - private static final String VOIDED = "voided"; private final FormalSettlementSourceMapper sourceMapper; private final FormalSettlementSummaryFeeMapper summaryFeeMapper; private final FormalSettlementPaymentMapper paymentMapper; @@ -156,7 +143,6 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl selectPage(IPage page, FormalSettlementVO query) { @@ -191,7 +177,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl candidatePreSettlements(IPage page, PreSettlementVO query) { IPage result = preSettlementMapper.selectPage(page, Wrappers.lambdaQuery() - .eq(PreSettlement::getApprovalStatus, APPROVED) + .eq(PreSettlement::getApprovalStatus, TransportBusiConstant.APPROVED) .and(w -> w.isNull(PreSettlement::getFormalSettlementNo).or().eq(PreSettlement::getFormalSettlementNo, "")) .eq(query.getContractId() != null, PreSettlement::getContractId, query.getContractId()) .like(Func.isNotEmpty(query.getPreSettlementNo()), PreSettlement::getPreSettlementNo, query.getPreSettlementNo()) @@ -326,7 +312,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl receiptMap = receiptIds.isEmpty() ? Map.of() : invoiceReceiptMapper.selectByIds(receiptIds).stream() - .filter(receipt -> !VOIDED.equals(receipt.getApprovalStatus()) + .filter(receipt -> !TransportBusiConstant.VOIDED.equals(receipt.getApprovalStatus()) && !Objects.equals(receipt.getIsDeleted(), 1)) .collect(Collectors.toMap(InvoiceReceipt::getId, Function.identity())); for (InvoiceReceiptSettlement relation : receiptRelations) { @@ -409,7 +395,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl settlements = list(Wrappers.lambdaQuery() - .eq(FormalSettlement::getApprovalStatus, APPROVED) + .eq(FormalSettlement::getApprovalStatus, TransportBusiConstant.APPROVED) .eq(FormalSettlement::getSettlementType, "receivable") .in(FormalSettlement::getKingdeeSyncStatus, KingdeeBfiConstant.KINGDEE_STATUS_SYNCED, KingdeeBfiConstant.KINGDEE_STATUS_FAILED) @@ -704,12 +690,12 @@ public class FormalSettlementServiceImpl extends BaseServiceImpllambdaQuery() .eq(FormalSettlementPayment::getFormalSettlementId, settlement.getId()) .eq(FormalSettlementPayment::getIsDeleted, 0) - .notIn(FormalSettlementPayment::getBillStatus, RETURNED, VOIDED)); + .notIn(FormalSettlementPayment::getBillStatus, TransportBusiConstant.RETURNED, TransportBusiConstant.VOIDED)); if (activePaymentCount > 0) throw new ServiceException("该结算单正在申请结算尾款,不允许再次提交申请付款"); BigDecimal amount = positive(appliedAmount, "申请付款金额"); BigDecimal available = money(settlement.getSettlementAmount()).subtract(money(settlement.getAppliedPaymentAmount())); @@ -720,7 +706,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpllambdaUpdate() .eq(PreSettlement::getId, source.getId()) - .eq(PreSettlement::getApprovalStatus, APPROVED) + .eq(PreSettlement::getApprovalStatus, TransportBusiConstant.APPROVED) .and(w -> w.isNull(PreSettlement::getFormalSettlementNo).or().eq(PreSettlement::getFormalSettlementNo, "")) .set(PreSettlement::getFormalSettlementNo, settlement.getFormalSettlementNo()) .set(PreSettlement::getFormalSettledTime, LocalDateTime.now()) @@ -1296,11 +1282,11 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl applications = paymentApplicationMapper.selectList(query); BigDecimal appliedAmount = applications.stream() - .filter(item -> REVIEWING.equals(item.getApprovalStatus())) + .filter(item -> TransportBusiConstant.REVIEWING.equals(item.getApprovalStatus())) .map(PaymentApplication::getAppliedAmount).map(this::money) .reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal paidAmount = applications.stream() - .filter(item -> APPROVED.equals(item.getApprovalStatus())) + .filter(item -> TransportBusiConstant.APPROVED.equals(item.getApprovalStatus())) .map(PaymentApplication::getPaidAmount).map(this::money) .reduce(BigDecimal.ZERO, BigDecimal::add); Map relationStatuses = relationApplicationIds.isEmpty() ? Map.of() : paymentApplicationMapper.selectList( @@ -1308,11 +1294,11 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl REVIEWING.equals(relationStatuses.get(item.getPaymentApplicationId()))) + .filter(item -> TransportBusiConstant.REVIEWING.equals(relationStatuses.get(item.getPaymentApplicationId()))) .map(PaymentApplicationSettlement::getAppliedAmount).map(this::money) .reduce(BigDecimal.ZERO, BigDecimal::add)); paidAmount = paidAmount.add(relations.stream() - .filter(item -> APPROVED.equals(relationStatuses.get(item.getPaymentApplicationId()))) + .filter(item -> TransportBusiConstant.APPROVED.equals(relationStatuses.get(item.getPaymentApplicationId()))) .map(PaymentApplicationSettlement::getPaidAmount).map(this::money) .reduce(BigDecimal.ZERO, BigDecimal::add)); if ("payable".equals(settlement.getSettlementType())) { @@ -1361,11 +1347,11 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl "草稿"; - case REVIEWING -> "审批中"; - case APPROVED -> "审批通过"; - case RETURNED -> "已驳回"; - case VOIDED -> "已作废"; + case TransportBusiConstant.DRAFT -> "草稿"; + case TransportBusiConstant.REVIEWING -> "审批中"; + case TransportBusiConstant.APPROVED -> "审批通过"; + case TransportBusiConstant.RETURNED -> "已驳回"; + case TransportBusiConstant.VOIDED -> "已作废"; default -> value; }; } @@ -1373,7 +1359,7 @@ public class FormalSettlementServiceImpl extends BaseServiceImpl invoicePoolQuery(FormalSettlementInvoicePoolQueryDTO query) { + // 认领查询改为查本地收票管理已登记的发票,仅审批通过的收票可认领,不再远程调用金蝶全票池 long pageNo = Math.max(query.getCurrent() == null ? 1 : query.getCurrent(), 1); - // 上限 499:预留 1 条给 hasMore 探测,单次远程请求不超过 rim 契约 pageSize 上限 500 - long pageSize = Math.min(Math.max(query.getSize() == null ? 10 : query.getSize(), 1), 499); - String invoiceNo = query.getInvoiceNo(); - String invoiceDateStart = query.getInvoiceDateStart(); - String invoiceDateEnd = query.getInvoiceDateEnd(); - String salerTaxNo = query.getSalerTaxNo(); - String buyerTaxNo = query.getBuyerTaxNo(); - String expenseStatus = query.getExpenseStatus(); - // A801-1 rim 契约不支持全量且不返回总数:透传 pageNo/pageSize 单页查询, - // 多取 1 条探测是否还有下一页,total 合成为当前已知的最小精确值供前端分页器翻页 - BfiInvoicePoolQueryDataDTO data = new BfiInvoicePoolQueryDataDTO(); - data.setPageNo((int) pageNo); - data.setPageSize((int) pageSize + 1); - if (StringUtil.isNotBlank(invoiceNo)) { - data.setInvoiceNo(invoiceNo.trim()); - } - if (StringUtil.isNotBlank(invoiceDateStart)) { - data.setInvoiceDateStart(invoiceDateStart.trim()); - } - if (StringUtil.isNotBlank(invoiceDateEnd)) { - data.setInvoiceDateEnd(invoiceDateEnd.trim()); - } - if (StringUtil.isNotBlank(salerTaxNo)) { - data.setSalerTaxNo(salerTaxNo.trim()); - } - if (StringUtil.isNotBlank(buyerTaxNo)) { - data.setBuyerTaxNo(buyerTaxNo.trim()); - } - if (StringUtil.isNotBlank(expenseStatus)) { - data.setExpenseStatus(expenseStatus.trim()); - } - BfiInvoicePoolQueryDTO param = new BfiInvoicePoolQueryDTO(); - param.setQueryParam(data); - BfiPageVO poolPage = bfiService.queryInvoicePool(param); - List invoices = poolPage.getRows() == null ? List.of() - : poolPage.getRows().stream() - .map(this::toInvoicePoolVO) - .toList(); - // 多取的 1 条仅用于 hasMore 判断,不返回给前端 - boolean hasMore = invoices.size() > pageSize; - List records = hasMore ? invoices.subList(0, (int) pageSize) : invoices; - long total = hasMore ? pageNo * pageSize + 1 : (pageNo - 1) * pageSize + records.size(); - log.info("正式结算单认领查询 全票池第 {} 页 {} 条/页,返回 {} 条,hasMore:{}", pageNo, pageSize, records.size(), hasMore); - Page page = new Page<>(pageNo, pageSize); - page.setRecords(records); - page.setTotal(total); - return page; + long pageSize = Math.min(Math.max(query.getSize() == null ? 10 : query.getSize(), 1), 500); + IPage receipts = invoiceReceiptMapper.selectPage(new Page<>(pageNo, pageSize), + Wrappers.lambdaQuery() + .eq(InvoiceReceipt::getApprovalStatus, TransportBusiConstant.APPROVED) + .like(StringUtil.isNotBlank(query.getInvoiceNo()), InvoiceReceipt::getInvoiceNo, + query.getInvoiceNo() == null ? null : query.getInvoiceNo().trim()) + .ge(StringUtil.isNotBlank(query.getInvoiceDateStart()), InvoiceReceipt::getInvoiceDate, + parseInvoiceDate(query.getInvoiceDateStart())) + .le(StringUtil.isNotBlank(query.getInvoiceDateEnd()), InvoiceReceipt::getInvoiceDate, + parseInvoiceDate(query.getInvoiceDateEnd())) + .orderByDesc(InvoiceReceipt::getCreateTime)); + return receipts.convert(this::toInvoicePoolVO); + } + + private LocalDate parseInvoiceDate(String value) { + return StringUtil.isBlank(value) ? null : LocalDate.parse(value.trim()); } /** - * A801-1 全票池发票 -> 正式结算单认领VO 字段映射 + * 收票登记发票 -> 正式结算单认领VO 字段映射 */ - private FormalSettlementInvoicePoolVO toInvoicePoolVO(BfiInvoicePoolVO poolInvoice) { + private FormalSettlementInvoicePoolVO toInvoicePoolVO(InvoiceReceipt receipt) { FormalSettlementInvoicePoolVO vo = new FormalSettlementInvoicePoolVO(); - // 发票号码 - vo.setInvoiceNo(poolInvoice.getInvoiceNo()); - // 发票流水号,票池发票唯一标识 - vo.setSerialNo(poolInvoice.getSerialNo()); - // 开票日期 yyyy-MM-dd - vo.setInvoiceDate(poolInvoice.getInvoiceDate()); - // 发票类型编码转名称,未知编码原样返回 - vo.setInvoiceTypeName(BfiConstant.INVOICE_TYPE_NAMES.getOrDefault(poolInvoice.getInvoiceType(), - poolInvoice.getInvoiceType())); - // 税率:顶层优先、回退首条明细,小数转百分数(0.13 -> 13) - vo.setTaxRate(resolveTaxRate(poolInvoice)); - // 价税合计作为发票金额,可匹配金额、默认认领金额与发票金额同源 - BigDecimal totalAmount = parseAmount(poolInvoice.getTotalAmount()); - vo.setInvoiceAmount(totalAmount); - vo.setAvailableInvoiceAmount(totalAmount); - vo.setMatchedAmount(totalAmount); - // 开票单位(销方名称) - vo.setSalerName(poolInvoice.getSalerName()); - // 受票单位(购方名称) - vo.setBuyerName(poolInvoice.getBuyerName()); - // 附件信息JSON:path 供 A801-2 进项发票下载,文件名以发票号码命名 - Map attachment = new LinkedHashMap<>(); - attachment.put("source", "piaozone"); - attachment.put("path", poolInvoice.getDownloadUrl()); - attachment.put("name", poolInvoice.getInvoiceNo() + ".pdf"); - vo.setAttachmentJson(JsonUtil.toJson(attachment)); + vo.setInvoiceNo(receipt.getInvoiceNo()); + // 收票登记无票池流水号,用登记主键作为前端行唯一标识 + vo.setSerialNo(String.valueOf(receipt.getId())); + vo.setInvoiceDate(receipt.getInvoiceDate() == null ? null : receipt.getInvoiceDate().toString()); + vo.setInvoiceTypeName(receipt.getInvoiceType()); + vo.setTaxRate(receipt.getTaxRate()); + // 开票金额为价税合计数,可匹配金额、默认认领金额与发票金额同源 + vo.setInvoiceAmount(money(receipt.getInvoiceAmount())); + vo.setAvailableInvoiceAmount(money(receipt.getInvoiceAmount())); + vo.setMatchedAmount(money(receipt.getInvoiceAmount())); + vo.setSalerName(receipt.getIssuerName()); + vo.setBuyerName(receipt.getReceiverName()); + vo.setAttachmentJson(receipt.getAttachmentsJson()); return vo; } - - /** - * 税率优先取顶层税率的小数值换算为百分数,如 0.13 -> 13;顶层为空时回退取首条明细税率,均无时返回 null - */ - private BigDecimal resolveTaxRate(BfiInvoicePoolVO poolInvoice) { - if (StringUtil.isNotBlank(poolInvoice.getTaxRate())) { - return new BigDecimal(poolInvoice.getTaxRate()).multiply(BigDecimal.valueOf(100)); - } - return Optional.ofNullable(poolInvoice.getItems()).orElse(List.of()).stream() - .map(BfiInvoicePoolItemVO::getTaxRate) - .filter(StringUtil::isNotBlank) - .findFirst() - .map(taxRate -> new BigDecimal(taxRate).multiply(BigDecimal.valueOf(100))) - .orElse(null); - } - - private BigDecimal parseAmount(String value) { - return StringUtil.isBlank(value) ? BigDecimal.ZERO : new BigDecimal(value); - } } diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/InvoiceApplicationServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/InvoiceApplicationServiceImpl.java index 14d959b1..19e6fc8d 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/InvoiceApplicationServiceImpl.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/InvoiceApplicationServiceImpl.java @@ -50,6 +50,7 @@ import org.springblade.thirdparty.bfi.pojo.vo.BfiPageVO; import org.springblade.thirdparty.bfi.service.IBfiService; import org.springblade.transport.config.BfiProperties; import org.springblade.transport.constant.KingdeeBfiConstant; +import org.springblade.transport.constant.TransportBusiConstant; import org.springblade.transport.mapper.ContractManageMapper; import org.springblade.transport.mapper.CustomerArchiveMapper; import org.springblade.transport.mapper.CustomerContactMapper; @@ -121,11 +122,6 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class InvoiceApplicationServiceImpl extends BaseServiceImpl implements IInvoiceApplicationService { - private static final String DRAFT = "draft"; - private static final String REVIEWING = "reviewing"; - private static final String APPROVED = "approved"; - private static final String RETURNED = "returned"; - private static final String VOIDED = "voided"; /** A303-5 开票结果批量查询单批单据编号上限(接口限制 50) */ private static final int INVOICE_RESULT_QUERY_BATCH = 50; private final InvoiceApplicationSettlementMapper settlementRelationMapper; @@ -202,7 +198,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl settlements = formalSettlementMapper.selectList(Wrappers.lambdaQuery() .eq(FormalSettlement::getSettlementType, candidateSettlementType) .eq(FormalSettlement::getInvoiceStatus, candidateInvoiceStatus) - .eq(FormalSettlement::getApprovalStatus, APPROVED) + .eq(FormalSettlement::getApprovalStatus, TransportBusiConstant.APPROVED) .eq(FormalSettlement::getStatus, 1) .in(Func.isNotEmpty(contractCategory), FormalSettlement::getContractId, contractIds) .and(Func.isNotEmpty(keyword), wrapper -> wrapper.like(FormalSettlement::getFormalSettlementNo, keyword) @@ -241,7 +237,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl allocatedAmounts = relations.stream() .filter(relation -> { InvoiceApplication application = applications.get(relation.getInvoiceApplicationId()); - return application != null && !VOIDED.equals(application.getApprovalStatus()) + return application != null && !TransportBusiConstant.VOIDED.equals(application.getApprovalStatus()) && !Objects.equals(application.getIsDeleted(), 1); }) .collect(Collectors.groupingBy(InvoiceApplicationSettlement::getFormalSettlementId, @@ -376,7 +372,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl applications = list(Wrappers.lambdaQuery() - .eq(InvoiceApplication::getApprovalStatus, APPROVED) + .eq(InvoiceApplication::getApprovalStatus, TransportBusiConstant.APPROVED) .eq(InvoiceApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_SYNCED) .isNotNull(InvoiceApplication::getKingdeeBillNo) .ne(InvoiceApplication::getKingdeeBillNo, "") @@ -956,7 +952,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl { InvoiceApplication application = applications.get(relation.getInvoiceApplicationId()); - return application != null && !VOIDED.equals(application.getApprovalStatus()) + return application != null && !TransportBusiConstant.VOIDED.equals(application.getApprovalStatus()) && !Objects.equals(application.getIsDeleted(), 1); }).toList(); } @@ -1165,7 +1161,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl implements IInvoiceReceiptService { - /** 审批状态:草稿(允许编辑、删除) */ - private static final String DRAFT = "draft"; - - /** 审批状态:审批中(收票审核节点,允许通过/驳回) */ - private static final String REVIEWING = "reviewing"; - - /** 审批状态:审批通过(允许同步金蝶、作废) */ - private static final String APPROVED = "approved"; - - /** 审批状态:已驳回(允许再编辑后重新提交) */ - private static final String RETURNED = "returned"; - - /** 审批状态:已作废(终态,不参与绑定与收票统计) */ - private static final String VOIDED = "voided"; - /** A801-1 rim 契约单页最大条数 */ private static final int POOL_PAGE_SIZE = 500; @@ -232,7 +218,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl settlements = formalSettlementMapper.selectList( Wrappers.lambdaQuery() .eq(FormalSettlement::getSettlementType, "payable") - .eq(FormalSettlement::getApprovalStatus, APPROVED) + .eq(FormalSettlement::getApprovalStatus, TransportBusiConstant.APPROVED) .eq(FormalSettlement::getStatus, 1) .and(Func.isNotEmpty(keyword), wrapper -> wrapper .like(FormalSettlement::getFormalSettlementNo, keyword) @@ -322,7 +308,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl settlementIds = relationSettlementIds(id); @@ -377,32 +363,32 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl> receiptMap = list(Wrappers.lambdaQuery() .in(InvoiceReceipt::getInvoiceNo, mirrorMap.keySet()) - .ne(InvoiceReceipt::getApprovalStatus, VOIDED)).stream() + .ne(InvoiceReceipt::getApprovalStatus, TransportBusiConstant.VOIDED)).stream() .filter(receipt -> !Objects.equals(receipt.getIsDeleted(), 1)) .collect(Collectors.groupingBy(InvoiceReceipt::getInvoiceNo)); // 镜像有了却没人登记:本页不产生任何绑定,属正常(票池范围大于我方登记范围) @@ -645,7 +631,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl unboundReceipts = list(Wrappers.lambdaQuery() .isNull(InvoiceReceipt::getKingdeeInvoicePoolId) - .ne(InvoiceReceipt::getApprovalStatus, VOIDED) + .ne(InvoiceReceipt::getApprovalStatus, TransportBusiConstant.VOIDED) .orderByAsc(InvoiceReceipt::getCreateTime) .last("limit " + compensateLimit)); if (unboundReceipts.isEmpty()) { @@ -1205,7 +1191,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl { InvoiceReceipt receipt = receipts.get(relation.getInvoiceReceiptId()); - return receipt != null && !VOIDED.equals(receipt.getApprovalStatus()) + return receipt != null && !TransportBusiConstant.VOIDED.equals(receipt.getApprovalStatus()) && !Objects.equals(receipt.getIsDeleted(), 1); }).toList(); } @@ -1436,7 +1422,7 @@ public class InvoiceReceiptServiceImpl extends BaseServiceImpl implements IPaymentApplicationService { - private static final String DRAFT = "draft"; - private static final String REVIEWING = "reviewing"; - private static final String APPROVED = "approved"; - private static final String RETURNED = "returned"; - private static final String VOIDED = "voided"; /** A103-2 按 awrp_src_code 批量查询单次条数上限 */ private static final int PAY_RESULT_QUERY_BATCH = 50; /** A103-2 / A103-4 分页查询页大小 */ @@ -162,7 +157,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl { PaymentApplicationVO vo = PaymentApplicationWrapper.build().entityVO(item); - if (!APPROVED.equals(item.getApprovalStatus())) vo.setPaidAmount(BigDecimal.ZERO); + if (!TransportBusiConstant.APPROVED.equals(item.getApprovalStatus())) vo.setPaidAmount(BigDecimal.ZERO); return vo; }); } @@ -192,7 +187,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpllambdaUpdate() .eq(PaymentApplication::getId, id) - .eq(PaymentApplication::getApprovalStatus, APPROVED) + .eq(PaymentApplication::getApprovalStatus, TransportBusiConstant.APPROVED) .set(PaymentApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_FAILED)); } @@ -483,7 +478,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl applications = list(Wrappers.lambdaQuery() - .eq(PaymentApplication::getApprovalStatus, APPROVED) + .eq(PaymentApplication::getApprovalStatus, TransportBusiConstant.APPROVED) .in(PaymentApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_SYNCED, KingdeeBfiConstant.KINGDEE_STATUS_PAYING, KingdeeBfiConstant.KINGDEE_STATUS_FAILED) .orderByAsc(PaymentApplication::getId)); @@ -521,7 +516,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpllambdaQuery() - .eq(PaymentApplication::getApprovalStatus, APPROVED) + .eq(PaymentApplication::getApprovalStatus, TransportBusiConstant.APPROVED) .eq(PaymentApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_PAID)) .stream().filter(application -> realRecordCount(application.getId()) == 0) .forEach(application -> recordCandidates.putIfAbsent(application.getId(), application)); @@ -1066,7 +1061,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl ids, KingdeeSyncContext context) { List applications = list(Wrappers.lambdaQuery() .in(PaymentApplication::getId, ids) - .eq(PaymentApplication::getApprovalStatus, APPROVED) + .eq(PaymentApplication::getApprovalStatus, TransportBusiConstant.APPROVED) .notIn(PaymentApplication::getKingdeeStatus, KingdeeBfiConstant.KINGDEE_STATUS_SYNCED, KingdeeBfiConstant.KINGDEE_STATUS_PAYING, KingdeeBfiConstant.KINGDEE_STATUS_PAID, KingdeeBfiConstant.KINGDEE_STATUS_CLOSED)); List srcCodes = new ArrayList<>(); @@ -1165,14 +1160,14 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpllambdaQuery() .eq(PreSettlementAdvance::getPreSettlementId, entity.getPreSettlementId()) .eq(PreSettlementAdvance::getIsDeleted, 0) - .ne(PreSettlementAdvance::getBillStatus, VOIDED) + .ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED) .eq(PreSettlementAdvance::getAdvanceNo, entity.getPaymentNo()) .last("limit 1")).stream().findFirst().orElse(null); if (advance == null) { advance = preSettlementAdvanceMapper.selectList(Wrappers.lambdaQuery() .eq(PreSettlementAdvance::getPreSettlementId, entity.getPreSettlementId()) .eq(PreSettlementAdvance::getIsDeleted, 0) - .ne(PreSettlementAdvance::getBillStatus, VOIDED) + .ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED) .eq(PreSettlementAdvance::getPaidAmount, BigDecimal.ZERO) .eq(PreSettlementAdvance::getAppliedAmount, money(entity.getAppliedAmount())) .orderByDesc(PreSettlementAdvance::getCreateTime).last("limit 1")).stream().findFirst().orElse(null); @@ -1203,7 +1198,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpllambdaQuery() .eq(PreSettlementAdvance::getPreSettlementId, preSettlementId) .eq(PreSettlementAdvance::getIsDeleted, 0) - .ne(PreSettlementAdvance::getBillStatus, VOIDED)).stream() + .ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED)).stream() .map(PreSettlementAdvance::getPaidAmount).map(this::money).reduce(BigDecimal.ZERO, BigDecimal::add); } @@ -1211,7 +1206,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpllambdaQuery() .eq(PreSettlementAdvance::getPreSettlementId, preSettlementId) .eq(PreSettlementAdvance::getIsDeleted, 0) - .ne(PreSettlementAdvance::getBillStatus, VOIDED)).stream() + .ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED)).stream() .map(PreSettlementAdvance::getAppliedAmount).map(this::money).reduce(BigDecimal.ZERO, BigDecimal::add); } @@ -1219,7 +1214,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl advances = preSettlementAdvanceMapper.selectList(Wrappers.lambdaQuery() .eq(PreSettlementAdvance::getPreSettlementId, preSettlementId) .eq(PreSettlementAdvance::getIsDeleted, 0) - .ne(PreSettlementAdvance::getBillStatus, VOIDED)); + .ne(PreSettlementAdvance::getBillStatus, TransportBusiConstant.VOIDED)); PreSettlement settlement = preSettlementMapper.selectById(preSettlementId); if (settlement == null) throw new ServiceException("预结算单不存在"); settlement.setAdvanceNo(advances.stream().map(PreSettlementAdvance::getAdvanceNo) @@ -1354,13 +1349,13 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl settlements = ids.stream().map(id -> formalSettlementMapper.selectById(id)).toList(); if (settlements.stream().anyMatch(item -> item == null || Objects.equals(item.getIsDeleted(), 1) - || !APPROVED.equals(item.getApprovalStatus()) || !"payable".equals(item.getSettlementType()))) { + || !TransportBusiConstant.APPROVED.equals(item.getApprovalStatus()) || !"payable".equals(item.getSettlementType()))) { throw new ServiceException("只能选择审批通过的应付正式结算单"); } Long contractId = settlements.get(0).getContractId(); @@ -1458,7 +1453,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpllambdaQuery() .eq(TemporaryCreditLimit::getProjectId, project.getId()) - .eq(TemporaryCreditLimit::getApprovalStatus, APPROVED) + .eq(TemporaryCreditLimit::getApprovalStatus, TransportBusiConstant.APPROVED) .ge(TemporaryCreditLimit::getValidUntil, LocalDate.now()) .eq(TemporaryCreditLimit::getStatus, 1) .eq(TemporaryCreditLimit::getIsDeleted, 0)).stream() @@ -1468,7 +1463,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl wrapper) { - return list(wrapper.ne(PaymentApplication::getApprovalStatus, VOIDED)).stream() + return list(wrapper.ne(PaymentApplication::getApprovalStatus, TransportBusiConstant.VOIDED)).stream() .map(PaymentApplication::getAppliedAmount).map(this::money).reduce(BigDecimal.ZERO, BigDecimal::add); } @@ -1523,7 +1518,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpllambdaQuery() .eq(BillLedgerUsage::getPaymentApplicationId, entity.getId()) - .eq(BillLedgerUsage::getUsageStatus, APPROVED).last("FOR UPDATE")); + .eq(BillLedgerUsage::getUsageStatus, TransportBusiConstant.APPROVED).last("FOR UPDATE")); if (usage == null) throw new ServiceException("未找到对应的汇票使用记录,无法作废"); BillLedger ledger = lockedBill(usage.getBillLedgerId()); ledger.setAvailableBalance(money(ledger.getAvailableBalance()).add(money(usage.getUsedAmount())) @@ -1602,13 +1597,13 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpllambdaQuery() .eq(FormalSettlementPayment::getIsDeleted, 0) .in(FormalSettlementPayment::getFormalSettlementId, formalSettlementIds) - .notIn(FormalSettlementPayment::getBillStatus, RETURNED, VOIDED)); + .notIn(FormalSettlementPayment::getBillStatus, TransportBusiConstant.RETURNED, TransportBusiConstant.VOIDED)); if (activeTailPaymentCount > 0) { throw new ServiceException("该结算单正在申请结算尾款,不允许再次提交申请付款"); } } private PaymentApplication existing(Long id) { PaymentApplication entity = getById(id); if (entity == null || Objects.equals(entity.getIsDeleted(), 1)) throw new ServiceException("付款申请不存在"); return entity; } - private PaymentApplication editable(Long id) { PaymentApplication entity = existing(id); if (!List.of(DRAFT, RETURNED).contains(entity.getApprovalStatus())) throw new ServiceException("当前状态不可编辑"); return entity; } + private PaymentApplication editable(Long id) { PaymentApplication entity = existing(id); if (!List.of(TransportBusiConstant.DRAFT, TransportBusiConstant.RETURNED).contains(entity.getApprovalStatus())) throw new ServiceException("当前状态不可编辑"); return entity; } private String nextNo() { String prefix = "FKD" + LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE); return prefix + String.format("%05d", count(Wrappers.lambdaQuery().likeRight(PaymentApplication::getPaymentNo, prefix)) + 1); } private BigDecimal nonNegative(BigDecimal value, String name) { if (value == null || value.compareTo(BigDecimal.ZERO) < 0) throw new ServiceException(name + "不能小于0"); return value; } private BigDecimal money(BigDecimal value) { return value == null ? BigDecimal.ZERO : value; } diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/SettlementAdjustmentServiceImpl.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/SettlementAdjustmentServiceImpl.java index d33dafa1..8dda1c1c 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/SettlementAdjustmentServiceImpl.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/impl/SettlementAdjustmentServiceImpl.java @@ -53,11 +53,6 @@ import java.util.Set; @RequiredArgsConstructor public class SettlementAdjustmentServiceImpl extends BaseServiceImpl implements ISettlementAdjustmentService { - private static final String DRAFT = "draft"; - private static final String REVIEWING = "reviewing"; - private static final String APPROVED = "approved"; - private static final String RETURNED = "returned"; - private static final String VOIDED = "voided"; private static final String PAID = "paid"; private final SettlementAdjustmentDetailMapper detailMapper; private final FormalSettlementMapper formalMapper; @@ -102,7 +97,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl> candidateFormalSettlements(String keyword) { List rows = formalMapper.selectList(Wrappers.lambdaQuery() - .eq(FormalSettlement::getApprovalStatus, APPROVED) + .eq(FormalSettlement::getApprovalStatus, TransportBusiConstant.APPROVED) .and(wrapper -> wrapper.isNull(FormalSettlement::getPaymentStatus) .or().ne(FormalSettlement::getPaymentStatus, PAID)) .like(Func.isNotEmpty(keyword), FormalSettlement::getFormalSettlementNo, keyword) @@ -153,7 +148,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl details = detailMapper.selectList( Wrappers.lambdaQuery() @@ -205,15 +200,15 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpllambdaQuery().eq(SettlementAdjustmentDetail::getAdjustmentId, adjustment.getId()))) { if (money(item.getAdjustmentAmountTax()).signum() == 0) continue; @@ -262,7 +257,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpllambdaQuery() .eq(FormalSettlementPayment::getIsDeleted, 0) .in(FormalSettlementPayment::getFormalSettlementId, formalSettlementIds) - .notIn(FormalSettlementPayment::getBillStatus, RETURNED, VOIDED)).stream() + .notIn(FormalSettlementPayment::getBillStatus, TransportBusiConstant.RETURNED, TransportBusiConstant.VOIDED)).stream() .map(FormalSettlementPayment::getFormalSettlementId) .filter(Objects::nonNull).toList()); result.addAll(paymentApplicationMapper.selectList(Wrappers.lambdaQuery() @@ -340,7 +335,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl relations = paymentApplicationSettlementMapper.selectList( Wrappers.lambdaQuery() @@ -358,7 +353,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpl activeApplicationIds.contains(relation.getPaymentApplicationId())) .map(PaymentApplicationSettlement::getFormalSettlementId).filter(Objects::nonNull) @@ -395,7 +390,7 @@ public class SettlementAdjustmentServiceImpl extends BaseServiceImpllambdaQuery().likeRight(SettlementAdjustment::getAdjustmentNo, prefix)); return prefix + String.format("%04d", count + 1); } private BigDecimal money(BigDecimal value) { return value == null ? BigDecimal.ZERO : value; }