diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java index a7f4edb..ffb466c 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/mapper/SupermarketProductMapper.java @@ -18,6 +18,8 @@ public interface SupermarketProductMapper { */ public SupermarketProduct selectSupermarketProductByProductId(Long productId); + public List selectSupermarketProductByMaterialIds(Long[] materialIds); + /** * 查询超市商城商品列表 * diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketMaterialServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketMaterialServiceImpl.java index a4e38bd..a0bb2b1 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketMaterialServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/supermarket/service/impl/SupermarketMaterialServiceImpl.java @@ -1,6 +1,9 @@ package com.bonus.canteen.core.supermarket.service.impl; import java.util.List; + +import com.bonus.canteen.core.supermarket.domain.SupermarketProduct; +import com.bonus.canteen.core.supermarket.mapper.SupermarketProductMapper; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -8,6 +11,7 @@ import org.springframework.stereotype.Service; import com.bonus.canteen.core.supermarket.mapper.SupermarketMaterialMapper; import com.bonus.canteen.core.supermarket.domain.SupermarketMaterial; import com.bonus.canteen.core.supermarket.service.ISupermarketMaterialService; +import org.springframework.util.CollectionUtils; /** * 商品信息Service业务层处理 @@ -19,6 +23,8 @@ import com.bonus.canteen.core.supermarket.service.ISupermarketMaterialService; public class SupermarketMaterialServiceImpl implements ISupermarketMaterialService { @Autowired private SupermarketMaterialMapper supermarketMaterialMapper; + @Autowired + private SupermarketProductMapper supermarketProductMapper; /** * 查询商品信息 @@ -82,6 +88,10 @@ public class SupermarketMaterialServiceImpl implements ISupermarketMaterialServi */ @Override public int deleteSupermarketMaterialByMaterialIds(Long[] materialIds) { + List list = supermarketProductMapper.selectSupermarketProductByMaterialIds(materialIds); + if (!CollectionUtils.isEmpty(list)) { + throw new ServiceException("该原料下含有商品,不能删除"); + } return supermarketMaterialMapper.deleteSupermarketMaterialByMaterialIds(materialIds); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookDishesMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookDishesMapper.xml index 3751faf..980dcd5 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookDishesMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookDishesMapper.xml @@ -165,7 +165,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and cd.glycemic_index = #{glycemicIndex} and cd.sort = #{sort} and cd.canteen_id = #{canteenId} - and cd.shopstall_id = #{stallId} + and (cd.shopstall_id = #{stallId} or cd.shopstall_id is null or cd.shopstall_id == '') and cd.hide_flag = #{hideFlag} and cd.convert_flag = #{convertFlag} and cd.material_cost = #{materialCost} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookH5Mapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookH5Mapper.xml index ff8587c..af20f52 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookH5Mapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/cook/CookH5Mapper.xml @@ -139,7 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 - bind_type = 2 + bind_type = 2 and mr.del_flag = '0' @@ -45,6 +47,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where product_id = #{productId} + + insert into supermarket_product