From c2053d7017625f270577bc0f6c523d04f52db6ea Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 24 七月 2026 14:20:29 +0800
Subject: [PATCH] refactor(crm): 重构文件上传功能,替换原有的fileUrls字段为统一的StorageAttachmentApi

---
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java
index e5ad277..c7bab33 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java
@@ -20,8 +20,10 @@
 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.api.customer.CrmCustomerApi;
 import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
+import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi;
 import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi;
 import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemRespDTO;
 import jakarta.annotation.Resource;
@@ -61,11 +63,15 @@
     @Resource
     private CrmCustomerService customerService;
     @Resource
+    private CrmCustomerApi customerApi;
+    @Resource
     private CrmBusinessService businessService;
     @Resource
     private CrmContactService contactService;
     @Resource
     private CrmPermissionService permissionService;
+    @Resource
+    private StorageAttachmentApi storageAttachmentApi;
     @Resource
     private CrmContractService contractService;
 
@@ -97,6 +103,8 @@
                 .setBizType(CrmBizTypeEnum.CRM_SALE_QUOTATION.getType())
                 .setBizId(saleQuotation.getId())
                 .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
+        storageAttachmentApi.bindAttachments("file", "crm_sale_quotation",
+                saleQuotation.getId(), createReqVO.getBlobIds());
         return saleQuotation.getId();
     }
 
@@ -120,6 +128,11 @@
         saleQuotationMapper.updateById(updateObj);
         // 2.2 鏇存柊鎶ヤ环鏄庣粏
         updateQuotationProductList(updateReqVO.getId(), quotationProducts);
+        if (updateReqVO.getBlobIds() != null) {
+            storageAttachmentApi.deleteAttachmentsByRecord("crm_sale_quotation", updateReqVO.getId());
+            storageAttachmentApi.bindAttachments("file", "crm_sale_quotation",
+                    updateReqVO.getId(), updateReqVO.getBlobIds());
+        }
     }
 
     @Override
@@ -138,6 +151,8 @@
 
         // 2. 閬嶅巻鍒犻櫎
         saleQuotations.forEach(saleQuotation -> {
+            // 2.0 鍒犻櫎闄勪欢鍏宠仈
+            storageAttachmentApi.deleteAttachmentsByRecord("crm_sale_quotation", saleQuotation.getId());
             // 2.1 鍒犻櫎鎶ヤ环鍗�
             saleQuotationMapper.deleteById(saleQuotation.getId());
             // 2.2 鍒犻櫎鎶ヤ环鏄庣粏
@@ -229,7 +244,9 @@
 
     @Override
     public PageResult<CrmSaleQuotationDO> getSaleQuotationPage(CrmSaleQuotationPageReqVO pageReqVO, Long userId) {
-        return saleQuotationMapper.selectPage(pageReqVO, userId);
+        // 鑾峰彇鐢ㄦ埛鏈夋潈闄愮殑瀹㈡埛 ID 鍒楄〃
+        List<Long> permittedCustomerIds = customerApi.getPermittedCustomerIds();
+        return saleQuotationMapper.selectPage(pageReqVO, userId, permittedCustomerIds);
     }
 
     @Override

--
Gitblit v1.9.3