From b5e1bceabb36fe1d1e5e88397280d12e7044c6dd Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期五, 06 十一月 2026 15:32:31 +0800
Subject: [PATCH] 完善设备采集、安全管理及采购业务
---
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/tender/SrmTenderBidServiceImpl.java | 42 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/tender/SrmTenderBidServiceImpl.java b/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/tender/SrmTenderBidServiceImpl.java
index 4dd6b76..ab35008 100644
--- a/yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/tender/SrmTenderBidServiceImpl.java
+++ b/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;
@@ -23,8 +24,10 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
+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.*;
@@ -46,6 +49,8 @@
@Resource
private SrmSupplierMapper supplierMapper;
+ @Resource
+ private SrmTenderMaterialMapper tenderMaterialMapper;
// ========== 鎶曟爣绠$悊 ==========
@@ -117,6 +122,7 @@
// ========== 鎶ヤ环绠$悊 ==========
@Override
+ @Transactional(rollbackFor = Exception.class)
@LogRecord(type = LOG_QUOTE_TYPE, subType = LOG_QUOTE_CREATE_SUB_TYPE,
bizNo = "{{#createReqVO.bidId}}", success = LOG_QUOTE_CREATE_SUCCESS)
public Long createQuote(SrmSupplierQuoteSaveReqVO createReqVO) {
@@ -127,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);
@@ -140,6 +147,7 @@
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public void updateQuote(SrmSupplierQuoteSaveReqVO updateReqVO) {
// 鏍¢獙鎶曟爣鐘舵�侊紙鎾ゆ爣鍚庝笉鍏佽鎶ヤ环锛�
SrmTenderBidDO bid = validateBidNotWithdrawn(updateReqVO.getBidId());
@@ -149,14 +157,26 @@
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
@@ -164,6 +184,24 @@
return supplierQuoteMapper.selectListByBidId(bidId);
}
+ // ========== 鎶曟爣鎬婚噾棰濓紙浜哄伐缁存姢锛屽彲鑷姩甯﹀嚭鎶ヤ环鍚堣鍚庤皟鏁达級 ==========
+
+ @Override
+ public void updateBidTotal(Long bidId, BigDecimal bidTotalAmount) {
+ // 鏍¢獙鎶曟爣鐘舵�侊紙鎾ゆ爣鍚庝笉鍏佽淇敼锛�
+ SrmTenderBidDO bid = validateBidNotWithdrawn(bidId);
+ // 鏍¢獙鎷涙爣椤圭洰鐘舵�侊細浠呭厑璁哥淮鎶ゆ姤浠风殑鎷涙爣鐘舵�佷笅鍙慨鏀�
+ SrmTenderProjectDO project = tenderProjectMapper.selectById(bid.getTenderProjectId());
+ if (project == null || !TenderStatusEnum.canCreateOrUpdateQuote(project.getTenderStatus())) {
+ throw ServiceExceptionUtil.exception(ErrorCodeConstants.TENDER_QUOTE_FORBIDDEN);
+ }
+ // 浠呭湪浼犲叆闈� null 鏃舵洿鏂帮紙MyBatis-Plus updateById 浼氬拷鐣� null 瀛楁锛宯ull 瑙嗕负涓嶆敼锛�
+ if (bidTotalAmount != null) {
+ bid.setBidTotalAmount(bidTotalAmount);
+ tenderBidMapper.updateById(bid);
+ }
+ }
+
// ========== 鏍¢獙鏂规硶 ==========
private SrmTenderBidDO validateBidExists(Long id) {
--
Gitblit v1.9.3