diff --git a/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java b/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java index 041e586..ce76699 100644 --- a/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java +++ b/stockMate/src/main/java/com/stockm8/controller/ReceivingController.java @@ -258,7 +258,7 @@ public Map scanPOST(@RequestBody Map payload, } try { - rService.ReceivingStatusToComplete(businessId, barcode, receivingShipmentNo); + rService.ReceivingStatusToComplete(businessId, barcode, receivingShipmentNo, orderItemId); int remainingStock = rService.increseStockByBarcode(businessId, barcode, receivingShipmentNo, orderItemId); int reservedQuantity = rService.decreaseReservedQuantity(businessId, barcode, receivingShipmentNo, orderItemId); ProductVO product = rService.productNameBarcode(businessId, barcode, receivingShipmentNo); diff --git a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java index dfe9788..231c7cf 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAO.java @@ -49,7 +49,7 @@ public interface ReceivingDAO { public ProductVO selectProductNameBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception; // 수량 없을시 완료상태로 변경 - public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) throws Exception; + public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo, int orderItemId) throws Exception; // 입출고 번호를 누를시 스캔으로가서 특정 리스트 보여주기 public List selectReceivingShipmentNo(int businessId, Integer receivingShipmentNo, int orderItemId) throws Exception; diff --git a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java index 72d8215..3b2458d 100644 --- a/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java +++ b/stockMate/src/main/java/com/stockm8/persistence/ReceivingDAOImpl.java @@ -161,12 +161,13 @@ public ProductVO selectProductNameBarcode(int businessId, String barcode, Intege } @Override - public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) throws Exception { + public void updateReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo, int orderItemId) throws Exception { logger.info("updateReceivingStatusToComplete() 호출"); Map params = new HashMap<>(); params.put("businessId", businessId); params.put("barcode", barcode); params.put("receivingShipmentNo", receivingShipmentNo); + params.put("orderItemId", orderItemId); sqlSession.update(NAMESPACE + "updateReceivingStatusToComplete", params); } diff --git a/stockMate/src/main/java/com/stockm8/service/ReceivingService.java b/stockMate/src/main/java/com/stockm8/service/ReceivingService.java index 8a0ce75..47a692f 100644 --- a/stockMate/src/main/java/com/stockm8/service/ReceivingService.java +++ b/stockMate/src/main/java/com/stockm8/service/ReceivingService.java @@ -47,7 +47,7 @@ public interface ReceivingService { public ProductVO productNameBarcode(int businessId, String barcode, Integer receivingShipmentNo) throws Exception; // 수량 없을시 완료상태로 변경 - public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) throws Exception; + public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo, int orderItemId) throws Exception; // 입출고 번호를 누를시 스캔으로가서 특정 리스트 보여주기 public List getReceivingShipmentNo(int businessId, Integer receivingShipmentNo, int rderItemId) throws Exception; diff --git a/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java b/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java index 1ec1560..a9ab0c8 100644 --- a/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java +++ b/stockMate/src/main/java/com/stockm8/service/ReceivingServiceImpl.java @@ -122,10 +122,10 @@ public ProductVO productNameBarcode(int businessId, String barcode, Integer rece } @Override - public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo) { + public void ReceivingStatusToComplete(int businessId, String barcode, Integer receivingShipmentNo, int orderItemId) { try { // MyBatis 매퍼 호출 - rdao.updateReceivingStatusToComplete(businessId, barcode, receivingShipmentNo); + rdao.updateReceivingStatusToComplete(businessId, barcode, receivingShipmentNo, orderItemId); // opService.processInboundAfterInspection(orderId, completedItems); } catch (Exception e) { // 예외 처리 diff --git a/stockMate/src/main/resources/mappers/OrderMapper.xml b/stockMate/src/main/resources/mappers/OrderMapper.xml index b4caf7e..19db36f 100644 --- a/stockMate/src/main/resources/mappers/OrderMapper.xml +++ b/stockMate/src/main/resources/mappers/OrderMapper.xml @@ -120,7 +120,7 @@ #{productId}, #{warehouseId}, #{quantity}, - #{quantity} + #{quantity}, #{unitPrice}, #{remarks}, NOW() diff --git a/stockMate/src/main/resources/mappers/receivingMapper.xml b/stockMate/src/main/resources/mappers/receivingMapper.xml index d2bc114..daa8e6c 100644 --- a/stockMate/src/main/resources/mappers/receivingMapper.xml +++ b/stockMate/src/main/resources/mappers/receivingMapper.xml @@ -238,7 +238,6 @@ WHERE r.transaction_type = 'INBOUND' JOIN stocks s on o.product_id = s.product_id JOIN receiving_shipment r on r.stock_id = s.stock_id AND r.order_item_id = o.order_item_id SET s.total_quantity = s.total_quantity + 1, - s.reserved_quantity = s.reserved_quantity -1, o.change_quantity = o.change_quantity -1 WHERE p.product_barcode = #{barcode} AND s.business_id = #{businessId} @@ -288,12 +287,15 @@ AND r.order_item_id = #{orderItemId} JOIN products p ON r.product_id = p.product_id JOIN stocks s ON s.product_id = p.product_id JOIN order_items o ON s.product_id = o.product_id - SET r.status = 'COMPLETED' + SET r.status = 'COMPLETED', + s.reserved_quantity = s.reserved_quantity - o.quantity WHERE p.product_barcode = #{barcode} AND o.change_quantity = 0 AND r.status = 'PENDING' AND s.business_id = #{businessId} AND r.receiving_shipment_no = #{receivingShipmentNo} + AND r.order_item_id = #{orderItemId} + AND o.order_item_id = r.order_item_id;