From 13fd47c5aa585b74bfc8b77722bde3f7a2399587 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 21 五月 2026 10:26:42 +0800
Subject: [PATCH] refactor(invoice): 删除invoice_registration invoice_registration_product invoice_ledger invoice_ledger_file
---
src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java | 92 ++++++++++------------------------------------
1 files changed, 20 insertions(+), 72 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
index dfca752..603fd22 100644
--- a/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
+++ b/src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -10,11 +10,10 @@
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.framework.web.page.TableDataInfo;
-import com.ruoyi.sales.dto.InvoiceLedgerDto;
import com.ruoyi.sales.dto.SalesLedgerDto;
-import com.ruoyi.sales.mapper.InvoiceLedgerMapper;
import com.ruoyi.sales.mapper.ReceiptPaymentMapper;
import com.ruoyi.sales.pojo.ReceiptPayment;
import com.ruoyi.sales.pojo.SalesLedger;
@@ -56,7 +55,6 @@
private ISalesLedgerService salesLedgerService;
private ICommonFileService commonFileService;
- private InvoiceLedgerMapper invoiceLedgerMapper;
private ReceiptPaymentMapper receiptPaymentMapper;
private final FileUtil fileUtil;
@@ -66,7 +64,7 @@
@Log(title = "瀵煎叆閿�鍞彴璐�", businessType = BusinessType.INSERT)
@PostMapping("/import")
@Operation(summary = "瀵煎叆閿�鍞彴璐�")
- public R<?> importData(@RequestParam("file")
+ public AjaxResult importData(@RequestParam("file")
@ApiParam(value = "Excel鏂囦欢", required = true)
MultipartFile file) {
return salesLedgerService.importData(file);
@@ -121,20 +119,6 @@
if(CollectionUtils.isEmpty(list)){
return getDataTable(list);
}
- List<Long> salesLedgerIds = list.stream().map(SalesLedger::getId).collect(Collectors.toList());
- List<InvoiceLedgerDto> invoiceLedgerDtoList = invoiceLedgerMapper.invoicedTotal(salesLedgerIds);
- if(CollectionUtils.isEmpty(invoiceLedgerDtoList)){
- return getDataTable(list);
- }
- for (SalesLedger salesLedger : list) {
- for (InvoiceLedgerDto invoiceLedgerDto : invoiceLedgerDtoList) {
- if (salesLedger.getId().intValue() == invoiceLedgerDto.getSalesLedgerId()) {
- BigDecimal noInvoiceAmountTotal = salesLedger.getContractAmount().subtract(invoiceLedgerDto.getInvoiceTotal());
- salesLedger.setNoInvoiceAmountTotal(noInvoiceAmountTotal);
- }
- }
- }
-
return getDataTable(list);
}
@@ -182,9 +166,8 @@
*/
@Log(title = "閿�鍞彴璐�", businessType = BusinessType.INSERT)
@PostMapping("/addOrUpdateSalesLedger")
- public R<?> add(@RequestBody SalesLedgerDto salesLedgerDto) {
- salesLedgerService.addOrUpdateSalesLedger(salesLedgerDto);
- return R.ok();
+ public AjaxResult add(@RequestBody SalesLedgerDto salesLedgerDto) {
+ return toAjax(salesLedgerService.addOrUpdateSalesLedger(salesLedgerDto));
}
/**
@@ -192,12 +175,11 @@
*/
@Log(title = "閿�鍞彴璐�", businessType = BusinessType.DELETE)
@DeleteMapping("/delLedger")
- public R<?> remove(@RequestBody Long[] ids) {
+ public AjaxResult remove(@RequestBody Long[] ids) {
if (ids == null || ids.length == 0) {
- return R.fail("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
+ return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
}
- salesLedgerService.deleteSalesLedgerByIds(ids);
- return R.ok();
+ return toAjax(salesLedgerService.deleteSalesLedgerByIds(ids));
}
/**
@@ -207,9 +189,9 @@
* @return
*/
@GetMapping("/listNoPage")
- public R<?> listNoPage(SalesLedgerDto salesLedgerDto) {
+ public AjaxResult listNoPage(SalesLedgerDto salesLedgerDto) {
List<SalesLedger> list = salesLedgerService.selectSalesLedgerList(salesLedgerDto);
- return R.ok(list);
+ return AjaxResult.success(list);
}
/**
@@ -217,24 +199,23 @@
*/
@Log(title = "閿�鍞彴璐﹂檮浠跺垹闄�", businessType = BusinessType.DELETE)
@DeleteMapping("/delLedgerFile")
- public R<?> delLedgerFile(@RequestBody Long[] ids) {
+ public AjaxResult delLedgerFile(@RequestBody Long[] ids) {
if (ids == null || ids.length == 0) {
- return R.fail("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
+ return AjaxResult.error("璇蜂紶鍏ヨ鍒犻櫎鐨処D");
}
- commonFileService.deleteSalesLedgerByIds(ids);
- return R.ok();
+ return toAjax(commonFileService.deleteSalesLedgerByIds(ids));
}
/**
* 鏈湀閿�鍞悎鍚岄噾棰�
*/
@GetMapping("/getContractAmount")
- public R<?> getContractAmount() {
+ public AjaxResult getContractAmount() {
try {
BigDecimal contractAmount = salesLedgerService.getContractAmount();
- return R.ok(contractAmount != null ? contractAmount : BigDecimal.ZERO);
+ return AjaxResult.success(contractAmount != null ? contractAmount : BigDecimal.ZERO);
} catch (Exception e) {
- return R.fail("鑾峰彇鍚堝悓閲戦澶辫触锛�" + e.getMessage());
+ return AjaxResult.error("鑾峰彇鍚堝悓閲戦澶辫触锛�" + e.getMessage());
}
}
@@ -242,16 +223,16 @@
* 瀹㈡埛鍚堝悓閲戦TOP5缁熻
*/
@GetMapping("/getTopFiveList")
- public R<?> getTopFiveList() {
- return R.ok(salesLedgerService.getTopFiveList());
+ public AjaxResult getTopFiveList() {
+ return AjaxResult.success(salesLedgerService.getTopFiveList());
}
/**
* 杩戝崐骞村紑绁�,鍥炴閲戦
*/
@GetMapping("/getAmountHalfYear")
- public R<?> getAmountHalfYear(@RequestParam(value = "type",defaultValue = "1") Integer type) {
- return R.ok(salesLedgerService.getAmountHalfYear(type));
+ public AjaxResult getAmountHalfYear(@RequestParam(value = "type",defaultValue = "1") Integer type) {
+ return AjaxResult.success(salesLedgerService.getAmountHalfYear(type));
}
/**
@@ -269,20 +250,6 @@
// 鑾峰彇褰撳墠椤垫墍鏈夊彴璐﹁褰曠殑 ID 闆嗗悎
List<Long> salesLedgerIds = iPage.getRecords().stream().map(SalesLedger::getId).collect(Collectors.toList());
- // 鏌ヨ鍙戠エ淇℃伅鐨勫凡寮�绁ㄩ噾棰�
- List<InvoiceLedgerDto> invoiceLedgerDtoList = invoiceLedgerMapper.invoicedTotal(salesLedgerIds);
- if (CollectionUtils.isEmpty(invoiceLedgerDtoList)) {
- invoiceLedgerDtoList = Collections.emptyList();
- }
-
- // 杞崲鍙戠エ鏁版嵁, key 涓哄彴璐D, value 涓鸿鍙拌处鐨勬�诲紑绁ㄩ噾棰�
- Map<Long, BigDecimal> invoiceTotals = invoiceLedgerDtoList.stream()
- .filter(dto -> dto.getSalesLedgerId() != null && dto.getInvoiceTotal() != null)
- .collect(Collectors.toMap(
- dto -> dto.getSalesLedgerId().longValue(),
- InvoiceLedgerDto::getInvoiceTotal,
- BigDecimal::add // 瀛樺湪閲嶅ID鎵ц绱姞
- ));
// 鏌ヨ鍥炴/浠樻璁板綍
List<ReceiptPayment> receiptPayments = Collections.emptyList();
@@ -307,30 +274,11 @@
// 鍚堝悓鎬婚噾棰�
BigDecimal contractAmount = salesLedgerVo.getContractAmount() == null ? BigDecimal.ZERO : salesLedgerVo.getContractAmount();
// 寮�绁ㄦ�婚鍜屽洖娆炬�婚
- BigDecimal invoiceTotal = invoiceTotals.getOrDefault(ledgerId, BigDecimal.ZERO);
BigDecimal receiptPaymentAmountTotal = receiptTotals.getOrDefault(ledgerId, BigDecimal.ZERO);
- // 鏈紑绁ㄩ噾棰� = 鍚堝悓閲戦 - 宸插紑绁ㄩ噾棰�
- BigDecimal noInvoiceAmountTotal = contractAmount.subtract(invoiceTotal);
- if (noInvoiceAmountTotal.compareTo(BigDecimal.ZERO) < 0) {
- noInvoiceAmountTotal = BigDecimal.ZERO;
- }
-
- // 寰呭洖娆鹃噾棰� = 宸插紑绁ㄩ噾棰� - 宸插洖娆鹃噾棰�
- BigDecimal noReceiptPaymentAmountTotal = invoiceTotal.subtract(receiptPaymentAmountTotal);
- if (noReceiptPaymentAmountTotal.compareTo(BigDecimal.ZERO) < 0) {
- noReceiptPaymentAmountTotal = BigDecimal.ZERO;
- }
-
- salesLedgerVo.setNoInvoiceAmountTotal(noInvoiceAmountTotal);
- salesLedgerVo.setInvoiceTotal(invoiceTotal);
- salesLedgerVo.setReceiptPaymentAmountTotal(receiptPaymentAmountTotal);
- salesLedgerVo.setNoReceiptAmount(noReceiptPaymentAmountTotal);
-
// 濡傛灉宸茬粡鏈夎繃寮�绁ㄦ垨鍥炴鎿嶄綔,鍒欎笉鍏佽缂栬緫
- boolean hasInvoiceOperation = invoiceTotal.compareTo(BigDecimal.ZERO) > 0;
boolean hasReceiptOperation = receiptPaymentAmountTotal.compareTo(BigDecimal.ZERO) > 0;
- salesLedgerVo.setIsEdit(!(hasInvoiceOperation || hasReceiptOperation));
+ salesLedgerVo.setIsEdit(hasReceiptOperation);
salesLedgerVo.setStorageBlobVOs(fileUtil.getStorageBlobVOsByApplicationAndRecordTypeAndRecordId(ApplicationTypeEnum.FILE, RecordTypeEnum.SALES_LEDGER, ledgerId));
}
--
Gitblit v1.9.3