From a82d847bbb39e2417d4c9773ebc4fc51fdb0b8fc Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 10 十一月 2026 13:31:31 +0800
Subject: [PATCH] feat(crm): 完善投标保证金与报价单关联及作废功能

---
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/quotation/CrmSaleQuotationMapper.java |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/quotation/CrmSaleQuotationMapper.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/quotation/CrmSaleQuotationMapper.java
index 7a3a05b..4dbbfbf 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/quotation/CrmSaleQuotationMapper.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/quotation/CrmSaleQuotationMapper.java
@@ -5,6 +5,7 @@
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import cn.iocoder.yudao.module.crm.controller.admin.quotation.vo.CrmSaleQuotationPageReqVO;
 import cn.iocoder.yudao.module.crm.dal.dataobject.quotation.CrmSaleQuotationDO;
 import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
@@ -12,13 +13,15 @@
 import cn.iocoder.yudao.module.crm.enums.quotation.CrmSaleQuotationStatusEnum;
 import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 
+import java.util.Collection;
 import java.util.List;
 
 /**
  * CRM 閿�鍞姤浠峰崟 Mapper
  *
- * @author 鑺嬮亾婧愮爜
+ * @author 瓒呯骇绠$悊鍛�
  */
 @Mapper
 public interface CrmSaleQuotationMapper extends BaseMapperX<CrmSaleQuotationDO> {
@@ -26,6 +29,13 @@
     default CrmSaleQuotationDO selectByNo(String no) {
         return selectOne(CrmSaleQuotationDO::getNo, no);
     }
+
+    /**
+     * 鎸夋姤浠峰崟鍙锋煡璇㈣褰曪紙涓嶈繃婊ら�昏緫鍒犻櫎锛屽惈宸插垹闄よ锛�
+     * 鐢ㄤ簬鑷畾涔夊崟鍙风殑鍞竴鎬ч鏍¢獙锛歶k_no 鍞竴绱㈠紩瑕嗙洊宸插垹闄よ锛岄渶涓�璧峰垽鏂墠鑳界粰鍑哄彲璇绘彁绀�
+     */
+    @Select("SELECT * FROM crm_sale_quotation WHERE no = #{no} LIMIT 1")
+    CrmSaleQuotationDO selectAnyByNo(String no);
 
     default PageResult<CrmSaleQuotationDO> selectPage(CrmSaleQuotationPageReqVO pageReqVO, Long userId) {
         return selectPage(pageReqVO, userId, null);
@@ -50,6 +60,7 @@
                 .eqIfPresent(CrmSaleQuotationDO::getCustomerId, pageReqVO.getCustomerId())
                 .eqIfPresent(CrmSaleQuotationDO::getBusinessId, pageReqVO.getBusinessId())
                 .eqIfPresent(CrmSaleQuotationDO::getStatus, pageReqVO.getStatus())
+                .likeIfPresent(CrmSaleQuotationDO::getBidBondNo, pageReqVO.getBidBondNo())
                 .orderByDesc(CrmSaleQuotationDO::getId);
 
         // 瀹㈡埛鏉冮檺杩囨护
@@ -83,6 +94,14 @@
         return selectList(CrmSaleQuotationDO::getCustomerId, customerId);
     }
 
+    default List<CrmSaleQuotationDO> selectListByCustomerIdAndStatuses(Long customerId,
+                                                                      Collection<Integer> statuses) {
+        return selectList(new LambdaQueryWrapperX<CrmSaleQuotationDO>()
+                .eq(CrmSaleQuotationDO::getCustomerId, customerId)
+                .in(CrmSaleQuotationDO::getStatus, statuses)
+                .orderByDesc(CrmSaleQuotationDO::getId));
+    }
+
     default List<CrmSaleQuotationDO> selectListByBusinessId(Long businessId) {
         return selectList(CrmSaleQuotationDO::getBusinessId, businessId);
     }
@@ -95,4 +114,37 @@
         return selectCount(CrmSaleQuotationDO::getCustomerId, customerId);
     }
 
+    /**
+     * 娓呴櫎鎶ヤ环鍗曠殑鍚堝悓鍏宠仈锛堝垹闄ゅ悎鍚屾椂璋冪敤锛�
+     *
+     * @param quotationId 鎶ヤ环鍗曠紪鍙�
+     */
+    default void clearContractReference(Long quotationId) {
+        update(new LambdaUpdateWrapper<CrmSaleQuotationDO>()
+                .eq(CrmSaleQuotationDO::getId, quotationId)
+                .set(CrmSaleQuotationDO::getContractId, null)
+                .set(CrmSaleQuotationDO::getStatus,0)
+                .set(CrmSaleQuotationDO::getContractNo, null));
+    }
+
+    /**
+     * 缁戝畾鎶曟爣锛沚idBondId 涓� null 鏃惰〃绀鸿В缁�
+     */
+    default void bindBidBond(Long quotationId, Long bidBondId, String bidBondNo) {
+        update(new LambdaUpdateWrapper<CrmSaleQuotationDO>()
+                .eq(CrmSaleQuotationDO::getId, quotationId)
+                .set(CrmSaleQuotationDO::getBidBondId, bidBondId)
+                .set(CrmSaleQuotationDO::getBidBondNo, bidBondNo));
+    }
+
+    /**
+     * 閲嶆柊鎶ヤ环锛氶噸缃负鑽夌骞舵竻绌烘祦绋嬪疄渚�
+     */
+    default void resetToDraft(Long quotationId) {
+        update(new LambdaUpdateWrapper<CrmSaleQuotationDO>()
+                .eq(CrmSaleQuotationDO::getId, quotationId)
+                .set(CrmSaleQuotationDO::getStatus, CrmSaleQuotationStatusEnum.DRAFT.getStatus())
+                .set(CrmSaleQuotationDO::getProcessInstanceId, null));
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.3