| | |
| | | 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; |
| | |
| | | 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.*; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private SrmSupplierMapper supplierMapper; |
| | | @Resource |
| | | private SrmTenderMaterialMapper tenderMaterialMapper; |
| | | |
| | | // ========== 投标管理 ========== |
| | | |
| | |
| | | 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); |
| | |
| | | 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); |