2025-04-03 15:06:05 +08:00
|
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
|
|
<!DOCTYPE mapper
|
|
|
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2025-04-05 19:12:26 +08:00
|
|
|
|
<mapper namespace="com.bonus.canteen.core.menu.mapper.MenuRecipeMapper">
|
|
|
|
|
|
<resultMap type="com.bonus.canteen.core.menu.domain.MenuRecipe" id="MenuRecipeResult">
|
2025-04-03 15:06:05 +08:00
|
|
|
|
<result property="id" column="id" />
|
|
|
|
|
|
<result property="recipeId" column="recipe_id" />
|
|
|
|
|
|
<result property="planId" column="plan_id" />
|
|
|
|
|
|
<result property="recipeName" column="recipe_name" />
|
|
|
|
|
|
<result property="isDefault" column="is_default" />
|
|
|
|
|
|
<result property="recipeType" column="recipe_type" />
|
|
|
|
|
|
<result property="effectDate" column="effect_date" />
|
|
|
|
|
|
<result property="expireDate" column="expire_date" />
|
|
|
|
|
|
<result property="canteenId" column="canteen_id" />
|
|
|
|
|
|
<result property="stallId" column="stall_id" />
|
|
|
|
|
|
<result property="enableFlag" column="enable_flag" />
|
|
|
|
|
|
<result property="revision" column="revision" />
|
|
|
|
|
|
<result property="createBy" column="create_by" />
|
|
|
|
|
|
<result property="createTime" column="create_time" />
|
|
|
|
|
|
<result property="updateBy" column="update_by" />
|
|
|
|
|
|
<result property="updateTime" column="update_time" />
|
|
|
|
|
|
<result property="remark" column="remark" />
|
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
|
|
<sql id="selectMenuRecipeVo">
|
|
|
|
|
|
select id, recipe_id, plan_id, recipe_name, is_default, recipe_type, effect_date, expire_date, canteen_id, stall_id, enable_flag, revision, create_by, create_time, update_by, update_time, remark from menu_recipe
|
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
2025-04-14 23:58:26 +08:00
|
|
|
|
<select id="selectMenuRecipeList" parameterType="com.bonus.canteen.core.menu.domain.MenuRecipe" resultType="com.bonus.canteen.core.menu.vo.MenuRecipeVO">
|
|
|
|
|
|
|
|
|
|
|
|
<!-- select ala.area_id as areaId,ala.area_name as areaName,ac.canteen_id as canteenId,ac.canteen_name as canteenName,-->
|
|
|
|
|
|
<!-- als.stall_id as stallId,als.stall_name as stallName,map.recipe_id as recipeId,mr.recipe_name as recipeName-->
|
|
|
|
|
|
<!-- from menu_recipe mr-->
|
|
|
|
|
|
<!-- LEFT JOIN alloc_canteen ac on ac.canteen_id = mr.canteen_id-->
|
|
|
|
|
|
<!-- LEFT JOIN alloc_stall als on als.stall_id = mr.stall_id-->
|
|
|
|
|
|
<!-- LEFT JOIN alloc_area ala on ala.area_id = ac.area_id-->
|
|
|
|
|
|
<!-- LEFT JOIN menu_app_recipe map on map.recipe_id = mr.recipe_id-->
|
|
|
|
|
|
<!-- WHERE ala.area_id is not null and map.bind_type = #{key}-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- AND EXISTS (-->
|
|
|
|
|
|
<!-- SELECT NULL-->
|
|
|
|
|
|
<!-- FROM-->
|
|
|
|
|
|
<!-- device_bind t6-->
|
|
|
|
|
|
<!-- LEFT JOIN device_info t7 ON t7.device_id = t6.device_id-->
|
|
|
|
|
|
<!-- WHERE-->
|
|
|
|
|
|
<!-- t6.canteen_id = ac.canteen_id-->
|
|
|
|
|
|
<!-- AND t6.stall_id = als.stall_id-->
|
|
|
|
|
|
<!-- AND t7.device_type IN-->
|
|
|
|
|
|
<!-- <foreach collection="param.deviceTypeList" item="deviceType" separator="," open="(" close=")">-->
|
|
|
|
|
|
<!-- #{deviceType}-->
|
|
|
|
|
|
<!-- </foreach>-->
|
|
|
|
|
|
<!-- )-->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
t3.area_id as areaId, t3.area_name as areaName, t2.canteen_id as canteenId,
|
|
|
|
|
|
t2.canteen_name as canteenName, t1.stall_id as stallId, t1.stall_name as stallName,
|
|
|
|
|
|
a.recipe_id as recipeId,a.recipe_name as recipeName
|
|
|
|
|
|
FROM
|
|
|
|
|
|
alloc_stall t1
|
|
|
|
|
|
LEFT JOIN alloc_canteen t2 ON t1.canteen_id = t2.canteen_id
|
|
|
|
|
|
LEFT JOIN alloc_area t3 ON t2.area_id = t3.area_id
|
|
|
|
|
|
LEFT JOIN(
|
|
|
|
|
|
select
|
|
|
|
|
|
mar.recipe_id,
|
|
|
|
|
|
mr.stall_id,
|
|
|
|
|
|
mar.bind_type,
|
|
|
|
|
|
mr.recipe_name
|
|
|
|
|
|
from menu_app_recipe mar
|
|
|
|
|
|
left join menu_recipe mr on mar.recipe_id = mr.recipe_id
|
|
|
|
|
|
where bind_type = #{bindType}
|
|
|
|
|
|
) a on a.stall_id =t1.stall_id
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
<if test="deviceTypeList != null and deviceTypeList.size() > 0">
|
|
|
|
|
|
|
|
|
|
|
|
EXISTS (
|
|
|
|
|
|
SELECT NULL
|
|
|
|
|
|
FROM
|
|
|
|
|
|
device_bind t6
|
|
|
|
|
|
LEFT JOIN device_info t7 ON t7.device_id = t6.device_id
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
t6.canteen_id = t2.canteen_id
|
|
|
|
|
|
AND t6.stall_id = t1.stall_id
|
|
|
|
|
|
AND t7.device_type IN
|
|
|
|
|
|
<foreach collection="deviceTypeList" item="deviceType" separator="," open="(" close=")">
|
|
|
|
|
|
#{deviceType}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
and 1=1
|
|
|
|
|
|
|
|
|
|
|
|
<if test="areaIds !=null">
|
|
|
|
|
|
and ala.area_id in
|
|
|
|
|
|
<foreach collection="areaIds" open="(" close=")" item="item" separator=",">
|
|
|
|
|
|
#{item}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="canteenIds !=null">
|
|
|
|
|
|
and ac.canteen_id in
|
|
|
|
|
|
<foreach collection="canteenIds" open="(" close=")" item="item" separator=",">
|
|
|
|
|
|
#{item}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="stallIds !=null">
|
|
|
|
|
|
and als.stall_id in
|
|
|
|
|
|
<foreach collection="stallIds" open="(" close=")" item="item" separator=",">
|
|
|
|
|
|
#{item}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
<if test="recipeName !=null and recipeName !=''">
|
|
|
|
|
|
and a.recipe_name like concat('%', #{recipeName}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- <include refid="selectMenuRecipeVo"/>-->
|
|
|
|
|
|
<!-- <where> -->
|
|
|
|
|
|
<!-- <if test="recipeId != null "> and recipe_id = #{recipeId}</if>-->
|
|
|
|
|
|
<!-- <if test="planId != null and planId != ''"> and plan_id = #{planId}</if>-->
|
|
|
|
|
|
<!-- <if test="recipeName != null and recipeName != ''"> and recipe_name like concat('%', #{recipeName}, '%')</if>-->
|
|
|
|
|
|
<!-- <if test="isDefault != null "> and is_default = #{isDefault}</if>-->
|
|
|
|
|
|
<!-- <if test="recipeType != null "> and recipe_type = #{recipeType}</if>-->
|
|
|
|
|
|
<!-- <if test="effectDate != null "> and effect_date = #{effectDate}</if>-->
|
|
|
|
|
|
<!-- <if test="expireDate != null "> and expire_date = #{expireDate}</if>-->
|
|
|
|
|
|
<!-- <if test="canteenId != null "> and canteen_id = #{canteenId}</if>-->
|
|
|
|
|
|
<!-- <if test="stallId != null "> and stall_id = #{stallId}</if>-->
|
|
|
|
|
|
<!-- <if test="enableFlag != null "> and enable_flag = #{enableFlag}</if>-->
|
|
|
|
|
|
<!-- <if test="revision != null "> and revision = #{revision}</if>-->
|
|
|
|
|
|
<!-- </where>-->
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getDishesListByRecipeId" parameterType="string" resultType="com.bonus.canteen.core.menu.vo.MenuRecipeMealtimeTypeVO">
|
|
|
|
|
|
<!-- 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵-->
|
|
|
|
|
|
select mealtime_type as mealtimeType,
|
|
|
|
|
|
CASE
|
|
|
|
|
|
WHEN mealtime_type = 1 THEN '早餐'
|
|
|
|
|
|
WHEN mealtime_type = 2 THEN '午餐'
|
|
|
|
|
|
WHEN mealtime_type = 3 THEN '晚餐'
|
|
|
|
|
|
WHEN mealtime_type = 4 THEN '下午茶'
|
|
|
|
|
|
WHEN mealtime_type = 5 THEN '夜宵'
|
|
|
|
|
|
ELSE '无效参数'
|
|
|
|
|
|
END AS mealtimeName,
|
|
|
|
|
|
detail_id as detailId
|
|
|
|
|
|
from menu_recipe_detail WHERE recipe_id =#{recipeId} and apply_date = #{applyDate}
|
|
|
|
|
|
GROUP BY mealtime_type ORDER BY mealtime_type
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getDishesListByDetailId" parameterType="string" resultType="com.bonus.canteen.core.menu.vo.MenuRecipeDishesVO">
|
|
|
|
|
|
select mrd.id,mrd.dishes_id as dishesId,mud.dishes_name as dishesName,
|
|
|
|
|
|
mud.dishes_num as dishesNum,mud.meal_type,mud.material_cost as materialCost,
|
|
|
|
|
|
mrd.price,mrd.size_type as sizeType,mrd.supply_num as supplyNum,mrd.sale_num as saleNum,mrd.surplus_num as surplusNum,
|
|
|
|
|
|
mrd.restrict_num as restrictNum,mrd.sale_price as salePrice,mrd.recommend_flag as recommendFlag,mrd.sort_num as sortNum,
|
|
|
|
|
|
mdt.type_name as typeName,alc.canteen_name as alc,mud.sales_mode as salesMode,mud.unit_price as unitPrice
|
|
|
|
|
|
from (select * from menu_recipe_dishes where detail_id = #{detailId} ) mrd
|
|
|
|
|
|
LEFT JOIN menu_dishes mud on mud.dishes_id = mrd.dishes_id
|
|
|
|
|
|
LEFT JOIN menu_dishes_type mdt on mdt.type_id = mud.type_id
|
|
|
|
|
|
LEFT JOIN alloc_canteen alc on alc.canteen_id = mud.canteen_id
|
|
|
|
|
|
|
2025-04-03 15:06:05 +08:00
|
|
|
|
</select>
|
2025-04-14 23:58:26 +08:00
|
|
|
|
|
2025-04-03 15:06:05 +08:00
|
|
|
|
<select id="selectMenuRecipeById" parameterType="Long" resultMap="MenuRecipeResult">
|
|
|
|
|
|
<include refid="selectMenuRecipeVo"/>
|
|
|
|
|
|
where id = #{id}
|
|
|
|
|
|
</select>
|
2025-04-14 13:14:16 +08:00
|
|
|
|
<select id="getDishesList" resultType="com.bonus.canteen.core.menu.vo.MenuRecipeV2VO">
|
|
|
|
|
|
select
|
|
|
|
|
|
mr.recipe_id,
|
|
|
|
|
|
mr.recipe_name,
|
|
|
|
|
|
mr.recipe_type,
|
|
|
|
|
|
ac.canteen_id,
|
|
|
|
|
|
ac.canteen_name,
|
|
|
|
|
|
aa.area_id,
|
|
|
|
|
|
aa.area_name,
|
|
|
|
|
|
a.stall_id,
|
|
|
|
|
|
a.stall_name,
|
|
|
|
|
|
mr.create_time,
|
|
|
|
|
|
mr.create_by
|
|
|
|
|
|
from
|
|
|
|
|
|
menu_recipe mr
|
|
|
|
|
|
left join alloc_canteen ac on mr.canteen_id = ac.canteen_id
|
|
|
|
|
|
left join alloc_stall a on mr.stall_id = a.stall_id
|
|
|
|
|
|
left join alloc_area aa on ac.area_id = aa.area_id
|
|
|
|
|
|
where 1 = 1
|
|
|
|
|
|
<if test="recipeId != null ">
|
|
|
|
|
|
and mr.recipe_id = #{recipeId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="areaIds != null and areaIds.size >0">
|
|
|
|
|
|
and aa.area_id in
|
|
|
|
|
|
<foreach collection="areaIds" item="areaId" open="(" separator="," close=")">
|
|
|
|
|
|
#{areaId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">
|
|
|
|
|
|
and mr.recipe_name like concat('%', #{recipeName}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="canteenId != null and canteenId !=-1">
|
|
|
|
|
|
and mr.canteen_id = #{canteenId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="canteenIds != null and canteenIds.size >0">
|
|
|
|
|
|
and ac.canteen_id in
|
|
|
|
|
|
<foreach collection="canteenIds" item="canteenId" open="(" separator="," close=")">
|
|
|
|
|
|
#{canteenId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="stallId != null and stallId !=-1">
|
|
|
|
|
|
and mr.stall_id = #{stallId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="stallIds != null and stallIds.size >0">
|
|
|
|
|
|
and a.stall_id in
|
|
|
|
|
|
<foreach collection="stallIds" item="stallId" open="(" separator="," close=")">
|
|
|
|
|
|
#{stallId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="areaId != null and areaId !=-1">
|
|
|
|
|
|
and ac.area_id = #{areaId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="areaIds != null and areaIds.size >0">
|
|
|
|
|
|
and ac.area_id in
|
|
|
|
|
|
<foreach collection="areaIds" item="areaId" open="(" separator="," close=")">
|
|
|
|
|
|
#{areaId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="recipeType != null">
|
|
|
|
|
|
and mr.recipe_type = #{recipeType}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getDishesCountByRecipeIds" resultType="com.bonus.canteen.core.menu.dto.RecipeDishesCountDTO">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
mrd.recipe_id,count(DISTINCT(md.base_dishes_id)) as num
|
|
|
|
|
|
FROM
|
|
|
|
|
|
menu_recipe_detail mrd
|
|
|
|
|
|
LEFT JOIN menu_recipe_dishes mrdd ON mrd.detail_id = mrdd.detail_id
|
|
|
|
|
|
LEFT JOIN menu_dishes md ON md.dishes_id = mrdd.dishes_id
|
|
|
|
|
|
where
|
|
|
|
|
|
mrd.apply_date >= curdate()
|
|
|
|
|
|
<if test="recipeIds !=null and recipeIds.size()>0">
|
|
|
|
|
|
AND mrd.recipe_id in
|
|
|
|
|
|
<foreach collection="recipeIds" separator="," open="(" close=")" item="item">
|
|
|
|
|
|
#{item}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
GROUP BY mrd.recipe_id
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="selectApplyDateListByRecipeId" resultType="com.bonus.canteen.core.menu.vo.MenuRecipeDataVO">
|
|
|
|
|
|
SELECT recipe_id as recipeId, apply_date as applyData
|
|
|
|
|
|
FROM menu_recipe_detail
|
|
|
|
|
|
WHERE apply_date >= #{applyDate}
|
|
|
|
|
|
<if test="recipeIds !=null and recipeIds.size()>0">
|
|
|
|
|
|
AND recipe_id IN
|
|
|
|
|
|
<foreach collection="recipeIds" open="(" close=")" item="item" separator=",">
|
|
|
|
|
|
#{item}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
|
|
</select>
|
2025-04-14 18:01:27 +08:00
|
|
|
|
<resultMap id="menuBaseModel" type="com.bonus.canteen.core.menu.model.MenuBaseModel">
|
|
|
|
|
|
<result property="baseDishesId" column="base_dishes_id"/>
|
|
|
|
|
|
<collection property="dishesList" ofType="com.bonus.canteen.core.menu.model.MenuBaseDishesModel">
|
|
|
|
|
|
<result property="dishesId" column="dishes_id"/>
|
|
|
|
|
|
<result property="sizeJson" column="size_json"/>
|
|
|
|
|
|
</collection>
|
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
<select id="selectBaseSizeDishesId" resultMap="menuBaseModel">
|
2025-04-14 13:41:13 +08:00
|
|
|
|
select
|
|
|
|
|
|
base_dishes_id,
|
|
|
|
|
|
dishes_id,
|
|
|
|
|
|
size_json
|
|
|
|
|
|
from
|
|
|
|
|
|
menu_dishes
|
|
|
|
|
|
where
|
|
|
|
|
|
base_dishes_id in
|
|
|
|
|
|
<foreach collection="baseDishesIdList" item="baseDishesId" separator="," open="(" close=")">
|
|
|
|
|
|
#{baseDishesId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</select>
|
2025-04-14 23:58:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-04-14 18:01:27 +08:00
|
|
|
|
<select id="selectCount" resultType="java.lang.Long">
|
|
|
|
|
|
select
|
|
|
|
|
|
count(1)
|
|
|
|
|
|
from menu_recipe
|
|
|
|
|
|
where 1 = 1
|
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">
|
|
|
|
|
|
and recipe_name = #{recipeName}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getOneById" resultType="com.bonus.canteen.core.menu.domain.MenuRecipe">
|
|
|
|
|
|
select recipe_id as recipeId,
|
|
|
|
|
|
plan_id as planId,
|
|
|
|
|
|
recipe_name as recipeName,
|
|
|
|
|
|
is_default as isDefault,
|
|
|
|
|
|
recipe_type as recipeType,
|
|
|
|
|
|
effect_date as effectDate,
|
|
|
|
|
|
expire_date as expireDate,
|
|
|
|
|
|
canteen_id as canteenId,
|
|
|
|
|
|
stall_id as stallId,
|
|
|
|
|
|
enable_flag as enableFlag,
|
|
|
|
|
|
revision,
|
|
|
|
|
|
create_by as createBy,
|
|
|
|
|
|
create_time as createTime,
|
|
|
|
|
|
update_by as updateBy,
|
|
|
|
|
|
update_time as updateTime,
|
|
|
|
|
|
remark
|
|
|
|
|
|
from menu_recipe
|
|
|
|
|
|
where recipe_id = #{recipeId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<!-- MenuRecipeMapper.xml -->
|
|
|
|
|
|
<select id="selectDetailIds" resultType="java.lang.Long">
|
|
|
|
|
|
SELECT detail_id
|
|
|
|
|
|
FROM menu_recipe_detail
|
|
|
|
|
|
<where>
|
|
|
|
|
|
recipe_id = #{dto.recipeId}
|
|
|
|
|
|
AND detail_type = 1
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<!-- 当菜谱类型为3(周类型) -->
|
|
|
|
|
|
<when test="dto.recipeType == 3">
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<!-- 完整模式 -->
|
|
|
|
|
|
<when test="dto.isComplete">
|
|
|
|
|
|
AND apply_week IN
|
|
|
|
|
|
<foreach collection="dto.weeks" item="week" open="(" separator="," close=")">
|
|
|
|
|
|
#{week}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</when>
|
|
|
|
|
|
<!-- 非完整模式 -->
|
|
|
|
|
|
<otherwise>
|
|
|
|
|
|
AND (
|
|
|
|
|
|
<foreach collection="dto.menuRecipeV2Add.recipeDateList" item="dateDTO" separator=" OR ">
|
|
|
|
|
|
<if test="dateDTO != null and dateDTO.detailList != null and !dateDTO.detailList.isEmpty()">
|
|
|
|
|
|
(
|
|
|
|
|
|
<foreach collection="dateDTO.detailList" item="detailDTO" separator=" OR ">
|
|
|
|
|
|
(apply_week = #{dateDTO.applyWeek} AND mealtime_type = #{detailDTO.mealtimeType})
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
)
|
|
|
|
|
|
</otherwise>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</when>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 其他类型且非完整模式 -->
|
|
|
|
|
|
<when test="!dto.isComplete">
|
|
|
|
|
|
AND mealtime_type = #{dto.mealType}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="selectDetailsList" resultType="com.bonus.canteen.core.menu.domain.MenuRecipeDetail">
|
|
|
|
|
|
SELECT *
|
|
|
|
|
|
FROM menu_recipe_detail
|
|
|
|
|
|
<where>
|
|
|
|
|
|
recipe_id = #{dto.recipeId}
|
|
|
|
|
|
AND apply_date >= #{currentDate}
|
|
|
|
|
|
AND detail_type = 2
|
|
|
|
|
|
<!-- 动态条件 -->
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<!-- 当菜谱类型为3(周类型) -->
|
|
|
|
|
|
<when test="dto.recipeType == 3">
|
|
|
|
|
|
<choose>
|
|
|
|
|
|
<!-- 完全模式 -->
|
|
|
|
|
|
<when test="dto.isComplete">
|
|
|
|
|
|
AND apply_week IN
|
|
|
|
|
|
<foreach collection="dto.weeks" item="week" open="(" separator="," close=")">
|
|
|
|
|
|
#{week}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</when>
|
|
|
|
|
|
<!-- 非完全模式 -->
|
|
|
|
|
|
<otherwise>
|
|
|
|
|
|
AND (
|
|
|
|
|
|
<foreach collection="dto.menuRecipeV2Add.recipeDateList" item="dateDTO" separator=" OR ">
|
|
|
|
|
|
<if test="dateDTO != null and dateDTO.detailList != null and !dateDTO.detailList.isEmpty()">
|
|
|
|
|
|
(
|
|
|
|
|
|
<foreach collection="dateDTO.detailList" item="detailDTO" separator=" OR ">
|
|
|
|
|
|
(apply_week = #{dateDTO.applyWeek} AND mealtime_type = #{detailDTO.mealtimeType})
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
)
|
|
|
|
|
|
</otherwise>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</when>
|
2025-04-14 13:14:16 +08:00
|
|
|
|
|
2025-04-14 18:01:27 +08:00
|
|
|
|
<!-- 其他类型且非完整模式 -->
|
|
|
|
|
|
<when test="!dto.isComplete">
|
|
|
|
|
|
AND mealtime_type = #{mealType}
|
|
|
|
|
|
</when>
|
|
|
|
|
|
</choose>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getMenuRecipeDishesList" resultType="com.bonus.canteen.core.menu.domain.MenuRecipeDishes">
|
|
|
|
|
|
SELECT id,
|
|
|
|
|
|
detail_id AS detailId,
|
|
|
|
|
|
dishes_id as dishesId,
|
|
|
|
|
|
price,
|
|
|
|
|
|
size_type as sizeType,
|
|
|
|
|
|
supply_num as supplyNum,
|
|
|
|
|
|
sale_num as saleNum,
|
|
|
|
|
|
surplus_num as surplusNum,
|
|
|
|
|
|
restrict_num as restrictNum,
|
|
|
|
|
|
sale_price as salePrice,
|
|
|
|
|
|
sale_start as saleStart,
|
|
|
|
|
|
sale_end as saleEnd,
|
|
|
|
|
|
chef_id as chefId,
|
|
|
|
|
|
recommend_flag as recommendFlag,
|
|
|
|
|
|
sort_num as sortNum,
|
|
|
|
|
|
revision,
|
|
|
|
|
|
create_by as createBy,
|
|
|
|
|
|
create_time as createTime,
|
|
|
|
|
|
update_by as updateBy,
|
|
|
|
|
|
update_time as updateTime,
|
|
|
|
|
|
remark
|
|
|
|
|
|
FROM menu_recipe_dishes
|
|
|
|
|
|
where
|
|
|
|
|
|
detail_id IN
|
|
|
|
|
|
<foreach collection="haveDetailIds" item="item" separator="," open="(" close=")">
|
|
|
|
|
|
#{item}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="selectMenuRecipeDetail" resultType="com.bonus.canteen.core.menu.domain.MenuRecipeDetail">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
id,
|
|
|
|
|
|
detail_id AS detailId,
|
|
|
|
|
|
sale_type_id AS saleTypeId,
|
|
|
|
|
|
recipe_id AS recipeId,
|
|
|
|
|
|
apply_date AS applyDate,
|
|
|
|
|
|
apply_week AS applyWeek,
|
|
|
|
|
|
apply_month AS applyMonth,
|
|
|
|
|
|
mealtime_type AS mealtimeType,
|
|
|
|
|
|
detail_type AS detailType,
|
|
|
|
|
|
revision
|
|
|
|
|
|
FROM menu_recipe_detail
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<!-- 固定条件 -->
|
|
|
|
|
|
recipe_id = #{bean.recipeId}
|
|
|
|
|
|
AND apply_date >= #{bean.applyDate}
|
|
|
|
|
|
AND apply_date <= #{bean.endDate}
|
|
|
|
|
|
AND detail_type = #{bean.detailType}
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 可扩展的动态条件(示例) -->
|
|
|
|
|
|
<if test="bean.mealtimeType != null">
|
|
|
|
|
|
AND mealtime_type = #{bean.mealtimeType}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="weeks != null and weeks.size() > 0">
|
|
|
|
|
|
and apply_week in
|
|
|
|
|
|
<foreach collection="weeks" item="item" separator="," open="(" close=")">
|
|
|
|
|
|
#{item}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="selectDetailIdListByWrapper" resultType="java.lang.Long">
|
|
|
|
|
|
SELECT detail_id FROM menu_recipe_detail
|
|
|
|
|
|
WHERE del_flag = 0
|
|
|
|
|
|
AND recipe_id = #{recipeId}
|
|
|
|
|
|
AND apply_date IN
|
|
|
|
|
|
<foreach item="date" collection="applyDateList" open="(" separator="," close=")">
|
|
|
|
|
|
#{date}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
<if test="isComplete == false">
|
|
|
|
|
|
AND (
|
|
|
|
|
|
<foreach item="dateItem" collection="recipeDateList" separator=" OR ">
|
|
|
|
|
|
<if test="dateItem != null and dateItem.detailList != null and !dateItem.detailList.isEmpty()">
|
|
|
|
|
|
(
|
|
|
|
|
|
apply_date = #{dateItem.applyDate}
|
|
|
|
|
|
AND mealtime_type IN
|
|
|
|
|
|
<foreach item="detail" collection="dateItem.detailList" open="(" separator="," close=")">
|
|
|
|
|
|
#{detail.mealtimeType}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="selectBatchIds" resultType="com.bonus.canteen.core.menu.domain.MenuRecipeDishes">
|
|
|
|
|
|
select
|
|
|
|
|
|
id,
|
|
|
|
|
|
detail_id as detailId,
|
|
|
|
|
|
dishes_id as dishesId,
|
|
|
|
|
|
price,
|
|
|
|
|
|
size_type as sizeType,
|
|
|
|
|
|
supply_num as supplyNum,
|
|
|
|
|
|
sale_num as saleNum,
|
|
|
|
|
|
surplus_num as surplusNum,
|
|
|
|
|
|
restrict_num as restrictNum,
|
|
|
|
|
|
sale_price as salePrice,
|
|
|
|
|
|
sale_start as saleStart,
|
|
|
|
|
|
sale_end as saleEnd,
|
|
|
|
|
|
chef_id as chefId,
|
|
|
|
|
|
recommend_flag as recommendFlag,
|
|
|
|
|
|
sort_num as sortNum,
|
|
|
|
|
|
revision,
|
|
|
|
|
|
create_by as createBy,
|
|
|
|
|
|
create_time as createTime,
|
|
|
|
|
|
update_by as updateBy,
|
|
|
|
|
|
update_time as updateTime,
|
|
|
|
|
|
remark
|
|
|
|
|
|
from menu_recipe_dishes
|
|
|
|
|
|
where id in
|
|
|
|
|
|
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
|
|
|
|
|
#{id}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="selectAppRecipeList" resultType="com.bonus.canteen.core.menu.domain.MenuAppRecipe">
|
|
|
|
|
|
select
|
2025-04-14 23:16:37 +08:00
|
|
|
|
DISTINCT
|
2025-04-14 18:01:27 +08:00
|
|
|
|
recipe_id as recipeId,
|
|
|
|
|
|
bind_type as bindType,
|
|
|
|
|
|
meal_line_id as mealLineId,
|
|
|
|
|
|
bind_time as bindTime
|
|
|
|
|
|
from menu_app_recipe
|
|
|
|
|
|
where recipe_id = #{recipeId}
|
|
|
|
|
|
</select>
|
2025-04-14 23:16:37 +08:00
|
|
|
|
<select id="getDetail" resultMap="menuRecipeDetailDateVO">
|
|
|
|
|
|
select DISTINCT
|
|
|
|
|
|
mrd.mealtime_type,
|
2025-04-14 20:22:57 +08:00
|
|
|
|
mrd.detail_id,
|
|
|
|
|
|
mdb.base_dishes_id as dishes_id,
|
|
|
|
|
|
mdb.dishes_name,
|
|
|
|
|
|
mrdd.id,
|
|
|
|
|
|
mrdd.price,
|
|
|
|
|
|
mrdd.size_type,
|
|
|
|
|
|
mrdd.supply_num,
|
|
|
|
|
|
mrdd.sale_num,
|
|
|
|
|
|
mrdd.surplus_num,
|
|
|
|
|
|
mrdd.restrict_num,
|
|
|
|
|
|
mrdd.sale_price,
|
|
|
|
|
|
mrdd.recommend_flag,
|
|
|
|
|
|
mrdd.sort_num,
|
|
|
|
|
|
ac.canteen_name,
|
|
|
|
|
|
md.sales_mode,
|
|
|
|
|
|
md.unit_price,
|
|
|
|
|
|
md.meal_type,
|
|
|
|
|
|
md.dishes_num,
|
|
|
|
|
|
md.type_id,
|
|
|
|
|
|
mdt.type_name,
|
|
|
|
|
|
md.material_cost
|
|
|
|
|
|
from menu_recipe_detail mrd
|
|
|
|
|
|
left join menu_recipe_dishes mrdd on mrd.detail_id = mrdd.detail_id
|
|
|
|
|
|
left join menu_dishes md on mrdd.dishes_id = md.dishes_id
|
|
|
|
|
|
left join alloc_canteen ac on md.canteen_id = ac.canteen_id
|
|
|
|
|
|
left join menu_dishes_base mdb on md.base_dishes_id = mdb.base_dishes_id
|
|
|
|
|
|
left join menu_dishes_type mdt on md.type_id = mdt.type_id
|
|
|
|
|
|
where mrd.recipe_id = #{params.recipeId}
|
2025-04-14 23:16:37 +08:00
|
|
|
|
<if test="params.applyWeek !=null and params.applyWeek != ''">
|
2025-04-14 20:22:57 +08:00
|
|
|
|
and mrd.apply_week = #{params.applyWeek}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
and mrd.detail_type = 1
|
|
|
|
|
|
order by mrdd.sort_num
|
|
|
|
|
|
</select>
|
2025-04-14 23:16:37 +08:00
|
|
|
|
|
2025-04-14 20:22:57 +08:00
|
|
|
|
<select id="getRecipeBindCount" resultType="java.lang.Integer">
|
|
|
|
|
|
select DISTINCT
|
|
|
|
|
|
count(device_id)
|
|
|
|
|
|
from device_recipe
|
|
|
|
|
|
where recipe_id = #{recipeId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getDetailIdList" resultType="java.lang.Long">
|
|
|
|
|
|
select
|
|
|
|
|
|
detail_id as detailId
|
|
|
|
|
|
from menu_recipe_detail
|
|
|
|
|
|
where recipe_id = #{recipeId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="selectMenuAppRecipeCount" resultType="java.lang.Integer">
|
|
|
|
|
|
select
|
|
|
|
|
|
count(1)
|
|
|
|
|
|
from menu_app_recipe
|
|
|
|
|
|
where recipe_id = #{recipeId}
|
|
|
|
|
|
</select>
|
2025-04-14 23:16:37 +08:00
|
|
|
|
<select id="selectTypeDishesList" resultType="com.bonus.canteen.core.menu.vo.MenuAllTypeDishesVO">
|
|
|
|
|
|
select
|
|
|
|
|
|
mdb.base_dishes_id as dishes_id,
|
|
|
|
|
|
mdb.dishes_name,
|
|
|
|
|
|
md.price,
|
|
|
|
|
|
ac.canteen_name,
|
|
|
|
|
|
ass.stall_name,
|
|
|
|
|
|
aa.area_name,
|
|
|
|
|
|
md.sales_mode,
|
|
|
|
|
|
md.size_type,
|
|
|
|
|
|
md.public_dishes,
|
|
|
|
|
|
md.unit_price,
|
|
|
|
|
|
md.little_price,
|
|
|
|
|
|
md.large_price,
|
|
|
|
|
|
md.material_cost,
|
|
|
|
|
|
md.meal_type,
|
|
|
|
|
|
md.type_id,
|
|
|
|
|
|
mdt.type_name,
|
|
|
|
|
|
md.dishes_num
|
|
|
|
|
|
from
|
|
|
|
|
|
menu_dishes_base mdb
|
|
|
|
|
|
left join menu_dishes md on mdb.base_dishes_id = md.base_dishes_id
|
|
|
|
|
|
and md.size_json != '{"sizeType":"小份"}'
|
|
|
|
|
|
left join alloc_area aa on aa.area_id = md.area_id
|
|
|
|
|
|
left join alloc_canteen ac on md.canteen_id = ac.canteen_id
|
|
|
|
|
|
left join alloc_stall ass on ass.stall_id = md.shopstall_id
|
|
|
|
|
|
left join menu_dishes_type mdt on md.type_id = mdt.type_id
|
|
|
|
|
|
where
|
|
|
|
|
|
1 =1
|
|
|
|
|
|
<if test="typeId != null">
|
|
|
|
|
|
and md.type_id = #{typeId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="canteenId != null and stallId != null and areaId != null">
|
|
|
|
|
|
and(
|
|
|
|
|
|
(md.canteen_id = #{canteenId} and md.shopstall_id = #{stallId})
|
|
|
|
|
|
or (md.canteen_id = #{canteenId} and md.shopstall_id = -1)
|
|
|
|
|
|
or (md.canteen_id = -1 and md.shopstall_id = -1 and md.area_id = #{areaId})
|
|
|
|
|
|
or (md.canteen_id = -1 and md.shopstall_id = -1 and md.area_id = -1)
|
|
|
|
|
|
)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="areaIds != null and areaIds.size >0">
|
|
|
|
|
|
and md.area_id in
|
|
|
|
|
|
<foreach collection="areaIds" item="areaId" open="(" separator="," close=")">
|
|
|
|
|
|
#{areaId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="canteenIds != null and canteenIds.size >0">
|
|
|
|
|
|
and md.canteen_id in
|
|
|
|
|
|
<foreach collection="canteenIds" item="canteenId" open="(" separator="," close=")">
|
|
|
|
|
|
#{canteenId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="stallIds != null and stallIds.size >0">
|
|
|
|
|
|
and md.shopstall_id in
|
|
|
|
|
|
<foreach collection="stallIds" item="stallId" open="(" separator="," close=")">
|
|
|
|
|
|
#{stallId}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="dishesName != null and dishesName != ''">
|
|
|
|
|
|
and (md.dishes_name like #{dishesName}
|
|
|
|
|
|
or md.pinyin_full like #{dishesName}
|
|
|
|
|
|
or md.pinyin_initials like #{dishesName})
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="salesMode != null">
|
|
|
|
|
|
and md.sales_mode = #{salesMode}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<resultMap id="menuRecipeDetailDateVO" type="com.bonus.canteen.core.menu.vo.MenuRecipeDetailDateVO">
|
|
|
|
|
|
<result property="mealtimeType" column="mealtime_type"/>
|
|
|
|
|
|
<result property="detailId" column="detail_id"/>
|
|
|
|
|
|
<collection property="dishesList" ofType="com.bonus.canteen.core.menu.vo.MenuRecipeDetailDishesVO">
|
|
|
|
|
|
<result property="id" column="id"/>
|
|
|
|
|
|
<result property="dishesId" column="dishes_id"/>
|
|
|
|
|
|
<result property="dishesName" column="dishes_name"/>
|
|
|
|
|
|
<result property="price" column="price"/>
|
|
|
|
|
|
<result property="sizeType" column="size_type"/>
|
|
|
|
|
|
<result property="supplyNum" column="supply_num"/>
|
|
|
|
|
|
<result property="saleNum" column="sale_num"/>
|
|
|
|
|
|
<result property="surplusNum" column="surplus_num"/>
|
|
|
|
|
|
<result property="restrictNum" column="restrict_num"/>
|
|
|
|
|
|
<result property="salePrice" column="sale_price"/>
|
|
|
|
|
|
<result property="recommendFlag" column="recommend_flag"/>
|
|
|
|
|
|
<result property="canteenName" column="canteen_name"/>
|
|
|
|
|
|
<result property="salesMode" column="sales_mode"/>
|
|
|
|
|
|
<result property="unitPrice" column="unit_price"/>
|
|
|
|
|
|
<result property="mealType" column="meal_type"/>
|
|
|
|
|
|
<result property="dishesNum" column="dishes_num"/>
|
|
|
|
|
|
<result property="materialCost" column="material_cost"/>
|
|
|
|
|
|
<result property="sortNum" column="sort_num"/>
|
|
|
|
|
|
<result property="typeId" column="type_id"/>
|
|
|
|
|
|
<result property="typeName" column="type_name"/>
|
|
|
|
|
|
</collection>
|
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
<!-- 获取指定日期菜谱详情 -->
|
|
|
|
|
|
<select id="selectDateDetailList" resultMap="menuRecipeDetailDateVO">
|
|
|
|
|
|
select mrd.mealtime_type,
|
|
|
|
|
|
mrd.detail_id,
|
|
|
|
|
|
mdb.base_dishes_id as dishes_id,
|
|
|
|
|
|
mdb.dishes_name,
|
|
|
|
|
|
mrdd.id,
|
|
|
|
|
|
mrdd.price,
|
|
|
|
|
|
mrdd.size_type,
|
|
|
|
|
|
mrdd.supply_num,
|
|
|
|
|
|
mrdd.sale_num,
|
|
|
|
|
|
mrdd.surplus_num,
|
|
|
|
|
|
mrdd.restrict_num,
|
|
|
|
|
|
mrdd.sale_price,
|
|
|
|
|
|
mrdd.recommend_flag,
|
|
|
|
|
|
mrdd.sort_num,
|
|
|
|
|
|
ac.canteen_name,
|
|
|
|
|
|
md.sales_mode,
|
|
|
|
|
|
md.unit_price,
|
|
|
|
|
|
md.meal_type,
|
|
|
|
|
|
md.dishes_num,
|
|
|
|
|
|
md.type_id,
|
|
|
|
|
|
mdt.type_name,
|
|
|
|
|
|
md.material_cost
|
|
|
|
|
|
from menu_recipe_detail mrd
|
|
|
|
|
|
left join menu_recipe_dishes mrdd on mrd.detail_id = mrdd.detail_id
|
|
|
|
|
|
left join menu_dishes md on mrdd.dishes_id = md.dishes_id
|
|
|
|
|
|
left join alloc_canteen ac on md.canteen_id = ac.canteen_id
|
|
|
|
|
|
left join menu_dishes_base mdb on md.base_dishes_id = mdb.base_dishes_id
|
|
|
|
|
|
left join menu_dishes_type mdt on md.type_id = mdt.type_id
|
|
|
|
|
|
where mrd.recipe_id = #{recipeId}
|
|
|
|
|
|
and mrd.apply_date = #{applyDate}
|
|
|
|
|
|
order by mrdd.sort_num
|
|
|
|
|
|
</select>
|
2025-04-05 19:12:26 +08:00
|
|
|
|
<insert id="insertMenuRecipe" parameterType="com.bonus.canteen.core.menu.domain.MenuRecipe" useGeneratedKeys="true" keyProperty="id">
|
2025-04-03 15:06:05 +08:00
|
|
|
|
insert into menu_recipe
|
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="recipeId != null">recipe_id,</if>
|
|
|
|
|
|
<if test="planId != null">plan_id,</if>
|
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">recipe_name,</if>
|
|
|
|
|
|
<if test="isDefault != null">is_default,</if>
|
|
|
|
|
|
<if test="recipeType != null">recipe_type,</if>
|
|
|
|
|
|
<if test="effectDate != null">effect_date,</if>
|
|
|
|
|
|
<if test="expireDate != null">expire_date,</if>
|
|
|
|
|
|
<if test="canteenId != null">canteen_id,</if>
|
|
|
|
|
|
<if test="stallId != null">stall_id,</if>
|
|
|
|
|
|
<if test="enableFlag != null">enable_flag,</if>
|
|
|
|
|
|
<if test="revision != null">revision,</if>
|
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="recipeId != null">#{recipeId},</if>
|
|
|
|
|
|
<if test="planId != null">#{planId},</if>
|
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">#{recipeName},</if>
|
|
|
|
|
|
<if test="isDefault != null">#{isDefault},</if>
|
|
|
|
|
|
<if test="recipeType != null">#{recipeType},</if>
|
|
|
|
|
|
<if test="effectDate != null">#{effectDate},</if>
|
|
|
|
|
|
<if test="expireDate != null">#{expireDate},</if>
|
|
|
|
|
|
<if test="canteenId != null">#{canteenId},</if>
|
|
|
|
|
|
<if test="stallId != null">#{stallId},</if>
|
|
|
|
|
|
<if test="enableFlag != null">#{enableFlag},</if>
|
|
|
|
|
|
<if test="revision != null">#{revision},</if>
|
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
</insert>
|
2025-04-14 18:01:27 +08:00
|
|
|
|
<insert id="insertData">
|
|
|
|
|
|
insert into menu_recipe
|
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="recipeId != null">recipe_id,</if>
|
|
|
|
|
|
<if test="planId != null">plan_id,</if>
|
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">recipe_name,</if>
|
|
|
|
|
|
<if test="isDefault != null">is_default,</if>
|
|
|
|
|
|
<if test="recipeType != null">recipe_type,</if>
|
|
|
|
|
|
<if test="effectDate != null">effect_date,</if>
|
|
|
|
|
|
<if test="expireDate != null">expire_date,</if>
|
|
|
|
|
|
<if test="canteenId != null">canteen_id,</if>
|
|
|
|
|
|
<if test="stallId != null">stall_id,</if>
|
|
|
|
|
|
<if test="enableFlag != null">enable_flag,</if>
|
|
|
|
|
|
<if test="revision != null">revision,</if>
|
|
|
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
|
<if test="remark != null">remark,</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="recipeId != null">#{recipeId},</if>
|
|
|
|
|
|
<if test="planId != null">#{planId},</if>
|
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">#{recipeName},</if>
|
|
|
|
|
|
<if test="isDefault != null">#{isDefault},</if>
|
|
|
|
|
|
<if test="recipeType != null">#{recipeType},</if>
|
|
|
|
|
|
<if test="effectDate != null">#{effectDate},</if>
|
|
|
|
|
|
<if test="expireDate != null">#{expireDate},</if>
|
|
|
|
|
|
<if test="canteenId != null">#{canteenId},</if>
|
|
|
|
|
|
<if test="stallId != null">#{stallId},</if>
|
|
|
|
|
|
<if test="enableFlag != null">#{enableFlag},</if>
|
|
|
|
|
|
<if test="revision != null">#{revision},</if>
|
|
|
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
|
<if test="remark != null">#{remark},</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
<insert id="insertMenuDetails">
|
|
|
|
|
|
insert into menu_recipe_detail
|
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="menuDetails[0].detailId != null">detail_id,</if>
|
|
|
|
|
|
<if test="menuDetails[0].saleTypeId != null">sale_type_id,</if>
|
|
|
|
|
|
<if test="menuDetails[0].recipeId != null">recipe_id,</if>
|
|
|
|
|
|
<if test="menuDetails[0].applyDate != null">apply_date,</if>
|
|
|
|
|
|
<if test="menuDetails[0].applyWeek != null">apply_week,</if>
|
|
|
|
|
|
<if test="menuDetails[0].mealtimeType != null">mealtime_type,</if>
|
|
|
|
|
|
<if test="menuDetails[0].detailType != null">detail_type,</if>
|
|
|
|
|
|
<if test="menuDetails[0].revision != null">revision,</if>
|
|
|
|
|
|
<if test="menuDetails[0].createBy != null">create_by,</if>
|
|
|
|
|
|
<if test="menuDetails[0].createTime != null">create_time,</if>
|
|
|
|
|
|
<if test="menuDetails[0].updateBy != null">update_by,</if>
|
|
|
|
|
|
<if test="menuDetails[0].updateTime != null">update_time,</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
values
|
|
|
|
|
|
<foreach collection="menuDetails" item="menuDetail" separator=",">
|
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="menuDetails[0].detailId != null">#{menuDetail.detailId},</if>
|
|
|
|
|
|
<if test="menuDetails[0].saleTypeId != null">#{menuDetail.saleTypeId},</if>
|
|
|
|
|
|
<if test="menuDetails[0].recipeId != null">#{menuDetail.recipeId},</if>
|
|
|
|
|
|
<if test="menuDetails[0].applyDate != null">#{menuDetail.applyDate},</if>
|
|
|
|
|
|
<if test="menuDetails[0].applyWeek != null">#{menuDetail.applyWeek},</if>
|
|
|
|
|
|
<if test="menuDetails[0].mealtimeType != null">#{menuDetail.mealtimeType},</if>
|
|
|
|
|
|
<if test="menuDetails[0].detailType != null">#{menuDetail.detailType},</if>
|
|
|
|
|
|
<if test="menuDetails[0].revision != null">#{menuDetail.revision},</if>
|
|
|
|
|
|
<if test="menuDetails[0].createBy != null">#{menuDetail.createBy},</if>
|
|
|
|
|
|
<if test="menuDetails[0].createTime != null">#{menuDetail.createTime},</if>
|
|
|
|
|
|
<if test="menuDetails[0].updateBy != null">#{menuDetail.updateBy},</if>
|
|
|
|
|
|
<if test="menuDetails[0].updateTime != null">#{menuDetail.updateTime},</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
<insert id="insertMenuDishes">
|
|
|
|
|
|
insert into menu_recipe_dishes
|
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="menuDishes[0].detailId != null">detail_id,</if>
|
|
|
|
|
|
<if test="menuDishes[0].dishesId != null">dishes_id,</if>
|
|
|
|
|
|
<if test="menuDishes[0].price != null">price,</if>
|
|
|
|
|
|
<if test="menuDishes[0].sizeType != null">size_type,</if>
|
|
|
|
|
|
<if test="menuDishes[0].supplyNum != null">supply_num,</if>
|
|
|
|
|
|
<if test="menuDishes[0].saleNum != null">sale_num,</if>
|
|
|
|
|
|
<if test="menuDishes[0].surplusNum != null">surplus_num,</if>
|
|
|
|
|
|
<if test="menuDishes[0].restrictNum != null">restrict_num,</if>
|
|
|
|
|
|
<if test="menuDishes[0].salePrice != null">sale_price,</if>
|
|
|
|
|
|
<if test="menuDishes[0].recommendFlag != null">recommend_flag,</if>
|
|
|
|
|
|
<if test="menuDishes[0].sortNum != null">sort_num,</if>
|
|
|
|
|
|
<if test="menuDishes[0].revision != null">revision,</if>
|
|
|
|
|
|
<if test="menuDishes[0].createBy != null">create_by,</if>
|
|
|
|
|
|
<if test="menuDishes[0].createTime != null">create_time,</if>
|
|
|
|
|
|
<if test="menuDishes[0].updateBy != null">update_by,</if>
|
|
|
|
|
|
<if test="menuDishes[0].updateTime != null">update_time,</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
values
|
|
|
|
|
|
<foreach collection="menuDishes" item="menuDish" separator=",">
|
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<if test="menuDishes[0].detailId != null">#{menuDish.detailId},</if>
|
|
|
|
|
|
<if test="menuDishes[0].dishesId != null">#{menuDish.dishesId},</if>
|
|
|
|
|
|
<if test="menuDishes[0].price != null">#{menuDish.price},</if>
|
|
|
|
|
|
<if test="menuDishes[0].sizeType != null">#{menuDish.sizeType},</if>
|
|
|
|
|
|
<if test="menuDishes[0].supplyNum != null">#{menuDish.supplyNum},</if>
|
|
|
|
|
|
<if test="menuDishes[0].saleNum != null">#{menuDish.saleNum},</if>
|
|
|
|
|
|
<if test="menuDishes[0].surplusNum != null">#{menuDish.surplusNum},</if>
|
|
|
|
|
|
<if test="menuDishes[0].restrictNum != null">#{menuDish.restrictNum},</if>
|
|
|
|
|
|
<if test="menuDishes[0].salePrice != null">#{menuDish.salePrice},</if>
|
|
|
|
|
|
<if test="menuDishes[0].recommendFlag != null">#{menuDish.recommendFlag},</if>
|
|
|
|
|
|
<if test="menuDishes[0].sortNum != null">#{menuDish.sortNum},</if>
|
|
|
|
|
|
<if test="menuDishes[0].revision != null">#{menuDish.revision},</if>
|
|
|
|
|
|
<if test="menuDishes[0].createBy != null">#{menuDish.createBy},</if>
|
|
|
|
|
|
<if test="menuDishes[0].createTime != null">#{menuDish.createTime},</if>
|
|
|
|
|
|
<if test="menuDishes[0].updateBy != null">#{menuDish.updateBy},</if>
|
|
|
|
|
|
<if test="menuDishes[0].updateTime != null">#{menuDish.updateTime},</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</insert>
|
2025-04-05 19:12:26 +08:00
|
|
|
|
<update id="updateMenuRecipe" parameterType="com.bonus.canteen.core.menu.domain.MenuRecipe">
|
2025-04-03 15:06:05 +08:00
|
|
|
|
update menu_recipe
|
|
|
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
|
|
|
<if test="recipeId != null">recipe_id = #{recipeId},</if>
|
|
|
|
|
|
<if test="planId != null">plan_id = #{planId},</if>
|
|
|
|
|
|
<if test="recipeName != null and recipeName != ''">recipe_name = #{recipeName},</if>
|
|
|
|
|
|
<if test="isDefault != null">is_default = #{isDefault},</if>
|
|
|
|
|
|
<if test="recipeType != null">recipe_type = #{recipeType},</if>
|
|
|
|
|
|
<if test="effectDate != null">effect_date = #{effectDate},</if>
|
|
|
|
|
|
<if test="expireDate != null">expire_date = #{expireDate},</if>
|
|
|
|
|
|
<if test="canteenId != null">canteen_id = #{canteenId},</if>
|
|
|
|
|
|
<if test="stallId != null">stall_id = #{stallId},</if>
|
|
|
|
|
|
<if test="enableFlag != null">enable_flag = #{enableFlag},</if>
|
|
|
|
|
|
<if test="revision != null">revision = #{revision},</if>
|
|
|
|
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
|
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
where id = #{id}
|
|
|
|
|
|
</update>
|
2025-04-14 18:01:27 +08:00
|
|
|
|
<update id="updateMenuRecipeDetail">
|
|
|
|
|
|
update menu_recipe_detail set update_time = #{time} where recipe_id = #{recipeId}
|
|
|
|
|
|
</update>
|
2025-04-03 15:06:05 +08:00
|
|
|
|
|
|
|
|
|
|
<delete id="deleteMenuRecipeById" parameterType="Long">
|
|
|
|
|
|
delete from menu_recipe where id = #{id}
|
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
|
|
<delete id="deleteMenuRecipeByIds" parameterType="String">
|
2025-04-14 23:58:26 +08:00
|
|
|
|
delete from menu_recipe where id in
|
2025-04-03 15:06:05 +08:00
|
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
|
|
#{id}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</delete>
|
2025-04-14 18:01:27 +08:00
|
|
|
|
<delete id="deleteMenuRecipeDetailByIds">
|
|
|
|
|
|
delete from menu_recipe_detail where id in
|
|
|
|
|
|
<foreach item="id" collection="list" open="(" separator="," close=")">
|
|
|
|
|
|
#{id}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteMenuRecipeDishesByIds">
|
|
|
|
|
|
delete from menu_recipe_dishes where id in
|
|
|
|
|
|
<foreach item="id" collection="list" open="(" separator="," close=")">
|
|
|
|
|
|
#{id}
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
</delete>
|
2025-04-14 23:58:26 +08:00
|
|
|
|
|
|
|
|
|
|
<select id="selectMenuRecipe" resultMap="MenuRecipeResult" parameterType="long">
|
|
|
|
|
|
select * from menu_recipe where recipe_id = #{recipeId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getCanNum" resultType="com.bonus.canteen.core.alloc.domain.AllocCanteen">
|
|
|
|
|
|
select canteen_id as canteenId,if_reserve as ifReserve from alloc_canteen
|
|
|
|
|
|
where canteen_id = #{canteenId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getStallNum" resultType="com.bonus.canteen.core.alloc.domain.AllocStall">
|
|
|
|
|
|
select stall_id as stallId,if_reserve as ifReserve from alloc_stall
|
|
|
|
|
|
where stall_id = #{areaId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="exists" resultType="boolean">
|
|
|
|
|
|
select count(1) > 0 from menu_app_recipe
|
|
|
|
|
|
where recipe_id = #{recipeId}
|
|
|
|
|
|
<if test="mealLineId !=null">
|
|
|
|
|
|
and meal_line_id = #{mealLineId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
and bind_type = #{bindType}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="selectRecipeInSameShop" resultType="java.lang.Long">
|
|
|
|
|
|
select mar.recipe_id
|
|
|
|
|
|
from menu_app_recipe mar
|
|
|
|
|
|
inner join menu_recipe mr on mar.recipe_id = mr.recipe_id
|
|
|
|
|
|
where mar.bind_type = #{bindType}
|
|
|
|
|
|
and mr.stall_id = #{stallId}
|
|
|
|
|
|
<if test="effId !=null">
|
|
|
|
|
|
and mr.eff_id = #{effId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="mealLineId !=null">
|
|
|
|
|
|
and mar.meal_line_id= #{mealLineId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<delete id="delete" parameterType="com.bonus.canteen.core.menu.domain.MenuAppRecipe">
|
|
|
|
|
|
delete from menu_app_recipe where recipe_id = #{recipeId}
|
|
|
|
|
|
<if test="mealLineId != null">
|
|
|
|
|
|
and meal_line_id = #{mealLineId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
and bind_type = #{bindType}
|
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
|
|
<insert id="insert" parameterType="com.bonus.canteen.core.menu.domain.MenuAppRecipe">
|
|
|
|
|
|
|
|
|
|
|
|
insert into menu_app_recipe (recipe_id,bind_type,bind_time,meal_line_id)
|
|
|
|
|
|
values (#{recipeId},#{bindType},now(),#{mealLineId})
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
</mapper>
|
|
|
|
|
|
|