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/sale/controller/SaleController.java | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/main/java/org/springblade/modules/sale/controller/SaleController.java b/src/main/java/org/springblade/modules/sale/controller/SaleController.java
index 5e296bf..3884491 100644
--- a/src/main/java/org/springblade/modules/sale/controller/SaleController.java
+++ b/src/main/java/org/springblade/modules/sale/controller/SaleController.java
@@ -30,6 +30,7 @@
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.farmplant.service.FarmProductStockService;
+import org.springblade.modules.process.service.IProcessService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -52,6 +53,7 @@
private final ISaleService saleService;
private final FarmProductStockService farmProductStockService;
+ private final IProcessService processService;
/**
* 详情
@@ -123,6 +125,23 @@
return R.status(saleService.saveOrUpdate(sale));
}
+ /**
+ * 新增或修改 销售记录表(加工产品)
+ */
+ @PostMapping("/submitProcess")
+ @ApiOperationSupport(order = 8)
+ @ApiOperation(value = "新增或修改", notes = "传入sale")
+ public R submitProcess(@Valid @RequestBody SaleVO sale) {
+ //对比加工表库存量
+ boolean res = processService.stockCompare(sale.getSaleNum(),sale.getProid());
+ if (!res){
+ throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!"));
+ }else {
+ //库存充足,减去相应库存
+ processService.stockReduce(sale.getSaleNum(),sale.getProid());
+ }
+ return R.status(saleService.saveOrUpdate(sale));
+ }
/**
* 删除 销售记录表
--
Gitblit v1.9.3