This commit is contained in:
dzc committed 2026-05-13 15:50:51 +08:00
1 parent a13adfba87
commit 69e3084e45
2 files changed
+19 -17

No files matched your search

@@ -55,7 +55,7 @@ public class CanteenDailyMenuServiceImpl extends ServiceImpl<CanteenDailyMenuMap
@Override
public List<DailyMenuAll> selectTimeFood(String time, Long merchantId, Long categoryId) {
List<DailyMenuAll> dailyMenuAllES = new ArrayList<>();
List<DailyMenuVO> dailyMenuVOS = baseMapper.selectTimeFood(time, merchantId, categoryId, DataScope.of());
List<DailyMenuVO> dailyMenuVOS = baseMapper.selectTimeFood(time, merchantId, categoryId, DataScope.of().only(true));
Map<Integer, List<DailyMenuVO>> 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<CanteenDailyMenuMap
}
@Override
public List<ADCanteenDailyMenuListVO> getCanteenMenuListScope(String day, Integer hourType, Long categoryId, Long merchantId) {
return baseMapper.getCanteenMenuList(day, hourType, categoryId,merchantId, DataScope.of());
public List<ADCanteenDailyMenuListVO> 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<CanteenDailyMenuMap
}
return R.ok();
}
// 发送mq消息
private void sendMqttMsg(Long mchId) {
if (ObjectUtil.isEmpty(mchId)) return;
@@ -46,6 +46,7 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
private final CanteenCategoryMapper canteenCategoryMapper;
private final CanteenStockMapper canteenStockMapper;
private final CanteenOnlineSpuMapper canteenOnlineSpuMapper;
@Override
public Object selectFoodList(LambdaQueryWrapper<CanteenSpuEntity> wrapper) {
return baseMapper.selectListByScope(wrapper, DataScope.of());
@@ -59,11 +60,11 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
// 查询当前库存
CanteenSpuEntity spu = baseMapper.selectById(item.getId());
if (spu == null) {
R.failed(spu.getName()+"商品不存在");
R.failed(spu.getName() + "商品不存在");
}
// 检查库存是否足够
if (item.getIncrCount() < 0 && Math.abs(item.getIncrCount()) > 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<CanteenSpuMapper, Canteen
Map<Long, List<CanteenCategoryEntity>> 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<CanteenSpuMapper, Canteen
LambdaQueryWrapper<CanteenCategoryEntity> canteenCategoryEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
canteenCategoryEntityLambdaQueryWrapper.like(CanteenCategoryEntity::getCategoryType, canteenDailySpuDTO.getHourType());
List<CanteenCategoryEntity> canteenCategoryEntities = canteenCategoryMapper.selectList(canteenCategoryEntityLambdaQueryWrapper);
List<Long> caIds = canteenCategoryEntities.stream().map(CanteenCategoryEntity::getId).collect(Collectors.toList());
List<Long> 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<CanteenSpuMapper, Canteen
// 查询SPU分页数据
Page<CanteenSpuEntity> pageData = baseMapper.selectPageByScope(page, wrapper, DataScope.of());
List<CanteenSpuEntity> records = pageData.getRecords();
// 构建返回的VO列表
List<CanteenSpuStockVO> resultList = new ArrayList<>();
if (!CollectionUtils.isEmpty(records)) {
// 获取所有SPU ID
List<Long> spuIds = records.stream()
.map(CanteenSpuEntity::getId)
.collect(Collectors.toList());
// 查询对应的库存信息
LambdaQueryWrapper<CanteenStockEntity> stockWrapper = Wrappers.lambdaQuery();
stockWrapper.in(CanteenStockEntity::getItemId, spuIds);
stockWrapper.eq(CanteenStockEntity::getItemType, "2"); // 假设"成品"表示菜品的类型
List<CanteenStockEntity> stockList = canteenStockMapper.selectList(stockWrapper);
// 将库存信息映射到SPU ID
Map<Long, CanteenStockEntity> 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<CanteenSpuMapper, Canteen
vo.setInventoryUpperLimit(0);
vo.setInventoryLowerLimit(0);
}
resultList.add(vo);
}
}
// 构建分页返回对象
Page<CanteenSpuStockVO> resultPage = new Page<>();
resultPage.setRecords(resultList);
@@ -217,7 +218,7 @@ public class CanteenSpuServiceImpl extends ServiceImpl<CanteenSpuMapper, Canteen
resultPage.setSize(pageData.getSize());
resultPage.setCurrent(pageData.getCurrent());
resultPage.setPages(pageData.getPages());
return resultPage;
}