h5历史菜谱功能薪增

This commit is contained in:
liux 2025-04-30 14:08:11 +08:00
parent 5d1ca83851
commit 796a91fa5d
4 changed files with 83 additions and 7 deletions

View File

@ -62,8 +62,12 @@ public class AppletRecipeH5Controller extends BaseController {
@PostMapping({"/detail"})
@ApiOperation("根据菜品id获取菜品详情")
public AjaxResult getRecipeDetail(@RequestBody AppletDishesDetailDTO dto) {
try {
AppletDishesDetailVO dishesDetailVO = this.appletRecipeH5Service.getDishesDetailByDishesId(dto);
return success(dishesDetailVO);
}catch (Exception e) {
return AjaxResult.error(e.getMessage());
}
}

View File

@ -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<String> selectDishesName(@Param("dishesId") Long dishesId);
List<Long> selectWeekRecipeIdHistory(@Param("recipeIdList") List<Long> recipeId, @Param("effIdSet") Set<Long> effIdSet, @Param("applyDate") LocalDate applyDate);
List<Long> getRecipeIdListByRecipeId(@Param("recipeId") Long recipeId);
String getBingTimeByRecipeId(@Param("recipeId") Long recipeId);
}

View File

@ -141,19 +141,56 @@ public class AppletRecipeH5ServiceImpl extends ServiceImpl<MenuRecipeMapper, Men
@Override
public List<AppletWeekRecipeVO> getWeekRecipeDetailList(AppletWeekRecipeDTO content) {
List<Long> recipeIdList = Lists.newArrayList();
if (ObjectUtil.isNull(content.getRecipeId())) {
Set<Long> effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false);
if (ObjectUtil.isNull(content.getRecipeId())) {
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 {
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<Long> 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());
List<AppletWeekRecipeVO> resultList = appletRecipeH5Mapper.selectWeekRecipe(content.getApplyDate(), content.getRecipeId(), (List) recipeIdList);

View File

@ -118,9 +118,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- <foreach collection="effIdSet" item="effId" separator="," open="(" close=")">-->
<!-- #{effId}-->
<!-- </foreach>-->
<!-- <if test="recipeId != null">-->
<!-- and mar.recipe_id = #{recipeId}-->
<!-- </if>-->
<if test="recipeId != null">
and mar.recipe_id = #{recipeId}
</if>
</select>
@ -215,4 +215,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and mmd.del_flag = 2
</select>
<select id="selectWeekRecipeIdHistory" resultType="java.lang.Long">
select
mar.recipe_id
from
menu_app_recipe_history mar
left join menu_recipe mr on mar.recipe_id = mr.recipe_id
where
bind_type = 3
<!-- and mr.eff_id in-->
<!-- <foreach collection="effIdSet" item="effId" separator="," open="(" close=")">-->
<!-- #{effId}-->
<!-- </foreach>-->
and mar.recipe_id in
<foreach collection="recipeIdList" item="repiceId" separator="," open="(" close=")">
#{repiceId}
</foreach>
and #{applyDate} >= DATE(mar.bind_time)
ORDER BY bind_time desc limit 1
</select>
<select id="getRecipeIdListByRecipeId" resultType="java.lang.Long">
select recipe_id from menu_recipe where stall_id = (select stall_id from menu_recipe where recipe_id = #{recipeId})
</select>
<select id="getBingTimeByRecipeId" resultType="java.lang.String">
select bind_time from menu_app_recipe where recipe_id = #{recipeId}
</select>
</mapper>