From 08afeadee3b2a73266a0a43c899f86cd474a274d Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 01 Aug 2022 15:32:48 +0800
Subject: [PATCH] 加工产品新增销售、库存损耗功能

---
 src/main/java/org/springblade/modules/InventoryLoss/controller/InventoryController.java |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/main/java/org/springblade/modules/InventoryLoss/controller/InventoryController.java b/src/main/java/org/springblade/modules/InventoryLoss/controller/InventoryController.java
index 57ca548..c1d0851 100644
--- a/src/main/java/org/springblade/modules/InventoryLoss/controller/InventoryController.java
+++ b/src/main/java/org/springblade/modules/InventoryLoss/controller/InventoryController.java
@@ -32,6 +32,7 @@
 import org.springblade.modules.InventoryLoss.entity.Inventory;
 import org.springblade.modules.InventoryLoss.service.InventoryService;
 import org.springblade.modules.InventoryLoss.vo.InventoryVO;
+import org.springblade.modules.process.service.IProcessService;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
@@ -50,6 +51,7 @@
 
 	private final InventoryService inventoryService;
 	private final FarmProductStockService farmProductStockService;
+	private final IProcessService processService;
 
 	/**
 	 * 详情
@@ -121,6 +123,22 @@
 		return R.status(inventoryService.saveOrUpdate(inventory));
 	}
 
+	/**
+	 * 新增或修改 库存损耗记录表
+	 */
+	@PostMapping("/submitProcess")
+	@ApiOperationSupport(order = 8)
+	@ApiOperation(value = "新增或修改", notes = "传入sale")
+	public R submitProcess(@Valid @RequestBody InventoryVO inventory) {
+		boolean res = processService.stockCompare(inventory.getSaleNum(),inventory.getProid());
+		if (!res){
+			throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!"));
+		}else {
+			//库存充足,减去相应库存
+			processService.stockReduce(inventory.getSaleNum(),inventory.getProid());
+		}
+		return R.status(inventoryService.saveOrUpdate(inventory));
+	}
 
 	/**
 	 * 删除 库存损耗记录表

--
Gitblit v1.9.3