@Override public List<SkuStockInMemVo> getStocksBySkuIdList(List<Long> skuIdList) { if (skuIdList == null || skuIdList.size() <= 0) { logger.error("skuIdList is null or no elements"); return null; } List<SkuStockInMemVo> skuStockInMemVoList = new ArrayList<SkuStockInMemVo>(); for (Long skuId : skuIdList) { ResponseResult<Integer> result = dataStore.getValueByKeyAndField(CartConstant.SKU_STOCK_NAMESPACE, String.valueOf(skuId)); if (result.getCode() == CodeInfoClass.COMMON_FAIL || result.getCode() == CodeInfoClass.NOT_EXIST) { logger.error( "system err or no stockCount found in mem,skuId:" + skuId + ",code:" + result.getCode()); continue; } SkuStockInMemVo vo = new SkuStockInMemVo(); vo.setSkuId(skuId); vo.setStockCount(result.getResult()); skuStockInMemVoList.add(vo); } return skuStockInMemVoList; }
@Override public ResponseResult<Integer> getStockBySkuId(Long skuId) { if (skuId == null) { logger.error("skuId is null"); return ResponseUtil.generateError("skuId is null"); } ResponseResult<Integer> result = dataStore.getValueByKeyAndField(CartConstant.SKU_STOCK_NAMESPACE, String.valueOf(skuId)); return result; }