云
2026-10-31 bf5f52656e128f578ed42c7979c31cf4b476ce46
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/quotation/CrmSaleQuotationServiceImpl.java
@@ -26,6 +26,7 @@
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;
@@ -42,7 +43,7 @@
/**
 * CRM 销售报价单 Service 实现类
 *
 * @author 芋道源码
 * @author 超级管理员
 */
@Service
@Validated
@@ -284,6 +285,16 @@
        // 2. 获取报价明细
        List<CrmSaleQuotationProductDO> quotationProducts = saleQuotationProductMapper.selectListByQuotationId(id);
        // 合同明细使用整数数量,禁止截断小数或溢出后生成错误订单。
        for (CrmSaleQuotationProductDO product : quotationProducts) {
            try {
                if (product.getCount() == null || product.getCount().intValueExact() <= 0) {
                    throw exception(SALE_QUOTATION_CONVERT_INVALID_COUNT);
                }
            } catch (ArithmeticException ex) {
                throw exception(SALE_QUOTATION_CONVERT_INVALID_COUNT);
            }
        }
        // 3. 构建合同创建 VO
        CrmContractSaveReqVO contractVO = new CrmContractSaveReqVO();
        contractVO.setName(saleQuotation.getName() + "-合同");
@@ -318,4 +329,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);
    }
}