| | |
| | | productStructureDtos.add(productStructureDto); |
| | | } |
| | | for (ProductStructureDto productStructureDto : productStructureDtos) { |
| | | ProductModel productModel1 = productModelMapper.selectById(productStructureDto.getProductModelId()); |
| | | Product product = productMapper.selectById(productModel1.getProductId()); |
| | | BigDecimal stockQuantity = stockUtils.getStockQuantity(productModel1.getId()).get("stockQuantity"); |
| | | if (!(stockQuantity.compareTo(BigDecimal.ZERO) > 0)) { |
| | | throw new RuntimeException(product.getProductName()+"产品的"+productModel1.getModel() + "的规格库存为0"); |
| | | } |
| | | if (stockQuantity.compareTo(productStructureDto.getUnitQuantity().multiply(dto.getQuantity())) < 0) { |
| | | throw new RuntimeException(product.getProductName()+"产品的"+productModel1.getModel() + "的规格库存不足"); |
| | | } |
| | | |
| | | ProductionProductInput productionProductInput = new ProductionProductInput(); |
| | | productionProductInput.setProductModelId(productStructureDto.getProductModelId()); |
| | | productionProductInput.setQuantity(productStructureDto.getUnitQuantity().multiply(dto.getQuantity())); |