xiaoyi
2 天以前 b5e1bceabb36fe1d1e5e88397280d12e7044c6dd
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/tender/SrmTenderBidServiceImpl.java
@@ -12,6 +12,7 @@
import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierQuoteMapper;
import cn.iocoder.yudao.module.srm.dal.mysql.SrmTenderBidMapper;
import cn.iocoder.yudao.module.srm.dal.mysql.SrmTenderProjectMapper;
import cn.iocoder.yudao.module.srm.dal.mysql.SrmTenderMaterialMapper;
import cn.iocoder.yudao.module.srm.enums.BidStatusEnum;
import cn.iocoder.yudao.module.srm.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.srm.enums.TenderStatusEnum;
@@ -26,6 +27,7 @@
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import static cn.iocoder.yudao.module.srm.enums.LogRecordConstants.*;
@@ -47,6 +49,8 @@
    @Resource
    private SrmSupplierMapper supplierMapper;
    @Resource
    private SrmTenderMaterialMapper tenderMaterialMapper;
    // ========== 投标管理 ==========
@@ -129,6 +133,7 @@
        if (project == null || !TenderStatusEnum.canCreateOrUpdateQuote(project.getTenderStatus())) {
            throw ServiceExceptionUtil.exception(ErrorCodeConstants.TENDER_QUOTE_FORBIDDEN);
        }
        validateQuoteMaterial(createReqVO.getTenderMaterialId(), bid.getTenderProjectId());
        // 校验同一投标下物料不可重复报价
        if (supplierQuoteMapper.existsByBidAndMaterial(createReqVO.getBidId(), createReqVO.getTenderMaterialId())) {
            throw ServiceExceptionUtil.exception(ErrorCodeConstants.QUOTE_MATERIAL_DUPLICATE);
@@ -152,16 +157,28 @@
            throw ServiceExceptionUtil.exception(ErrorCodeConstants.TENDER_QUOTE_FORBIDDEN);
        }
        // 校验同一投标下物料不可重复报价(排除自身)
        SrmSupplierQuoteDO existing = supplierQuoteMapper.selectById(updateReqVO.getId());
        if (existing != null && !existing.getTenderMaterialId().equals(updateReqVO.getTenderMaterialId())) {
        SrmSupplierQuoteDO existing = updateReqVO.getId() == null ? null : supplierQuoteMapper.selectById(updateReqVO.getId());
        if (existing == null) throw ServiceExceptionUtil.exception(ErrorCodeConstants.QUOTE_NOT_EXISTS);
        if (!Objects.equals(existing.getBidId(), bid.getId())) throw ServiceExceptionUtil.exception(ErrorCodeConstants.QUOTE_BID_MISMATCH);
        validateQuoteMaterial(updateReqVO.getTenderMaterialId(), bid.getTenderProjectId());
        if (!Objects.equals(existing.getTenderMaterialId(), updateReqVO.getTenderMaterialId())) {
            if (supplierQuoteMapper.existsByBidAndMaterial(updateReqVO.getBidId(), updateReqVO.getTenderMaterialId())) {
                throw ServiceExceptionUtil.exception(ErrorCodeConstants.QUOTE_MATERIAL_DUPLICATE);
            }
        }
        SrmSupplierQuoteDO updateObj = BeanUtils.toBean(updateReqVO, SrmSupplierQuoteDO.class);
        updateObj.setTenderProjectId(bid.getTenderProjectId());
        updateObj.setSupplierId(bid.getSupplierId());
        supplierQuoteMapper.updateById(updateObj);
    }
    private void validateQuoteMaterial(Long materialId, Long projectId) {
        var material = materialId == null ? null : tenderMaterialMapper.selectById(materialId);
        if (material == null || !Objects.equals(material.getTenderProjectId(), projectId)) {
            throw ServiceExceptionUtil.exception(ErrorCodeConstants.QUOTE_MATERIAL_NOT_IN_PROJECT);
        }
    }
    @Override
    public List<SrmSupplierQuoteDO> getQuoteList(Long bidId) {
        return supplierQuoteMapper.selectListByBidId(bidId);