From 0240f4dceb273622ddf7ab577ab9018295c17233 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期五, 14 八月 2026 14:55:22 +0800
Subject: [PATCH] 修复跟进记录图片上传问题

---
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java |   62 ++++++++++++++++++++++++-------
 1 files changed, 48 insertions(+), 14 deletions(-)

diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
index a2a70b4..d78cba5 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
@@ -19,12 +19,14 @@
 import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
 import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO;
 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
-import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
+import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
+import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi;
+import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemRespDTO;
 import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
 import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
 import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
-import cn.iocoder.yudao.module.crm.service.product.CrmProductService;
+import cn.iocoder.yudao.module.crm.service.invoice.CrmInvoiceService;
 import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService;
 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
@@ -69,9 +71,12 @@
     @Resource
     private CrmBusinessService businessService;
     @Resource
-    private CrmProductService productService;
-    @Resource
     private CrmReceivableService receivableService;
+    @Resource
+    private CrmInvoiceService invoiceService;
+
+    @Resource
+    private MdmItemApi mdmItemApi;
 
     @Resource
     private AdminUserApi adminUserApi;
@@ -118,12 +123,12 @@
         CrmContractRespVO contractVO = buildContractDetailList(singletonList(contract)).get(0);
         // 鎷兼帴浜у搧椤�
         List<CrmContractProductDO> businessProducts = contractService.getContractProductListByContractId(contractVO.getId());
-        Map<Long, CrmProductDO> productMap = productService.getProductMap(
-                convertSet(businessProducts, CrmContractProductDO::getProductId));
+        Map<Long, MdmItemRespDTO> itemMap = mdmItemApi.getItemMap(
+                convertSet(businessProducts, CrmContractProductDO::getItemId));
         contractVO.setProducts(BeanUtils.toBean(businessProducts, CrmContractRespVO.Product.class, businessProductVO ->
-                MapUtils.findAndThen(productMap, businessProductVO.getProductId(),
-                        product -> businessProductVO.setProductName(product.getName())
-                                .setProductNo(product.getNo()).setProductUnit(product.getUnit()))));
+                MapUtils.findAndThen(itemMap, businessProductVO.getItemId(),
+                        item -> businessProductVO.setItemCode(item.getCode())
+                                .setItemName(item.getName()).setItemBarCode(item.getBarCode()))));
         return contractVO;
     }
 
@@ -158,9 +163,18 @@
     public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO,
                                     HttpServletResponse response) throws IOException {
         PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO, getLoginUserId());
+        List<CrmContractRespVO> list = BeanUtils.toBean(pageResult.getList(), CrmContractRespVO.class);
+        // 璁$畻鏈洖娆鹃噾棰濄�佽浆鎹㈠鎵圭姸鎬佷负涓枃
+        list.forEach(vo -> {
+            if (vo.getTotalPrice() != null && vo.getTotalReceivablePrice() != null) {
+                vo.setUnReceivablePrice(vo.getTotalPrice().subtract(vo.getTotalReceivablePrice()));
+            }
+            if (vo.getAuditStatus() != null) {
+                vo.setAuditStatusName(CrmAuditStatusEnum.getNameByStatus(vo.getAuditStatus()));
+            }
+        });
         // 瀵煎嚭 Excel
-        ExcelUtils.write(response, "鍚堝悓.xls", "鏁版嵁", CrmContractRespVO.class,
-                BeanUtils.toBean(pageResult.getList(), CrmContractRespVO.class));
+        ExcelUtils.write(response, "鍚堝悓.xls", "鏁版嵁", CrmContractRespVO.class, list);
     }
 
     @PutMapping("/transfer")
@@ -174,9 +188,17 @@
     @PutMapping("/submit")
     @Operation(summary = "鎻愪氦鍚堝悓瀹℃壒")
     @PreAuthorize("@ss.hasPermission('crm:contract:update')")
-    public CommonResult<Boolean> submitContract(@RequestParam("id") Long id) {
-        contractService.submitContract(id, getLoginUserId());
+    public CommonResult<Boolean> submitContract(@RequestParam("id") Long id,
+                                                  @RequestParam("processDefinitionKey") String processDefinitionKey) {
+        contractService.submitContract(id, processDefinitionKey, getLoginUserId());
         return success(true);
+    }
+
+    @GetMapping("/approve-process-list")
+    @Operation(summary = "鑾峰彇鍚堝悓瀹℃壒娴佺▼鍒楄〃")
+    @PreAuthorize("@ss.hasPermission('crm:contract:query')")
+    public CommonResult<List<Map<String, Object>>> getContractApproveProcessList() {
+        return success(contractService.getContractApproveProcessDefinitionList());
     }
 
     private List<CrmContractRespVO> buildContractDetailList(List<CrmContractDO> contractList) {
@@ -199,6 +221,9 @@
         // 1.5 鑾峰緱宸插洖娆鹃噾棰�
         Map<Long, BigDecimal> receivablePriceMap = receivableService.getReceivablePriceMapByContractId(
                 convertSet(contractList, CrmContractDO::getId));
+        // 1.6 鑾峰緱宸插紑绁ㄩ噾棰濓紙瀹℃壒閫氳繃 + 瀹℃壒涓紝涓庡紑绁ㄩ槻瓒呮牎楠屽彛寰勪竴鑷达級
+        Map<Long, BigDecimal> invoicePriceMap = invoiceService.getInvoicePriceMapByContractId(
+                convertSet(contractList, CrmContractDO::getId));
         // 2. 鎷兼帴鏁版嵁
         return BeanUtils.toBean(contractList, CrmContractRespVO.class, contractVO -> {
             // 2.1 璁剧疆瀹㈡埛淇℃伅
@@ -216,6 +241,12 @@
             findAndThen(businessMap, contractVO.getBusinessId(), business -> contractVO.setBusinessName(business.getName()));
             // 2.5 璁剧疆宸插洖娆鹃噾棰�
             contractVO.setTotalReceivablePrice(receivablePriceMap.getOrDefault(contractVO.getId(), BigDecimal.ZERO));
+            // 2.6 璁剧疆宸插紑绁ㄩ噾棰�
+            contractVO.setTotalInvoicePrice(invoicePriceMap.getOrDefault(contractVO.getId(), BigDecimal.ZERO));
+            // 2.7 璁剧疆鏈紑绁ㄩ噾棰�
+            if (contractVO.getTotalPrice() != null && contractVO.getTotalInvoicePrice() != null) {
+                contractVO.setUnInvoicePrice(contractVO.getTotalPrice().subtract(contractVO.getTotalInvoicePrice()));
+            }
         });
     }
 
@@ -247,10 +278,13 @@
         // 鎷兼帴鏁版嵁
         Map<Long, BigDecimal> receivablePriceMap = receivableService.getReceivablePriceMapByContractId(
                 convertSet(pageResult.getList(), CrmContractDO::getId));
+        Map<Long, BigDecimal> invoicePriceMap = invoiceService.getInvoicePriceMapByContractId(
+                convertSet(pageResult.getList(), CrmContractDO::getId));
         return success(convertList(pageResult.getList(), contract -> new CrmContractRespVO() // 鍙繑鍥� id銆乶ame 绛夌簿绠�瀛楁
                 .setId(contract.getId()).setName(contract.getName()).setAuditStatus(contract.getAuditStatus())
                 .setTotalPrice(contract.getTotalPrice())
-                .setTotalReceivablePrice(receivablePriceMap.getOrDefault(contract.getId(), BigDecimal.ZERO))));
+                .setTotalReceivablePrice(receivablePriceMap.getOrDefault(contract.getId(), BigDecimal.ZERO))
+                .setTotalInvoicePrice(invoicePriceMap.getOrDefault(contract.getId(), BigDecimal.ZERO))));
     }
 
     @PostMapping("/generate-sale-order")

--
Gitblit v1.9.3