diff --git a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenDailyMenuServiceImpl.java b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenDailyMenuServiceImpl.java index b631fb63a..5bb27b35d 100644 --- a/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenDailyMenuServiceImpl.java +++ b/pjcloud-canteen/pjcloud-canteen-biz/src/main/java/com/bsd/pjcloud/canteen/service/impl/CanteenDailyMenuServiceImpl.java @@ -55,7 +55,7 @@ public class CanteenDailyMenuServiceImpl extends ServiceImpl selectTimeFood(String time, Long merchantId, Long categoryId) { List dailyMenuAllES = new ArrayList<>(); - List dailyMenuVOS = baseMapper.selectTimeFood(time, merchantId, categoryId, DataScope.of()); + List dailyMenuVOS = baseMapper.selectTimeFood(time, merchantId, categoryId, DataScope.of().only(true)); Map> collect = dailyMenuVOS.stream().collect(Collectors.groupingBy(DailyMenuVO::getHourType)); collect.keySet().forEach(x -> { DailyMenuAll dailyMenuAll = new DailyMenuAll(); @@ -138,8 +138,8 @@ public class CanteenDailyMenuServiceImpl extends ServiceImpl getCanteenMenuListScope(String day, Integer hourType, Long categoryId, Long merchantId) { - return baseMapper.getCanteenMenuList(day, hourType, categoryId,merchantId, DataScope.of()); + public List getCanteenMenuListScope(String day, Integer hourType, Long categoryId, Long merchantId) { + return baseMapper.getCanteenMenuList(day, hourType, categoryId, merchantId, DataScope.of()); } @Override @@ -195,6 +195,7 @@ public class CanteenDailyMenuServiceImpl extends ServiceImpl wrapper) { return baseMapper.selectListByScope(wrapper, DataScope.of()); @@ -59,11 +60,11 @@ public class CanteenSpuServiceImpl extends ServiceImpl spu.getStock()) { - R.failed(spu.getName()+"库存不足,无法完成操作"); + R.failed(spu.getName() + "库存不足,无法完成操作"); } int i = baseMapper.updateStock(item.getId(), item.getIncrCount()); // if (item.getIncrCount() <= 0) { @@ -89,7 +90,7 @@ public class CanteenSpuServiceImpl extends ServiceImpl> listMap = canteenCategoryEntities.stream().collect(Collectors.groupingBy(CanteenCategoryEntity::getId)); bean.forEach(item -> { - if (null!=listMap.get(item.getCategoryId()).get(0).getCategoryType()){ + if (null != listMap.get(item.getCategoryId()).get(0).getCategoryType()) { item.setCategoryType(listMap.get(item.getCategoryId()).get(0).getCategoryType()); } }); @@ -127,11 +128,11 @@ public class CanteenSpuServiceImpl extends ServiceImpl canteenCategoryEntityLambdaQueryWrapper = new LambdaQueryWrapper<>(); canteenCategoryEntityLambdaQueryWrapper.like(CanteenCategoryEntity::getCategoryType, canteenDailySpuDTO.getHourType()); List canteenCategoryEntities = canteenCategoryMapper.selectList(canteenCategoryEntityLambdaQueryWrapper); - List caIds = canteenCategoryEntities.stream().map(CanteenCategoryEntity::getId).collect(Collectors.toList()); + List caIds = canteenCategoryEntities.stream().map(CanteenCategoryEntity::getId).collect(Collectors.toList()); wrapper.in(!CollectionUtils.isEmpty(caIds), CanteenSpuEntity::getCategoryId, caIds); // wrapper.orderByAsc(CanteenSpuEntity::getSort); - return baseMapper.selectPageByScope(page, wrapper, DataScope.of()); + return baseMapper.selectPageByScope(page, wrapper, DataScope.of().only(true)); } @@ -164,32 +165,32 @@ public class CanteenSpuServiceImpl extends ServiceImpl pageData = baseMapper.selectPageByScope(page, wrapper, DataScope.of()); List records = pageData.getRecords(); - + // 构建返回的VO列表 List resultList = new ArrayList<>(); - + if (!CollectionUtils.isEmpty(records)) { // 获取所有SPU ID List spuIds = records.stream() .map(CanteenSpuEntity::getId) .collect(Collectors.toList()); - + // 查询对应的库存信息 LambdaQueryWrapper stockWrapper = Wrappers.lambdaQuery(); stockWrapper.in(CanteenStockEntity::getItemId, spuIds); stockWrapper.eq(CanteenStockEntity::getItemType, "2"); // 假设"成品"表示菜品的类型 List stockList = canteenStockMapper.selectList(stockWrapper); - + // 将库存信息映射到SPU ID Map stockMap = stockList.stream() .collect(Collectors.toMap(CanteenStockEntity::getItemId, stock -> stock, (v1, v2) -> v1)); - + // 构建返回结果 for (CanteenSpuEntity spu : records) { CanteenSpuStockVO vo = new CanteenSpuStockVO(); vo.setName(spu.getName()); vo.setPicUrl(spu.getPicUrl()); - + // 设置库存信息 CanteenStockEntity stock = stockMap.get(spu.getId()); if (stock != null) { @@ -205,11 +206,11 @@ public class CanteenSpuServiceImpl extends ServiceImpl resultPage = new Page<>(); resultPage.setRecords(resultList); @@ -217,7 +218,7 @@ public class CanteenSpuServiceImpl extends ServiceImpl