Просмотр исходного кода

库存临时修改,不同步erp的库存

xgb 6 дней назад
Родитель
Сommit
ee689e49ad

+ 20 - 2
fs-company/src/main/java/com/fs/company/controller/common/CommonController.java

@@ -172,12 +172,16 @@ public class CommonController
 //    }
 
     @GetMapping("common/test")
-    public R test(String id,String barcode) throws Exception
+    public R test(String barcode) throws Exception
     {
 
+        ErpGoodsStockQueryRequert queryRequert = new ErpGoodsStockQueryRequert();
+        queryRequert.setBarcode(barcode);
 
-        orderService.getErpOrderDeliverySendTime(Long.parseLong(id),barcode);
+        ErpGoodsStockQueryResponse response =     wdtTwoErpGoodsService.getGoodsStock(queryRequert);
 
+
+        log.info("查询结果:{}",response);
         return R.ok();
     }
 
@@ -185,6 +189,20 @@ public class CommonController
 
 
 
+//    @GetMapping("common/test")
+//    public R test(String id,String barcode) throws Exception
+//    {
+//
+//
+//        orderService.getErpOrderDeliverySendTime(Long.parseLong(id),barcode);
+//
+//        return R.ok();
+//    }
+
+
+
+
+
     public static void main(String[] args) {
         // 时间差转换时间
         String time="1769931653000";

+ 80 - 77
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCartScrmServiceImpl.java

@@ -231,83 +231,86 @@ public class FsStoreCartScrmServiceImpl implements IFsStoreCartScrmService
 
     @Override
     public void checkProductStock(Long productId, Long productAttrValueId) {
-        IErpGoodsService goodsService = getErpService();
-        if(goodsService != null){
-            log.info("检查库存 {} {}",productId,productAttrValueId);
-            FsStoreProductAttrValueScrm productAttrValue=valueMapper.selectFsStoreProductAttrValueById(productAttrValueId);
-            if(StringUtils.isEmpty(productAttrValue.getGroupBarCode())){
-                //单品
-                ErpGoodsStockQueryRequert queryRequert = new ErpGoodsStockQueryRequert();
-                queryRequert.setBarcode(productAttrValue.getBarCode());
-                ErpGoodsStockQueryResponse goodsStock = goodsService.getGoodsStock(queryRequert);
-                if(goodsStock != null && goodsStock.getStocks() != null && !goodsStock.getStocks().isEmpty()){
-
-                    int stocks = Double.valueOf(goodsStock.getStocks().get(0).getSalable_qty()).intValue();
-
-                    if(stocks<=0){
-                        productAttrValue.setStock(0);
-                        valueMapper.updateFsStoreProductAttrValue(productAttrValue);
-                        fsStoreProductMapper.updateStock(productId);
-                        throw new CustomException("库存不足");
-                    }
-                    else{
-                        //更新库存
-                        productAttrValue.setStock(stocks);
-                        valueMapper.updateFsStoreProductAttrValue(productAttrValue);
-                        fsStoreProductMapper.updateStock(productId);
-                        return;
-                    }
-
-                }
-                else{
-                    throw new CustomException("未获取到库存");
-                }
-
-            }
-            else{
-                //组合码
-                FsStoreProductGroupScrm group=productGroupMapper.selectFsStoreProductGroupByBarCode(productAttrValue.getGroupBarCode());
-                if(group!=null){
-                    Integer totalStock=0;
-                    JSONArray jsonArray= JSONUtil.parseArray(group.getProducts());
-                    List<StoreProductGroupDTO> productGroupDTOS=JSONUtil.toList(jsonArray, StoreProductGroupDTO.class);
-                    if(productGroupDTOS!=null){
-                        for(StoreProductGroupDTO dto:productGroupDTOS){
-                            FsStoreProductAttrValueScrm attrValue=valueMapper.selectFsStoreProductAttrValueById(dto.getId());
-                            ErpGoodsStockQueryRequert queryRequert = new ErpGoodsStockQueryRequert();
-                            queryRequert.setBarcode(attrValue.getGroupBarCode());
-                            ErpGoodsStockQueryResponse goodsStock = goodsService.getGoodsStock(queryRequert);
-                            if(goodsStock != null && goodsStock.getStocks() != null && !goodsStock.getStocks().isEmpty()){
-                                int stocks = Integer.valueOf(goodsStock.getStocks().get(0).getSalable_qty());
-
-
-                                if(stocks<=0){
-                                    attrValue.setStock(0);
-                                    valueMapper.updateFsStoreProductAttrValue(attrValue);
-                                    fsStoreProductMapper.updateStock(productId);
-                                    throw new CustomException("库存不足");
-                                }
-                                else{
-                                    //更新库存
-                                    attrValue.setStock(stocks);
-                                    valueMapper.updateFsStoreProductAttrValue(attrValue);
-                                    fsStoreProductMapper.updateStock(productId);
-                                }
-                                totalStock+=stocks;
-                            }
-                        }
-                    }
-                    productAttrValue.setStock(totalStock);
-                    valueMapper.updateFsStoreProductAttrValue(productAttrValue);
-                    fsStoreProductMapper.updateStock(productId);
-                }
-
-            }
-        }
-        int stock=valueMapper.selectFsStoreProductStockById(productAttrValueId);
-        if (stock < 1) {
-            throw new CustomException("库存不足");
-        }
+//        IErpGoodsService goodsService = getErpService();
+//        if(goodsService != null){
+//            log.info("检查库存 {} {}",productId,productAttrValueId);
+//            FsStoreProductAttrValueScrm productAttrValue=valueMapper.selectFsStoreProductAttrValueById(productAttrValueId);
+//            if(StringUtils.isEmpty(productAttrValue.getGroupBarCode())){
+
+                // todo 库存暂时不获取
+//                //单品
+//                ErpGoodsStockQueryRequert queryRequert = new ErpGoodsStockQueryRequert();
+//                queryRequert.setBarcode(productAttrValue.getBarCode());
+//                ErpGoodsStockQueryResponse goodsStock = goodsService.getGoodsStock(queryRequert);
+//                if(goodsStock != null && goodsStock.getStocks() != null && !goodsStock.getStocks().isEmpty()){
+//
+//                    int stocks = Double.valueOf(goodsStock.getStocks().get(0).getSalable_qty()).intValue();
+//
+//                    if(stocks<=0){
+//                        productAttrValue.setStock(0);
+//                        valueMapper.updateFsStoreProductAttrValue(productAttrValue);
+//                        fsStoreProductMapper.updateStock(productId);
+//                        throw new CustomException("库存不足");
+//                    }
+//                    else{
+//                        //更新库存
+//                        productAttrValue.setStock(stocks);
+//                        valueMapper.updateFsStoreProductAttrValue(productAttrValue);
+//                        fsStoreProductMapper.updateStock(productId);
+//                        return;
+//                    }
+//
+//                }
+//                else{
+//                    throw new CustomException("未获取到库存");
+//                }
+//
+//            }
+//            else{
+//                //组合码
+//                FsStoreProductGroupScrm group=productGroupMapper.selectFsStoreProductGroupByBarCode(productAttrValue.getGroupBarCode());
+//                if(group!=null){
+//                    Integer totalStock=0;
+//                    JSONArray jsonArray= JSONUtil.parseArray(group.getProducts());
+//                    List<StoreProductGroupDTO> productGroupDTOS=JSONUtil.toList(jsonArray, StoreProductGroupDTO.class);
+//                    if(productGroupDTOS!=null){
+//                        for(StoreProductGroupDTO dto:productGroupDTOS){
+                            // todo
+//                            FsStoreProductAttrValueScrm attrValue=valueMapper.selectFsStoreProductAttrValueById(dto.getId());
+//                            ErpGoodsStockQueryRequert queryRequert = new ErpGoodsStockQueryRequert();
+//                            queryRequert.setBarcode(attrValue.getGroupBarCode());
+//                            ErpGoodsStockQueryResponse goodsStock = goodsService.getGoodsStock(queryRequert);
+//                            if(goodsStock != null && goodsStock.getStocks() != null && !goodsStock.getStocks().isEmpty()){
+//                                int stocks = Integer.valueOf(goodsStock.getStocks().get(0).getSalable_qty());
+//
+//
+//                                if(stocks<=0){
+//                                    attrValue.setStock(0);
+//                                    valueMapper.updateFsStoreProductAttrValue(attrValue);
+//                                    fsStoreProductMapper.updateStock(productId);
+//                                    throw new CustomException("库存不足");
+//                                }
+//                                else{
+//                                    //更新库存
+//                                    attrValue.setStock(stocks);
+//                                    valueMapper.updateFsStoreProductAttrValue(attrValue);
+//                                    fsStoreProductMapper.updateStock(productId);
+//                                }
+//                                totalStock+=stocks;
+//                            }
+//                        }
+//                    }
+//                    productAttrValue.setStock(totalStock);
+//                    valueMapper.updateFsStoreProductAttrValue(productAttrValue);
+//                    fsStoreProductMapper.updateStock(productId);
+//                }
+//
+//            }
+//        }
+//        int stock=valueMapper.selectFsStoreProductStockById(productAttrValueId);
+//        if (stock < 1) {
+//            throw new CustomException("库存不足");
+//        }
     }