From 7fa5b3d685e5c37fd6115196fc3438068d240664 Mon Sep 17 00:00:00 2001 From: skjia <106962133@qq.com> Date: Thu, 20 Feb 2025 15:14:34 +0800 Subject: [PATCH] =?UTF-8?q?jsk=20=20=20getReserveMealCanteenList=20=20?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/allocation/api/AllocCanteenApi.java | 7 +- .../canteen/service/AllocCanteenService.java | 3 + .../service/impl/AllocCanteenServiceImpl.java | 69 +++++++++++++++++-- .../service/impl/MenuRecipeServiceImpl.java | 7 ++ 4 files changed, 79 insertions(+), 7 deletions(-) diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocCanteenApi.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocCanteenApi.java index bbb1d9c2..f7837bfe 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocCanteenApi.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/api/AllocCanteenApi.java @@ -10,6 +10,7 @@ import com.bonus.core.allocation.canteen.service.AllocAreaService; import com.bonus.core.allocation.canteen.service.AllocCanteenService; import com.bonus.core.allocation.canteen.service.AllocMealLineService; import com.bonus.core.allocation.canteen.vo.AllocAreaFullNameVO; +import com.bonus.core.menu.vo.AppletReserveCanteenVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -145,9 +146,9 @@ public class AllocCanteenApi { // return this.allocCanteenService.checkCanteenIfReserve(canteenId, stallId); // } // -// public void checkAndDelReserveCanteen(List reserveCanteenList) { -// this.allocCanteenService.checkAndDelReserveCanteen(reserveCanteenList); -// } + public void checkAndDelReserveCanteen(List reserveCanteenList) { + this.allocCanteenService.checkAndDelReserveCanteen(reserveCanteenList); + } // // public boolean checkCanteenBookExist() { // long bookNum = this.allocCanteenService.count((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(AllocCanteen.class).eq(AllocCanteen::getIfBook, LeConstants.COMMON_YES)).eq(AllocCanteen::getIfDel, LeConstants.COMMON_NO)); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocCanteenService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocCanteenService.java index 99115b87..3c4d4ce1 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocCanteenService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/AllocCanteenService.java @@ -3,6 +3,7 @@ package com.bonus.core.allocation.canteen.service; import com.baomidou.mybatisplus.extension.service.IService; import com.bonus.core.allocation.canteen.model.AllocCanteen; import com.bonus.core.allocation.canteen.vo.AllocCanteenStallVO; +import com.bonus.core.menu.vo.AppletReserveCanteenVO; import java.util.List; @@ -12,4 +13,6 @@ public interface AllocCanteenService extends IService { List getCanteenIdListByAreaIdList(List areaIdList); List listAllCanteenStall(); + + void checkAndDelReserveCanteen(List reserveCanteenList); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java index c0644bf4..1162d252 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java @@ -1,16 +1,22 @@ package com.bonus.core.allocation.canteen.service.impl; import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.bonus.constant.LeConstants; import com.bonus.core.allocation.api.AllocPayMetadataApi; import com.bonus.core.allocation.canteen.mapper.AllocCanteenMapper; import com.bonus.core.allocation.canteen.mapper.AllocStallMapper; import com.bonus.core.allocation.canteen.model.AllocCanteen; +import com.bonus.core.allocation.canteen.model.AllocStall; import com.bonus.core.allocation.canteen.service.AllocAreaService; import com.bonus.core.allocation.canteen.service.AllocCanteenService; import com.bonus.core.allocation.canteen.vo.AllocCanteenStallVO; import com.bonus.core.common.enums.AllocCanteenTypeEnum; +import com.bonus.core.menu.vo.AppletReserveCanteenVO; +import com.bonus.core.menu.vo.AppletReserveStallVO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -18,10 +24,8 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; @Service public class AllocCanteenServiceImpl extends ServiceImpl implements AllocCanteenService { @@ -61,6 +65,7 @@ public class AllocCanteenServiceImpl extends ServiceImpl listAllCanteenStall() { List canteenList = ((AllocCanteenMapper)this.baseMapper).listAllCanteenStall(LeConstants.COMMON_NO, AllocCanteenTypeEnum.CANTEEN.getKey()); if (CollUtil.isEmpty(canteenList)) { @@ -72,4 +77,60 @@ public class AllocCanteenServiceImpl extends ServiceImpl reserveCanteenList) { + List canteenIdList = new ArrayList(); + List stallIdList = new ArrayList(); + Iterator var4 = reserveCanteenList.iterator(); + + while(true) { + AppletReserveCanteenVO reserveCanteen; + do { + if (!var4.hasNext()) { + List allocCanteenList = this.list((Wrapper) Wrappers.lambdaQuery(AllocCanteen.class).select(AllocCanteen::getCanteenId, AllocCanteen::getIfReserve).in(AllocCanteen::getCanteenId, canteenIdList)); + Map allocCanteenMap = (Map)allocCanteenList.stream().collect(Collectors.toMap(AllocCanteen::getCanteenId, AllocCanteen::getIfReserve)); + Map allocStallMap = new HashMap(); + if (CollUtil.isNotEmpty(stallIdList)) { + List allocStallList = this.allocStallMapper.selectList((Wrapper)Wrappers.lambdaQuery(AllocStall.class).select(AllocStall::getStallId, AllocStall::getIfReserve).in(AllocStall::getStallId, stallIdList)); + allocStallMap = (Map)allocStallList.stream().collect(Collectors.toMap(AllocStall::getStallId, AllocStall::getIfReserve)); + } + + Iterator canteenIterator = reserveCanteenList.iterator(); + + while(true) { + while(canteenIterator.hasNext()) { + AppletReserveCanteenVO reserveCanteenVO = (AppletReserveCanteenVO)canteenIterator.next(); + Integer canteenIfReserve = (Integer)allocCanteenMap.get(reserveCanteenVO.getCanteenId()); + if (!LeConstants.COMMON_YES.equals(canteenIfReserve)) { + canteenIterator.remove(); + } else if (CollUtil.isNotEmpty(reserveCanteenVO.getStallList())) { + Iterator stallIterator = reserveCanteenVO.getStallList().iterator(); + + while(stallIterator.hasNext()) { + AppletReserveStallVO reserveStallVO = (AppletReserveStallVO)stallIterator.next(); + Integer stallIfReserve = (Integer)((Map)allocStallMap).get(reserveStallVO.getStallId()); + if (!LeConstants.COMMON_YES.equals(stallIfReserve)) { + stallIterator.remove(); + } + } + } + } + + return; + } + } + + reserveCanteen = (AppletReserveCanteenVO)var4.next(); + canteenIdList.add(reserveCanteen.getCanteenId()); + } while(!CollUtil.isNotEmpty(reserveCanteen.getStallList())); + + Iterator var6 = reserveCanteen.getStallList().iterator(); + + while(var6.hasNext()) { + AppletReserveStallVO reserveStall = (AppletReserveStallVO)var6.next(); + stallIdList.add(reserveStall.getStallId()); + } + } + } } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuRecipeServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuRecipeServiceImpl.java index d9a7e62e..942ab8c4 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuRecipeServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/core/menu/service/impl/MenuRecipeServiceImpl.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.bonus.common.core.exception.ServiceException; import com.bonus.constant.DelFlagEnum; +import com.bonus.core.allocation.api.AllocCanteenApi; import com.bonus.core.allocation.api.AllocDeliveryApi; import com.bonus.core.allocation.api.AllocMealtimeApi; import com.bonus.core.allocation.canteen.model.AllocDeliveryCostModel; @@ -101,6 +102,9 @@ public class MenuRecipeServiceImpl extends ServiceImpl getWeekMealList(AppletWeekCanteenDTO content) { Set effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false); @@ -179,10 +183,12 @@ public class MenuRecipeServiceImpl extends ServiceImpl resultList = this.menuAppRecipeMapper.selectReserveMealCanteenList((Set)effIdSet); if (ObjectUtil.isEmpty(resultList)) { return resultList; } else { + this.allocCanteenApi.checkAndDelReserveCanteen(resultList); List stallIdList = (List)resultList.stream().flatMap((canteen) -> { return canteen.getStallList().stream().map(AppletReserveStallVO::getStallId); }).collect(Collectors.toList()); @@ -461,6 +467,7 @@ public class MenuRecipeServiceImpl extends ServiceImpl changeSurplusNum(List changeSurplusNumList, Long custId, Integer mealtimeType, LocalDate ordGoodsDate) { this.checkChangeSurplusNum(changeSurplusNumList, ordGoodsDate, mealtimeType);