diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/AppletRecipeH5Controller.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/AppletRecipeH5Controller.java index d397deb..00cbcef 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/AppletRecipeH5Controller.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/AppletRecipeH5Controller.java @@ -62,8 +62,12 @@ public class AppletRecipeH5Controller extends BaseController { @PostMapping({"/detail"}) @ApiOperation("根据菜品id获取菜品详情") public AjaxResult getRecipeDetail(@RequestBody AppletDishesDetailDTO dto) { - AppletDishesDetailVO dishesDetailVO = this.appletRecipeH5Service.getDishesDetailByDishesId(dto); - return success(dishesDetailVO); + try { + AppletDishesDetailVO dishesDetailVO = this.appletRecipeH5Service.getDishesDetailByDishesId(dto); + return success(dishesDetailVO); + }catch (Exception e) { + return AjaxResult.error(e.getMessage()); + } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/AppletRecipeH5Mapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/AppletRecipeH5Mapper.java index 588e88e..510cda1 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/AppletRecipeH5Mapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/AppletRecipeH5Mapper.java @@ -38,4 +38,10 @@ public interface AppletRecipeH5Mapper { @Select({"select md.dishes_name from menu_package_dishes mpd left join menu_dishes md on mpd.dishes_id = md.dishes_id where mpd.del_flag = 2 and mpd.package_id = #{dishesId}"}) List selectDishesName(@Param("dishesId") Long dishesId); + + List selectWeekRecipeIdHistory(@Param("recipeIdList") List recipeId, @Param("effIdSet") Set effIdSet, @Param("applyDate") LocalDate applyDate); + + List getRecipeIdListByRecipeId(@Param("recipeId") Long recipeId); + + String getBingTimeByRecipeId(@Param("recipeId") Long recipeId); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/AppletRecipeH5ServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/AppletRecipeH5ServiceImpl.java index 271385e..ba543e4 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/AppletRecipeH5ServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/AppletRecipeH5ServiceImpl.java @@ -141,18 +141,55 @@ public class AppletRecipeH5ServiceImpl extends ServiceImpl getWeekRecipeDetailList(AppletWeekRecipeDTO content) { List recipeIdList = Lists.newArrayList(); + Set effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false); if (ObjectUtil.isNull(content.getRecipeId())) { - Set effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false); if (ObjectUtil.isEmpty(effIdSet)) { effIdSet = Sets.newTreeSet(); effIdSet.add(-1L); } recipeIdList = this.appletRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId(), (Set) effIdSet); + if (ObjectUtil.isEmpty(recipeIdList)) { return Lists.newArrayList(); } } else { - recipeIdList.add(content.getRecipeId()); + LocalDate applyDate = content.getApplyDate(); + LocalDate now = LocalDate.now(); + if (applyDate.isBefore(now)) { + System.out.println("applyDate 早于当前日期"); + //获取当前菜谱绑定的日期 + String bindTime = this.appletRecipeH5Mapper.getBingTimeByRecipeId(content.getRecipeId()); + if(bindTime !=null){ + bindTime = bindTime.substring(0,10); + LocalDate bindDate = LocalDate.parse(bindTime); + System.out.println("Parsed date and time: " + bindDate); + if(bindDate.isBefore(applyDate)){ + System.out.println("绑定日期早于查询历史信息日期"); + recipeIdList = this.appletRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId(), effIdSet); + }else{ + System.out.println("绑定日期迟于查询历史信息日期"); + + List repeIdList = this.appletRecipeH5Mapper.getRecipeIdListByRecipeId(content.getRecipeId()); + + recipeIdList = this.appletRecipeH5Mapper.selectWeekRecipeIdHistory(repeIdList, null,applyDate); + if(recipeIdList == null || recipeIdList.size() == 0){ + recipeIdList.add(content.getRecipeId()); + } + } + }else{ + throw new ServiceException("菜谱档口绑定日期为空"); + } + } else if (applyDate.isAfter(now)) { + System.out.println("applyDate 晚于当前日期"); + recipeIdList = this.appletRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId(), null); + } else { + System.out.println("applyDate 等于当前日期"); + recipeIdList = this.appletRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId(), null); + } + if(recipeIdList == null || recipeIdList.size() == 0){ + throw new ServiceException("本档口没有更早的历史菜谱记录"); + // recipeIdList.add(content.getRecipeId()); + } } this.generateRecipe(recipeIdList, content.getApplyDate()); diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/AppletRecipeH5Mapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/AppletRecipeH5Mapper.xml index d25ab92..2dd5435 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/AppletRecipeH5Mapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/menu/AppletRecipeH5Mapper.xml @@ -118,9 +118,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - + + and mar.recipe_id = #{recipeId} + @@ -215,4 +215,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and mmd.del_flag = 2 + + + + + + +