gongchunyi
15 小时以前 6b4cfc6f9d660b92be99ba4e3411a3267bc57155
src/main/java/com/ruoyi/stock/service/impl/StockUninventoryServiceImpl.java
@@ -54,6 +54,8 @@
        stockInRecordDto.setStockInNum(stockUninventoryDto.getQualitity());
        stockInRecordDto.setProductModelId(stockUninventoryDto.getProductModelId());
        stockInRecordDto.setType("1");
        stockInRecordDto.setSalesLedgerId(stockUninventoryDto.getSalesLedgerId());
        stockInRecordDto.setSalesLedgerProductId(stockUninventoryDto.getSalesLedgerProductId());
        stockInRecordService.add(stockInRecordDto);
        //再进行新增库存数量库存
        //先查询库存表中的产品是否存在,不存在新增,存在更新
@@ -82,12 +84,17 @@
        stockOutRecordDto.setStockOutNum(stockUninventoryDto.getQualitity());
        stockOutRecordDto.setProductModelId(stockUninventoryDto.getProductModelId());
        stockOutRecordDto.setType("1");
        stockOutRecordDto.setSalesLedgerId(stockUninventoryDto.getSalesLedgerId());
        stockOutRecordDto.setSalesLedgerProductId(stockUninventoryDto.getSalesLedgerProductId());
        stockOutRecordService.add(stockOutRecordDto);
        StockUninventory oldStockInventory = stockUninventoryMapper.selectOne(new QueryWrapper<StockUninventory>().lambda().eq(StockUninventory::getProductModelId, stockUninventoryDto.getProductModelId()));
        if (ObjectUtils.isEmpty(oldStockInventory)) {
            throw new RuntimeException("产品库存不存在");
        }else {
            stockUninventoryMapper.updateSubtractStockUnInventory(stockUninventoryDto);
            int affectRows = stockUninventoryMapper.updateSubtractStockUnInventory(stockUninventoryDto);
            if (affectRows <= 0) {
                throw new RuntimeException("库存不足无法出库");
            }
        }
        return 1;
    }