| | |
| | | package cn.iocoder.yudao.module.srm.service.tender; |
| | | |
| | | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.srm.controller.admin.tender.vo.SrmSupplierQuoteSaveReqVO; |
| | | import cn.iocoder.yudao.module.srm.controller.admin.tender.vo.SrmTenderBidSaveReqVO; |
| | | import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierDO; |
| | | import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierQuoteDO; |
| | | import cn.iocoder.yudao.module.srm.dal.dataobject.SrmTenderBidDO; |
| | | import cn.iocoder.yudao.module.srm.dal.dataobject.SrmTenderProjectDO; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierApplyMapper; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierMapper; |
| | | 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 org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | |
| | | private SrmTenderProjectMapper tenderProjectMapper; |
| | | |
| | | @Resource |
| | | private SrmSupplierApplyMapper supplierApplyMapper; |
| | | private SrmSupplierMapper supplierMapper; |
| | | |
| | | // ========== 投标管理 ========== |
| | | |
| | |
| | | if (project.getEndTime() != null && LocalDateTime.now().isAfter(project.getEndTime())) { |
| | | throw ServiceExceptionUtil.exception(ErrorCodeConstants.TENDER_END_TIME_PASSED); |
| | | } |
| | | // 校验供应商是否已通过准入审批 |
| | | if (!supplierApplyMapper.existsApprovedBySupplierId(createReqVO.getSupplierId())) { |
| | | throw ServiceExceptionUtil.exception(ErrorCodeConstants.BID_SUPPLIER_NOT_APPROVED); |
| | | // 校验投标供应商存在且未停用(准入状态不限制投标,中标生成采购订单时自动准入) |
| | | SrmSupplierDO supplier = supplierMapper.selectById(createReqVO.getSupplierId()); |
| | | if (supplier == null) { |
| | | throw ServiceExceptionUtil.exception(ErrorCodeConstants.SUPPLIER_NOT_EXISTS); |
| | | } |
| | | if (CommonStatusEnum.isDisable(supplier.getStatus())) { |
| | | throw ServiceExceptionUtil.exception(ErrorCodeConstants.SUPPLIER_NOT_ENABLE, supplier.getName()); |
| | | } |
| | | // 校验投标编号是否重复 |
| | | if (tenderBidMapper.existsByBidNo(createReqVO.getBidNo())) { |
| | |
| | | // ========== 报价管理 ========== |
| | | |
| | | @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) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateQuote(SrmSupplierQuoteSaveReqVO updateReqVO) { |
| | | // 校验投标状态(撤标后不允许报价) |
| | | SrmTenderBidDO bid = validateBidNotWithdrawn(updateReqVO.getBidId()); |
| | |
| | | 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 字段,null 视为不改) |
| | | if (bidTotalAmount != null) { |
| | | bid.setBidTotalAmount(bidTotalAmount); |
| | | tenderBidMapper.updateById(bid); |
| | | } |
| | | } |
| | | |
| | | // ========== 校验方法 ========== |
| | | |
| | | private SrmTenderBidDO validateBidExists(Long id) { |