|
|
@@ -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("库存不足");
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
|