فهرست منبع

Revert "酒单列表修改"

This reverts commit 6840a8eebf92b5c564c7381022a6fbe2858fa59c.
zhangchen 1 هفته پیش
والد
کامیت
277325a49e

+ 7 - 15
alien-store/src/main/java/shop/alien/store/controller/StoreMenuController.java

@@ -10,7 +10,6 @@ import shop.alien.entity.store.vo.StoreMenuVo;
 import shop.alien.store.service.StoreMenuService;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * 二期-门店菜单Controller
@@ -128,18 +127,13 @@ public class StoreMenuController {
      * 获取菜单(用户端)
      * <p>
      * 根据门店ID获取菜单列表,支持按菜品类型、菜单类型筛选,并可查询用户点赞状态
-     * 返回菜单列表以及按四种组合统计的数量:
-     * 1. menu_all: dish_menu_type=1(菜单),dish_type=0(全部)
-     * 2. menu_recommend: dish_menu_type=1(菜单),dish_type=1(推荐)
-     * 3. drink_all: dish_menu_type=2(酒水),dish_type=0(全部)
-     * 4. drink_recommend: dish_menu_type=2(酒水),dish_type=1(推荐)
      * </p>
      *
      * @param storeId      门店ID,必填,必须大于0
      * @param dishType     菜品类型,可选,0:非推荐, 1:推荐
      * @param phoneId      用户手机号,可选,用于查询点赞状态
      * @param dishMenuType 菜单类型,可选,1-菜单,2-酒水
-     * @return 统一返回结果,包含菜单列表和统计信息(list:菜单列表,count:按四种组合统计的数量)
+     * @return 统一返回结果,包含菜单列表
      * @throws IllegalArgumentException 当门店ID为空或小于等于0时抛出
      */
     @ApiOperation("获取菜单(用户端)")
@@ -151,7 +145,7 @@ public class StoreMenuController {
             @ApiImplicitParam(name = "dishMenuType", value = "菜单类型:1-菜单,2-酒水", dataType = "Integer", paramType = "query")
     })
     @GetMapping("/getClientMenuByStoreId")
-    public R<Map<String, Object>> getClientMenuByStoreId(
+    public R<List<StoreMenuVo>> getClientMenuByStoreId(
             @RequestParam(value = "storeId", required = true) Integer storeId,
             @RequestParam(value = "dishType", required = false) Integer dishType,
             @RequestParam(value = "phoneId", required = false) String phoneId,
@@ -167,17 +161,15 @@ public class StoreMenuController {
         }
         
         try {
-            // 调用服务层获取菜单列表和统计信息
-            Map<String, Object> result = storeMenuService.getClientMenuByStoreId(
+            // 调用服务层获取菜单列表
+            List<StoreMenuVo> menuList = storeMenuService.getClientMenuByStoreId(
                     storeId, dishType, phoneId, dishMenuType);
             
             // 记录返回结果
-            @SuppressWarnings("unchecked")
-            List<StoreMenuVo> menuList = (List<StoreMenuVo>) result.get("list");
-            log.info("获取用户端菜单成功,门店ID:{},返回菜单数量:{},统计信息:{}", 
-                    storeId, menuList != null ? menuList.size() : 0, result.get("count"));
+            log.info("获取用户端菜单成功,门店ID:{},返回菜单数量:{}", 
+                    storeId, menuList != null ? menuList.size() : 0);
             
-            return R.data(result);
+            return R.data(menuList);
         } catch (Exception e) {
             log.error("获取用户端菜单异常,门店ID:{},异常信息:{}", storeId, e.getMessage(), e);
             return R.fail("获取菜单失败:" + e.getMessage());

+ 2 - 2
alien-store/src/main/java/shop/alien/store/service/StoreMenuService.java

@@ -92,10 +92,10 @@ public interface StoreMenuService extends IService<StoreMenu> {
      * @param dishType     菜品类型,可选,0:非推荐, 1:推荐。当为0时,查询条件中不包含菜品类型限制
      * @param phoneId      用户手机号,可选,用于查询用户对推荐菜的点赞状态
      * @param dishMenuType 菜单类型,可选,1-菜单,2-酒水
-     * @return Map包含菜单列表和统计信息:list(菜单列表)、count(按四种组合统计:menu_all、menu_recommend、drink_all、drink_recommend)
+     * @return 菜单列表,按排序字段升序排列,如果查询结果为空则返回空列表
      * @throws IllegalArgumentException 当门店ID为空或小于等于0时抛出
      */
-    java.util.Map<String, Object> getClientMenuByStoreId(Integer storeId, Integer dishType, String phoneId, Integer dishMenuType);
+    List<StoreMenuVo> getClientMenuByStoreId(Integer storeId, Integer dishType, String phoneId, Integer dishMenuType);
 
     /**
      * 获取菜品详情

+ 27 - 86
alien-store/src/main/java/shop/alien/store/service/impl/StoreMenuServiceImpl.java

@@ -23,9 +23,7 @@ import shop.alien.mapper.StoreMenuMapper;
 import shop.alien.store.service.StoreImgService;
 import shop.alien.store.service.StoreMenuService;
 
-import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -232,7 +230,6 @@ public class StoreMenuServiceImpl extends ServiceImpl<StoreMenuMapper, StoreMenu
         return R.success("新增菜品成功");
     }
 
-
     /**
      * 菜品排序信息
      *
@@ -290,6 +287,7 @@ public class StoreMenuServiceImpl extends ServiceImpl<StoreMenuMapper, StoreMenu
         }
         return R.success("删除成功");
     }
+
     @Override
     public StoreMenuVo getMenuCountByStoreId(int storeId) {
         StoreMenuVo storeMenuVo = new StoreMenuVo();
@@ -341,79 +339,30 @@ public class StoreMenuServiceImpl extends ServiceImpl<StoreMenuMapper, StoreMenu
      * @return 菜单列表,按排序字段升序排列,如果查询结果为空则返回空列表
      */
     @Override
-    public Map<String, Object> getClientMenuByStoreId(Integer storeId, Integer dishType, String phoneId, Integer dishMenuType) {
-        log.info("开始获取用户端菜单,门店ID:{},菜品类型:{},用户手机号:{},菜单类型:{}", 
+    public List<StoreMenuVo> getClientMenuByStoreId(Integer storeId, Integer dishType, String phoneId, Integer dishMenuType) {
+        log.info("开始获取用户端菜单,门店ID:{},菜品类型:{},用户手机号:{},菜单类型:{}",
                 storeId, dishType, phoneId, dishMenuType);
-        
+
         // 参数校验
         if (storeId == null || storeId <= 0) {
             log.warn("获取用户端菜单失败,门店ID无效:{}", storeId);
             throw new IllegalArgumentException("门店ID不能为空且必须大于0");
         }
 
-        // 先查询该门店的所有菜单数据(不应用筛选条件),用于统计
-        List<StoreMenuVo> allMenuList = storeMenuMapper.getClientMenuByStoreId(storeId, null, null);
-
-        // 按照四种组合进行分组统计(基于所有菜单数据,不受筛选条件影响):
-        // 1. dish_menu_type = 1(菜单),dish_type = 0(全部)
-        // 2. dish_menu_type = 1(菜单),dish_type = 1(推荐)
-        // 3. dish_menu_type = 2(酒水),dish_type = 0(全部)
-        // 4. dish_menu_type = 2(酒水),dish_type = 1(推荐)
-        Map<String, Integer> countMap = new HashMap<>();
-
-        if (CollectionUtils.isNotEmpty(allMenuList)) {
-            // 统计:dish_menu_type = 1(菜单),dish_type = 1(推荐)
-            long menuRecommendCount = allMenuList.stream()
-                    .filter(item -> "1".equals(item.getDishMenuType())
-                            && DISH_TYPE_RECOMMEND.equals(item.getDishType()))
-                    .count();
-            countMap.put("menu_recommend", (int) menuRecommendCount);
-
-            // 统计:dish_menu_type = 1(菜单),dish_type = 0(全部)
-            long menuAllCount = allMenuList.stream()
-                    .filter(item -> "1".equals(item.getDishMenuType())
-                            && (item.getDishType() == null || DISH_TYPE_NON_RECOMMEND.equals(item.getDishType())))
-                    .count();
-            countMap.put("menu_all", (int) menuAllCount + (int) menuRecommendCount);
-
-            // 统计:dish_menu_type = 2(酒水),dish_type = 1(推荐)
-            long drinkRecommendCount = allMenuList.stream()
-                    .filter(item -> "2".equals(item.getDishMenuType())
-                            && DISH_TYPE_RECOMMEND.equals(item.getDishType()))
-                    .count();
-            countMap.put("drink_recommend", (int) drinkRecommendCount);
-
-            // 统计:dish_menu_type = 2(酒水),dish_type = 0(全部)
-            long drinkAllCount = allMenuList.stream()
-                    .filter(item -> "2".equals(item.getDishMenuType())
-                            && (item.getDishType() == null || DISH_TYPE_NON_RECOMMEND.equals(item.getDishType())))
-                    .count();
-            countMap.put("drink_all", (int) drinkAllCount + (int) drinkRecommendCount);
-        } else {
-            // 如果没有数据,返回0
-            countMap.put("menu_all", 0);
-            countMap.put("menu_recommend", 0);
-            countMap.put("drink_all", 0);
-            countMap.put("drink_recommend", 0);
-        }
-
         // 处理菜品类型参数:当dishType为0时,转换为null以查询所有类型
-        Integer queryDishType = (dishType != null && DISH_TYPE_NON_RECOMMEND.equals(dishType)) ? null : dishType;
+        Integer queryDishType = (DISH_TYPE_NON_RECOMMEND.equals(dishType)) ? null : dishType;
 
-        // 根据筛选条件查询菜单列表(用于返回给前端)
+        // 查询菜单列表
         List<StoreMenuVo> menuList = storeMenuMapper.getClientMenuByStoreId(storeId, queryDishType, dishMenuType);
-        
-        // 如果查询结果为空,返回空列表但保留统计信息
+
+        // 如果查询结果为空,直接返回空列表
         if (CollectionUtils.isEmpty(menuList)) {
-            log.info("获取用户端菜单完成,门店ID:{},未查询到符合条件的菜单数据", storeId);
-            Map<String, Object> result = new HashMap<>();
-            result.put("list", Collections.emptyList());
-            result.put("count", countMap);
-            return result;
+            log.info("获取用户端菜单完成,门店ID:{},未查询到菜单数据", storeId);
+            return menuList;
         }
-        
-        log.info("获取用户端菜单,门店ID:{},查询到符合条件的菜单数量:{}", storeId, menuList.size());
-        
+
+        log.info("获取用户端菜单,门店ID:{},查询到菜单数量:{}", storeId, menuList.size());
+
         // 如果是推荐菜且有用户标识,批量查询并设置点赞状态
         if (DISH_TYPE_RECOMMEND.equals(dishType) && StringUtils.isNotEmpty(phoneId)) {
             setLikeStatusForMenuList(menuList, phoneId);
@@ -421,23 +370,15 @@ public class StoreMenuServiceImpl extends ServiceImpl<StoreMenuMapper, StoreMenu
             // 非推荐菜或未提供用户手机号时,设置默认未点赞状态
             menuList.forEach(item -> item.setIsLike(LIKE_STATUS_NO));
         }
-        
+
         // 按排序字段升序排序
         List<StoreMenuVo> sortedMenuList = menuList.stream()
                 .sorted(Comparator.comparing(StoreMenuVo::getSort, Comparator.nullsLast(Integer::compareTo)))
                 .collect(Collectors.toList());
-        
-        // 构建返回结果
-        Map<String, Object> result = new HashMap<>();
-        result.put("list", sortedMenuList);
-        result.put("count", countMap);
-
-        log.info("获取用户端菜单完成,门店ID:{},返回菜单数量:{},统计信息:菜单-全部={},菜单-推荐={},酒水-全部={},酒水-推荐={}",
-                storeId, sortedMenuList.size(),
-                countMap.get("menu_all"), countMap.get("menu_recommend"),
-                countMap.get("drink_all"), countMap.get("drink_recommend"));
-
-        return result;
+
+        log.info("获取用户端菜单完成,门店ID:{},返回菜单数量:{}", storeId, sortedMenuList.size());
+
+        return sortedMenuList;
     }
 
     /**
@@ -453,43 +394,43 @@ public class StoreMenuServiceImpl extends ServiceImpl<StoreMenuMapper, StoreMenu
         if (CollectionUtils.isEmpty(menuList) || StringUtils.isEmpty(phoneId)) {
             return;
         }
-        
+
         log.debug("开始批量查询点赞状态,用户手机号:{},菜单数量:{}", phoneId, menuList.size());
-        
+
         // 将菜单ID转换为String集合,用于查询点赞记录
         Set<String> menuIdStrSet = menuList.stream()
                 .map(item -> String.valueOf(item.getId()))
                 .filter(id -> id != null && !"null".equals(id))
                 .collect(Collectors.toSet());
-        
+
         if (menuIdStrSet.isEmpty()) {
             log.warn("菜单ID集合为空,无法查询点赞状态");
             menuList.forEach(item -> item.setIsLike(LIKE_STATUS_NO));
             return;
         }
-        
+
         // 批量查询点赞记录
         LambdaQueryWrapper<LifeLikeRecord> likeQuery = new LambdaQueryWrapper<>();
         likeQuery.eq(LifeLikeRecord::getDianzanId, phoneId)
                 .in(LifeLikeRecord::getHuifuId, menuIdStrSet);
         List<LifeLikeRecord> likeRecordList = lifeLikeRecordMapper.selectList(likeQuery);
-        
+
         // 构建已点赞的菜单ID集合
         Set<String> likedMenuIdSet = likeRecordList.stream()
                 .map(LifeLikeRecord::getHuifuId)
                 .filter(id -> id != null)
                 .collect(Collectors.toSet());
-        
-        log.debug("查询到点赞记录数量:{},已点赞菜单数量:{}", 
+
+        log.debug("查询到点赞记录数量:{},已点赞菜单数量:{}",
                 likeRecordList.size(), likedMenuIdSet.size());
-        
+
         // 设置点赞状态
         menuList.forEach(item -> {
             if (item.getId() == null) {
                 item.setIsLike(LIKE_STATUS_NO);
                 return;
             }
-            
+
             String menuIdStr = String.valueOf(item.getId());
             if (likedMenuIdSet.contains(menuIdStr)) {
                 item.setIsLike(LIKE_STATUS_YES);