From 0e420d68f407fde240709ac1800da20b0bb99490 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期二, 09 六月 2026 16:06:16 +0800
Subject: [PATCH] feat:反审核操作。可以对已审核的订单进行反审核,反审核的时候可以选择作废还是重新生成一条,并记录反审核描述。选择作废的话则不生成新增订单。选择重新生成的话则跳转到新增台账页面对反审核的销售产品进行编辑保存重新生成一条新增的订单。反审核的订单即使是发货了还是可以反审核,并且需要将对应的入库、出库、发货进行作废。

---
 src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
index 48f3082..be5746d 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -261,24 +261,36 @@
     @Override
     public Boolean frozenStock(StockInventoryDto stockInventoryDto) {
         StockInventory stockInventory = stockInventoryMapper.selectById(stockInventoryDto.getId());
-        if (stockInventory.getQualitity().compareTo(stockInventoryDto.getLockedQuantity()) < 0) {
-            throw new RuntimeException("鍐荤粨鏁伴噺涓嶈兘瓒呰繃搴撳瓨鏁伴噺");
+        if (ObjectUtils.isEmpty(stockInventory)) {
+            throw new ServiceException("搴撳瓨璁板綍涓嶅瓨鍦�");
         }
-        if (ObjectUtils.isEmpty(stockInventory.getLockedQuantity())) {
-            stockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity());
-        } else {
-            stockInventory.setLockedQuantity(stockInventory.getLockedQuantity().add(stockInventoryDto.getLockedQuantity()));
+        if (ObjectUtils.isEmpty(stockInventoryDto.getLockedQuantity()) || stockInventoryDto.getLockedQuantity().compareTo(BigDecimal.ZERO) <= 0) {
+            throw new ServiceException("鍐荤粨鏁伴噺蹇呴』澶т簬0");
         }
+        BigDecimal totalQty = ObjectUtils.isEmpty(stockInventory.getQualitity()) ? BigDecimal.ZERO : stockInventory.getQualitity();
+        BigDecimal currentLockedQty = ObjectUtils.isEmpty(stockInventory.getLockedQuantity()) ? BigDecimal.ZERO : stockInventory.getLockedQuantity();
+        BigDecimal availableQty = totalQty.subtract(currentLockedQty);
+        if (stockInventoryDto.getLockedQuantity().compareTo(availableQty) > 0) {
+            throw new ServiceException("鍐荤粨鏁伴噺涓嶈兘瓒呰繃鍙喕缁撳簱瀛樻暟閲�");
+        }
+        stockInventory.setLockedQuantity(currentLockedQty.add(stockInventoryDto.getLockedQuantity()));
         return this.updateById(stockInventory);
     }
 
     @Override
     public Boolean thawStock(StockInventoryDto stockInventoryDto) {
         StockInventory stockInventory = stockInventoryMapper.selectById(stockInventoryDto.getId());
-        if (stockInventory.getLockedQuantity().compareTo(stockInventoryDto.getLockedQuantity()) < 0) {
-            throw new RuntimeException("瑙e喕鏁伴噺涓嶈兘瓒呰繃鍐荤粨鏁伴噺");
+        if (ObjectUtils.isEmpty(stockInventory)) {
+            throw new ServiceException("搴撳瓨璁板綍涓嶅瓨鍦�");
         }
-        stockInventory.setLockedQuantity(stockInventory.getLockedQuantity().subtract(stockInventoryDto.getLockedQuantity()));
+        if (ObjectUtils.isEmpty(stockInventoryDto.getLockedQuantity()) || stockInventoryDto.getLockedQuantity().compareTo(BigDecimal.ZERO) <= 0) {
+            throw new ServiceException("瑙e喕鏁伴噺蹇呴』澶т簬0");
+        }
+        BigDecimal currentLockedQty = ObjectUtils.isEmpty(stockInventory.getLockedQuantity()) ? BigDecimal.ZERO : stockInventory.getLockedQuantity();
+        if (currentLockedQty.compareTo(stockInventoryDto.getLockedQuantity()) < 0) {
+            throw new ServiceException("瑙e喕鏁伴噺涓嶈兘瓒呰繃鍐荤粨鏁伴噺");
+        }
+        stockInventory.setLockedQuantity(currentLockedQty.subtract(stockInventoryDto.getLockedQuantity()));
         return this.updateById(stockInventory);
     }
 

--
Gitblit v1.9.3