h5周菜谱

This commit is contained in:
sxu 2025-06-06 17:06:12 +08:00
parent 3144a21a8d
commit e6c0c78513
3 changed files with 170 additions and 49 deletions

View File

@ -15,6 +15,7 @@ import org.apache.ibatis.annotations.Select;
import java.time.LocalDate;
import java.util.List;
import java.util.Set;
/**
* 菜品计划信息Mapper接口
@ -31,4 +32,13 @@ public interface CookRecipeH5Mapper {
Long selectStallIdByRecipeId(@Param("recipeId") Long recipeId);
List<Long> selectWeekRecipeId(@Param("recipeId") Long recipeId);
String getBingTimeByRecipeId(@Param("recipeId") Long recipeId);
List<Long> getRecipeIdListByRecipeId(@Param("recipeId") Long recipeId);
List<Long> selectWeekRecipeIdHistory(@Param("recipeIdList") List<Long> recipeId, @Param("effIdSet") Set<Long> effIdSet, @Param("applyDate") LocalDate applyDate);
List<AppletWeekRecipeVO> selectWeekRecipe(@Param("applyDate") LocalDate applyDate, @Param("recipeId") Long recipeId, @Param("recipeIdList") List<Long> recipeIdList);
}

View File

@ -126,55 +126,53 @@ public class CookRecipeServiceH5Impl implements ICookRecipeH5Service {
@Override
public List<AppletWeekRecipeVO> getWeekRecipeDetailList(AppletWeekRecipeDTO content) {
// List<Long> recipeIdList = Lists.newArrayList();
// if (ObjectUtil.isNull(content.getRecipeId())) {
// recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId());
// if (ObjectUtil.isEmpty(recipeIdList)) {
// return Lists.newArrayList();
// }
// } else {
// LocalDate applyDate = LocalDate.parse(content.getDate());
// LocalDate now = LocalDate.now();
//
// if (applyDate.isBefore(now)) {
// System.out.println("applyDate 早于当前日期");
// //获取当前菜谱绑定的日期
// String bindTime = this.cookRecipeH5Mapper.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.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId());
// }else{
// System.out.println("绑定日期迟于查询历史信息日期");
// List<Long> repeIdList = this.cookRecipeH5Mapper.getRecipeIdListByRecipeId(content.getRecipeId());
// recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeIdHistory(repeIdList, null,applyDate);
// if(recipeIdList == null || recipeIdList.size() == 0){
// ((List) recipeIdList).add(content.getRecipeId());
// }
// }
// }
// } else if (applyDate.isAfter(now)) {
// System.out.println("applyDate 晚于当前日期");
// recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId());
// } else {
// System.out.println("applyDate 等于当前日期");
// recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId());
// }
// if(recipeIdList == null || recipeIdList.size() == 0){
// throw new ServiceException("本档口没有更早的历史菜谱记录");
// }
// }
//
// this.generateRecipe((List) recipeIdList, content.getApplyDate());
// List<AppletWeekRecipeVO> resultList = cookRecipeH5Mapper.selectWeekRecipe(content.getApplyDate(), content.getRecipeId(), (List) recipeIdList);
// resultList.sort(Collections.reverseOrder((s1, s2) -> {
// return s2.getMealtimeType() - s1.getMealtimeType();
// }));
// return resultList;
List<Long> recipeIdList = Lists.newArrayList();
if (ObjectUtil.isNull(content.getRecipeId())) {
recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId());
if (ObjectUtil.isEmpty(recipeIdList)) {
return Lists.newArrayList();
}
} else {
LocalDate applyDate = LocalDate.parse(content.getDate());
LocalDate now = LocalDate.now();
return null;
if (applyDate.isBefore(now)) {
System.out.println("applyDate 早于当前日期");
//获取当前菜谱绑定的日期
String bindTime = this.cookRecipeH5Mapper.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.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId());
}else{
System.out.println("绑定日期迟于查询历史信息日期");
List<Long> repeIdList = this.cookRecipeH5Mapper.getRecipeIdListByRecipeId(content.getRecipeId());
recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeIdHistory(repeIdList, null,applyDate);
if(recipeIdList == null || recipeIdList.size() == 0){
((List) recipeIdList).add(content.getRecipeId());
}
}
}
} else if (applyDate.isAfter(now)) {
System.out.println("applyDate 晚于当前日期");
recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId());
} else {
System.out.println("applyDate 等于当前日期");
recipeIdList = this.cookRecipeH5Mapper.selectWeekRecipeId(content.getRecipeId());
}
if(recipeIdList == null || recipeIdList.size() == 0){
throw new ServiceException("本档口没有更早的历史菜谱记录");
}
}
//this.generateRecipe((List) recipeIdList, content.getApplyDate());
List<AppletWeekRecipeVO> resultList = cookRecipeH5Mapper.selectWeekRecipe(content.getApplyDate(), content.getRecipeId(), (List) recipeIdList);
resultList.sort(Collections.reverseOrder((s1, s2) -> {
return s2.getMealtimeType() - s1.getMealtimeType();
}));
return resultList;
}
}

View File

@ -56,6 +56,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</collection>
</resultMap>
<resultMap id="appletWeekRecipeVO" type="com.bonus.canteen.core.cook.vo.AppletWeekRecipeVO">
<result property="mealtimeType" column="mealtime_type"/>
<collection property="typeList" ofType="com.bonus.canteen.core.cook.vo.AppletWeekRecipeTypeVO">
<result property="typeId" column="type_id"/>
<result property="typeName" column="type_name"/>
<collection property="dishesList" ofType="com.bonus.canteen.core.cook.vo.AppletWeekRecipeDishesVO">
<result property="baseDishesId" column="base_dishes_id"/>
<result property="dishesName" column="dishes_name"/>
<result property="dishesImgUrl" column="dishes_img_url"/>
<result property="detailId" column="detail_id"/>
<result property="canteenId" column="canteen_id"/>
<result property="canteenName" column="canteen_name"/>
<result property="stallId" column="stall_id"/>
<result property="stallName" column="stall_name"/>
<collection property="dishesDetailList" ofType="com.bonus.canteen.core.cook.vo.AppletCurrentDishesDetailVO">
<result property="dishesId" column="dishes_id"/>
<result property="dishesName" column="real_dishes_name"/>
<result property="remanentNum" column="remanent_num"/>
<result property="limitNum" column="limit_num"/>
<result property="dishesPrice" column="dishes_price"/>
<result property="prefPrice" column="pref_price"/>
<result property="sizeType" column="size_type"/>
<result property="sizeJson" column="size_json"/>
</collection>
</collection>
</collection>
</resultMap>
<select id="selectReserveMealCanteenList" resultMap="appletReserveCanteenVO">
select
ac.canteen_id,
@ -147,5 +175,90 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select stall_id from cook_recipe
where recipe_id = #{recipeId}
</select>
<!-- 获取菜谱id -->
<select id="selectWeekRecipeId" resultType="java.lang.Long">
select
mar.recipe_id
from
cook_recipe_bind_app mar
left join cook_recipe mr on mar.recipe_id = mr.recipe_id
where
bind_type = 3
<if test="recipeId != null">
and mar.recipe_id = #{recipeId}
</if>
</select>
<select id="getBingTimeByRecipeId" resultType="java.lang.String">
select bind_time from cook_recipe_bind_app where recipe_id = #{recipeId} and bind_type = 3
</select>
<select id="getRecipeIdListByRecipeId" resultType="java.lang.Long">
select recipe_id from cook_recipe where stall_id = (select stall_id from cook_recipe where recipe_id = #{recipeId})
</select>
<select id="selectWeekRecipeIdHistory" resultType="java.lang.Long">
select
mar.recipe_id
from
cook_recipe_bind_app_history mar
left join cook_recipe mr on mar.recipe_id = mr.recipe_id
where
bind_type = 3
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="selectWeekRecipe" resultMap="appletWeekRecipeVO">
select
mrd.mealtime_type,
if(md.meal_type = 2, 2, mdt.dishes_type_id) as type_id,
if(md.meal_type = 2, '套餐', mdt.dishes_type_name) as type_name,
md.dishes_id,
md.dishes_name,
md.intro,
md.image_url as dishes_img_url,
mrd.recipe_detail_id,
m.remanent_num,
m.limit_num,
m.price as dishes_price,
m.sale_price as pref_price,
ac.canteen_id,
ac.canteen_name,
ass.stall_id,
ass.stall_name,
m.size_type,
md.size_json
from
cook_recipe_detail mrd
inner join cook_recipe_dishes m on mrd.recipe_detail_id = m.recipe_detail_id
inner join cook_dishes md on m.dishes_id = md.dishes_id
inner join cook_dishes_type mdt on md.type_id = mdt.dishes_type_id
inner join cook_recipe mr on mrd.recipe_id = mr.recipe_id
left join cook_dishes_sale_record mdsr on md.dishes_id = mdsr.dishes_id
and mr.stall_id = mdsr.stall_id
and mdsr.sale_month = month(curdate())
left join basic_canteen ac on mr.canteen_id = ac.canteen_id
left join basic_stall ass on mr.stall_id = ass.stall_id
where
mrd.apply_date = #{applyDate}
<if test="recipeId != null">
and mrd.recipe_id = #{recipeId}
</if>
<if test="recipeIdList != null and recipeIdList.size() > 0">
and mrd.recipe_id in
<foreach collection="recipeIdList" item="recipeId" open="(" separator="," close=")">
#{recipeId}
</foreach>
</if>
order by
md.dishes_id asc
</select>
</mapper>