| | |
| | | @PostMapping("/submit") |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入sale") |
| | | public R submit(@Valid @RequestBody Inventory inventory) { |
| | | boolean res = farmProductStockService.stockCompare(inventory.getSaleNum(),inventory.getStrainId()); |
| | | public R submit(@Valid @RequestBody InventoryVO inventory) { |
| | | boolean res = farmProductStockService.stockCompare(inventory.getSaleNum(),inventory.getProid()); |
| | | if (!res){ |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | }else { |
| | | //库存充足,减去相应库存 |
| | | farmProductStockService.stockReduce(inventory.getSaleNum(),inventory.getStrainId()); |
| | | farmProductStockService.stockReduce(inventory.getSaleNum(),inventory.getProid()); |
| | | } |
| | | return R.status(inventoryService.saveOrUpdate(inventory)); |
| | | } |
| | |
| | | @EqualsAndHashCode(callSuper = true) |
| | | public class InventoryVO extends Inventory { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 库存量主键id |
| | | */ |
| | | private String proid; |
| | | } |
| | |
| | | @ApiOperationSupport(order = 6) |
| | | @ApiOperation(value = "新增或修改", notes = "传入sale") |
| | | public R submit(@Valid @RequestBody SaleVO sale) { |
| | | boolean res = farmProductStockService.stockCompare(sale.getSaleNum(),sale.getStrainId()); |
| | | boolean res = farmProductStockService.stockCompare(sale.getSaleNum(),sale.getProid()); |
| | | if (!res){ |
| | | throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!")); |
| | | }else { |
| | | //库存充足,减去相应库存 |
| | | farmProductStockService.stockReduce(sale.getSaleNum(),sale.getStrainId()); |
| | | farmProductStockService.stockReduce(sale.getSaleNum(),sale.getProid()); |
| | | } |
| | | return R.status(saleService.saveOrUpdate(sale)); |
| | | } |