From bb0b80bd7ca7c1f979ab0125ae01f3faa1d14f4b Mon Sep 17 00:00:00 2001
From: hsy <1029150275@qq.com>
Date: 星期一, 17 八月 2026 09:37:57 +0800
Subject: [PATCH] Merge branch 'refs/heads/dev_business' into fix/hsy/20260811

---
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java |   21 ++++++++++++++++++++-
 1 files changed, 20 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 99dda59..1b0237a 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
@@ -23,8 +23,10 @@
 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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -41,7 +43,7 @@
 /**
  * CRM 閿�鍞姤浠峰崟 Service 瀹炵幇绫�
  *
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
  */
 @Service
 @Validated
@@ -69,6 +71,8 @@
     private CrmContactService contactService;
     @Resource
     private CrmPermissionService permissionService;
+    @Resource
+    private StorageAttachmentApi storageAttachmentApi;
     @Resource
     private CrmContractService contractService;
 
@@ -100,6 +104,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();
     }
 
@@ -123,6 +129,7 @@
         saleQuotationMapper.updateById(updateObj);
         // 2.2 鏇存柊鎶ヤ环鏄庣粏
         updateQuotationProductList(updateReqVO.getId(), quotationProducts);
+        storageAttachmentApi.updateAttachments("file", "crm_sale_quotation", updateReqVO.getId(), updateReqVO.getBlobIds());
     }
 
     @Override
@@ -141,6 +148,8 @@
 
         // 2. 閬嶅巻鍒犻櫎
         saleQuotations.forEach(saleQuotation -> {
+            // 2.0 鍒犻櫎闄勪欢鍏宠仈
+            storageAttachmentApi.deleteAttachmentsByRecord("crm_sale_quotation", saleQuotation.getId());
             // 2.1 鍒犻櫎鎶ヤ环鍗�
             saleQuotationMapper.deleteById(saleQuotation.getId());
             // 2.2 鍒犻櫎鎶ヤ环鏄庣粏
@@ -310,4 +319,14 @@
         return contractId;
     }
 
+    @Override
+    public CrmSaleQuotationDO getByContractId(Long id) {
+        return saleQuotationMapper.selectOne(new LambdaQueryWrapper<CrmSaleQuotationDO>().eq(CrmSaleQuotationDO::getContractId,id));
+    }
+
+    @Override
+    public void clearContractReference(Long quotationId) {
+        saleQuotationMapper.clearContractReference(quotationId);
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.3