wangxiaoming vor 5 Jahren
Ursprung
Commit
2fc9b852fd

+ 42 - 5
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/InventoryServiceImpl.java

@@ -6,13 +6,16 @@ import com.iamberry.rst.core.cm.SalesOrderItem;
 import com.iamberry.rst.core.fm.InventoryInfo;
 import com.iamberry.rst.core.fm.InventoryLog;
 import com.iamberry.rst.core.order.OrderWarehouse;
+import com.iamberry.rst.core.order.ProductColor;
 import com.iamberry.rst.core.page.PageRequest;
 import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.faces.cm.InventoryService;
 import com.iamberry.rst.service.fm.mapper.InventoryLogMapper;
 import com.iamberry.rst.service.fm.mapper.InventoryMapper;
 import com.iamberry.rst.service.order.mapper.OrderWarehouseMapper;
+import com.iamberry.rst.service.product.mapper.ProductColorMapper;
 import com.iamberry.rst.util.PageUtil;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -35,6 +38,8 @@ public class InventoryServiceImpl implements InventoryService {
     private InventoryLogMapper inventoryLogMapper;
     @Autowired
     private OrderWarehouseMapper orderWarehouseMapper;
+    @Autowired
+    private ProductColorMapper productColorMapper;
 
     @Override
     public InventoryInfo getByInventoryId(Integer inventoryId) {
@@ -68,12 +73,28 @@ public class InventoryServiceImpl implements InventoryService {
     @Override
     public Integer addInventory(InventoryInfo invent) {
         Integer flag = 0;
-        if(invent.getInventoryProductBar() == null || invent.getWarehouseId() == null){
-            throw new RuntimeException("【入库】更新库存失败,入库需要产品SKU与仓库ID。");
+        if(invent.getWarehouseId() == null){
+            throw new RuntimeException("【出库】更新库存失败,出库仓库ID。");
+        }
+        if(invent.getInventoryProductBar() == null && invent.getInventoryProductColorId() == null){
+            throw new RuntimeException("【出库】更新库存失败,出库需要产品SKU或颜色ID。");
+        }else{
+            ProductColor productColor = null;
+            if(!StringUtils.isEmpty(invent.getInventoryProductBar())){
+                productColor = productColorMapper.getProductColorByBar(invent.getInventoryProductBar());
+            }else{
+                productColor = productColorMapper.getProductColorById(invent.getInventoryProductColorId());
+            }
+            if(productColor != null){
+                invent.setInventoryProductBar(productColor.getColorBar());
+            }else{
+                throw new RuntimeException("【出库】更新库存失败,产品SKU或颜色ID出错。");
+            }
         }
+
         OrderWarehouse orderWarehouse = orderWarehouseMapper.getOrderWarehouseById(invent.getWarehouseId());
         if(orderWarehouse == null){
-            throw new RuntimeException("【入库】更新库存失败,查询仓库信息失败。");
+            throw new RuntimeException("【库】更新库存失败,查询仓库信息失败。");
         }
         String warehouseName = orderWarehouse.getWarehouseName();
         InventoryInfo info = inventoryMapper.getByInventoryByBar(invent.getInventoryProductBar(),invent.getWarehouseId());
@@ -142,9 +163,25 @@ public class InventoryServiceImpl implements InventoryService {
     @Override
     public Integer minusInventory(InventoryInfo invent) {
         Integer flag = 0;
-        if(invent.getInventoryProductBar() == null || invent.getWarehouseId() == null){
-            throw new RuntimeException("【出库】更新库存失败,出库需要产品SKU与仓库ID。");
+        if(invent.getWarehouseId() == null){
+            throw new RuntimeException("【出库】更新库存失败,出库仓库ID。");
+        }
+        if(invent.getInventoryProductBar() == null && invent.getInventoryProductColorId() == null){
+            throw new RuntimeException("【出库】更新库存失败,出库需要产品SKU或颜色ID。");
+        }else{
+            ProductColor productColor = null;
+            if(!StringUtils.isEmpty(invent.getInventoryProductBar())){
+                productColor = productColorMapper.getProductColorByBar(invent.getInventoryProductBar());
+            }else{
+                productColor = productColorMapper.getProductColorById(invent.getInventoryProductColorId());
+            }
+            if(productColor != null){
+                invent.setInventoryProductBar(productColor.getColorBar());
+            }else{
+                throw new RuntimeException("【出库】更新库存失败,产品SKU或颜色ID出错。");
+            }
         }
+
         OrderWarehouse orderWarehouse = orderWarehouseMapper.getOrderWarehouseById(invent.getWarehouseId());
         if(orderWarehouse == null){
             throw new RuntimeException("【出库】更新库存失败,查询仓库信息失败。");

+ 29 - 5
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/ComplaintDetectInfoServiceImpl.java

@@ -10,6 +10,7 @@ import com.iamberry.rst.core.order.OrderWarehouse;
 import com.iamberry.rst.core.page.PageRequest;
 import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.core.sys.Admin;
+import com.iamberry.rst.faces.cm.InventoryService;
 import com.iamberry.rst.faces.cm.SalesOrderService;
 import com.iamberry.rst.faces.fm.ComplaintDetectInfoService;
 import com.iamberry.rst.faces.sms.SmsService;
@@ -47,6 +48,8 @@ public class ComplaintDetectInfoServiceImpl implements ComplaintDetectInfoServic
     private SmsService smsService;
     @Autowired
     private SalesOrderService salesOrderService;
+    @Autowired
+    private InventoryService inventoryService;
 
     @Override
     public ComplaintDetectInfo getDetectById(Integer detectId) {
@@ -178,13 +181,34 @@ public class ComplaintDetectInfoServiceImpl implements ComplaintDetectInfoServic
         //判断是否为维修
         ComplaintDetectInfo cdi = complaintDetectInfoMapper.getDetectById(record.getDetectId());
         if(cdi.getProcTypeId() == 3){    //3: 维修
-//            salesOrderService.updateInventory(salesOrder.getSalesId(),salesOrder.getSalesWarehouseId());    //删除
+            //减去售后仓库不良品
+            InventoryInfo inventoryInfo1 = new InventoryInfo();
+            inventoryInfo1.setInventoryDefectiveProductNum(1);
+            inventoryInfo1.setInventoryProductColorId(cdi.getProductColorId());
+            inventoryInfo1.setWarehouseId(2);
+            inventoryService.minusInventory(inventoryInfo1);
+
+            //增加售后仓库的良品
+            InventoryInfo inventoryInfo2 = new InventoryInfo();
+            inventoryInfo2.setInventoryGoodProductNum(1);
+            inventoryInfo2.setInventoryProductColorId(cdi.getProductColorId());
+            inventoryInfo2.setWarehouseId(2);
+            inventoryService.addInventory(inventoryInfo2);
 
         }else{  //退货等
-
-//            salesOrderService.updateInventory(salesOrder.getSalesId(),2);    //减去不良品
-//            salesOrderService.returnInventory(salesOrder.getSalesId(),1);    //增加销售仓库的良品
-//R
+            //减去售后仓库不良品
+            InventoryInfo inventoryInfo1 = new InventoryInfo();
+            inventoryInfo1.setInventoryDefectiveProductNum(1);
+            inventoryInfo1.setInventoryProductColorId(cdi.getProductColorId());
+            inventoryInfo1.setWarehouseId(2);
+            inventoryService.minusInventory(inventoryInfo1);
+
+            //增加销售仓库的良品
+            InventoryInfo inventoryInfo2 = new InventoryInfo();
+            inventoryInfo2.setInventoryGoodProductNum(1);
+            inventoryInfo2.setInventoryProductColorId(cdi.getProductColorId());
+            inventoryInfo2.setWarehouseId(1);
+            inventoryService.addInventory(inventoryInfo2);
         }
         return flag;
     }

+ 6 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/ProductColorMapper.java

@@ -23,6 +23,12 @@ public interface ProductColorMapper {
      */
     ProductColor  getProductColorById(Integer  id);
     /**
+     * 查询单条数据
+     * @param  bar
+     * @return  productColor
+     */
+    ProductColor  getProductColorByBar(String  bar);
+    /**
      * 增加数据
      * @param  productColor
      * @return Integer

+ 6 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productColorMapper.xml

@@ -62,6 +62,12 @@
         from tb_rst_product_color t
         where t.color_id= #{colorId}
     </select>
+    <select id="getProductColorByBar" resultMap="BaseResultMap" parameterType="String" >
+        select
+        <include refid="Base_List" />
+        from tb_rst_product_color t
+        where t.color_bar= #{colorBar}
+    </select>
     <insert id="save" parameterType="ProductColor" >
         insert into
         tb_rst_product_color