From d1ef6eb97bceed6a6a42adc0b198ae2ebbcf5c0a Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Mon, 31 Aug 2026 16:11:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=B6=E4=BB=98=E6=AC=BE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InvoiceApplicationController.java | 6 +++-- .../service/IInvoiceApplicationService.java | 3 ++- .../impl/InvoiceApplicationServiceImpl.java | 26 ++++++++++++------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/InvoiceApplicationController.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/InvoiceApplicationController.java index 4a817b4..c3ac9cc 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/InvoiceApplicationController.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/controller/InvoiceApplicationController.java @@ -82,9 +82,11 @@ public class InvoiceApplicationController extends BladeController { @Operation(summary = "可开票正式结算单") public R>> settlementCandidates(Query query, @RequestParam(required = false) String keyword, - @RequestParam(required = false) String contractCategory) { + @RequestParam(required = false) String contractCategory, + @RequestParam(defaultValue = "receivable") String settlementType, + @RequestParam(defaultValue = "unreceived") String invoiceStatus) { return R.data(invoiceApplicationService.settlementCandidates( - Condition.getPage(query), keyword, contractCategory)); + Condition.getPage(query), keyword, contractCategory, settlementType, invoiceStatus)); } @GetMapping("/settlement-details") diff --git a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/IInvoiceApplicationService.java b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/IInvoiceApplicationService.java index 9434bfc..93fe9fa 100644 --- a/blade-service/blade-transport/src/main/java/org/springblade/transport/service/IInvoiceApplicationService.java +++ b/blade-service/blade-transport/src/main/java/org/springblade/transport/service/IInvoiceApplicationService.java @@ -44,7 +44,8 @@ import java.util.Map; public interface IInvoiceApplicationService extends BaseService { IPage selectPage(IPage page, InvoiceApplicationVO query); InvoiceApplicationVO detail(Long id); - IPage> settlementCandidates(IPage page, String keyword, String contractCategory); + IPage> settlementCandidates(IPage page, String keyword, String contractCategory, + String settlementType, String invoiceStatus); List settlementDetails(String settlementIds); Map receiverInformation(String settlementIds); Long saveDraft(InvoiceApplicationSaveRequest request); 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 431a5e1..b3edd8c 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 @@ -147,7 +147,9 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl> settlementCandidates(IPage page, String keyword, - String contractCategory) { + String contractCategory, String settlementType, String invoiceStatus) { + String candidateSettlementType = Func.isEmpty(settlementType) ? "receivable" : settlementType; + String candidateInvoiceStatus = Func.isEmpty(invoiceStatus) ? "unreceived" : invoiceStatus; List contractIds = Func.isEmpty(contractCategory) ? List.of() : contractManageMapper.selectList(Wrappers.lambdaQuery() .select(ContractManage::getId) @@ -158,7 +160,8 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl(page.getCurrent(), page.getSize(), 0); } List settlements = formalSettlementMapper.selectList(Wrappers.lambdaQuery() - .eq(FormalSettlement::getSettlementType, "payable") + .eq(FormalSettlement::getSettlementType, candidateSettlementType) + .eq(FormalSettlement::getInvoiceStatus, candidateInvoiceStatus) .eq(FormalSettlement::getApprovalStatus, APPROVED) .eq(FormalSettlement::getStatus, 1) .in(Func.isNotEmpty(contractCategory), FormalSettlement::getContractId, contractIds) @@ -243,13 +246,15 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl settlements = distinctIds(settlementIds).stream().map(this::availableSettlement).toList(); assertCompatible(settlements); FormalSettlement first = settlements.get(0); - CustomerArchive customer = findCustomer(first.getPayeeName()); + String customerName = "receivable".equals(first.getSettlementType()) + ? first.getPayerName() : first.getPayeeName(); + CustomerArchive customer = findCustomer(customerName); List invoiceInfos = customer == null ? List.of() : activeInvoiceInfos(customer.getId()); Map result = new LinkedHashMap<>(); result.put("issuerName", first.getPayeeName()); result.put("receiverName", first.getPayerName()); result.put("customer", customer); - // 应付结算单的开票方(payeeName)是客商,受票方信息和部门邮箱均来源于该客商发票信息。 + // 应收结算单的受票方(payerName)是客商;历史应付申请仍按开票方(payeeName)读取客商资料。 result.put("invoices", invoiceInfos); result.put("invoiceInfos", invoiceInfos); result.put("departmentEmails", invoiceInfoEmails(invoiceInfos)); @@ -274,6 +279,10 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl first, LinkedHashMap::new)).values().stream().toList(); List settlements = requestedRows.stream().map(row -> availableSettlement(row.getSettlementId())).toList(); + if (settlements.stream().anyMatch(settlement -> !"receivable".equals(settlement.getSettlementType()) + || (creating && !"unreceived".equals(settlement.getInvoiceStatus())))) { + throw new ServiceException("只能选择审批通过、未作废、未收票的应收正式结算单"); + } assertCompatible(settlements); FormalSettlement first = settlements.get(0); Map settlementMap = settlements.stream() @@ -292,8 +301,8 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl invoiceInfos = activeInvoiceInfos(customer.getId()); CustomerInvoiceInfo invoiceInfo = invoiceInfos.stream() .filter(item -> Objects.equals(item.getId(), request.getReceiverInvoiceInfoId())) @@ -475,9 +484,8 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl