7 天以前 e1797a873bf114329f4870062201d388155ef014
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/service/apply/SrmSupplierApplyServiceImpl.java
@@ -145,6 +145,43 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void ensureSupplierApproved(Long supplierId) {
        if (supplierId == null) {
            return;
        }
        // 校验供应商存在
        SrmSupplierDO supplier = supplierMapper.selectById(supplierId);
        if (supplier == null) {
            throw ServiceExceptionUtil.exception(ErrorCodeConstants.SUPPLIER_NOT_EXISTS);
        }
        // 已准入则无需处理
        if (supplierApplyMapper.existsApprovedBySupplierId(supplierId)) {
            return;
        }
        // 自动创建准入申请并直接置为已通过
        SrmSupplierApplyDO apply = new SrmSupplierApplyDO();
        apply.setApplyNo(generateApplyNo());
        apply.setSupplierId(supplierId);
        apply.setSupplierName(supplier.getName());
        apply.setSupplierType(supplier.getType());
        apply.setCompanyNature(supplier.getCompanyNature());
        apply.setRegisteredCapital(supplier.getRegisteredCapital());
        apply.setBusinessLicenseNo(supplier.getBusinessLicenseNo());
        apply.setTaxNo(supplier.getTaxNo());
        apply.setAddress(supplier.getAddress());
        apply.setBankName(supplier.getBankName());
        apply.setBankAccount(supplier.getBankAccount());
        apply.setContactName(supplier.getContactName());
        apply.setContactMobile(supplier.getContactMobile());
        apply.setContactEmail(supplier.getContactEmail());
        apply.setRemark("中标生成采购订单时自动准入并通过");
        apply.setApplyStatus(SupplierApplyStatusEnum.APPROVED.getCode());
        apply.setApplyTime(LocalDateTime.now());
        supplierApplyMapper.insert(apply);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void approve(Long id) {
        SrmSupplierApplyDO apply = validateApplyExists(id);
        if (!SupplierApplyStatusEnum.APPROVED.getCode().equals(apply.getApplyStatus())) {