Compare commits

..

No commits in common. "3960eebac267559115a44ffe5da5eb502aaaec73" and "affb765dcf52ee8b00cd8097eb213351dbb59bb1" have entirely different histories.

3 changed files with 52 additions and 48 deletions

View File

@ -7,8 +7,12 @@ import lombok.Data;
*/ */
@Data @Data
public class CookDishCheckDTO { public class CookDishCheckDTO {
/** 食堂id */
private Long canteenId;
/** 档口id */
private Long stallId;
/** 供应日期 */ /** 供应日期 */
private String applyDate; private String applyDate;
/** 适用类型 */
private Long recipeId; private Integer applyType;
} }

View File

@ -1,12 +1,12 @@
package com.bonus.canteen.core.order.module; package com.bonus.canteen.core.order.module;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.bonus.canteen.core.cook.dto.AllocRecipeStallDTO;
import com.bonus.canteen.core.cook.dto.CookH5ReserveRecipeDTO;
import com.bonus.canteen.core.cook.dto.CookRecipeDTO; import com.bonus.canteen.core.cook.dto.CookRecipeDTO;
import com.bonus.canteen.core.cook.service.ICookH5Service;
import com.bonus.canteen.core.cook.service.ICookRecipeService; import com.bonus.canteen.core.cook.service.ICookRecipeService;
import com.bonus.canteen.core.cook.vo.*; import com.bonus.canteen.core.cook.vo.CookRecipeDateVO;
import com.bonus.canteen.core.cook.vo.CookRecipeDetailVO;
import com.bonus.canteen.core.cook.vo.CookRecipeDishesVO;
import com.bonus.canteen.core.cook.vo.CookRecipeVO;
import com.bonus.canteen.core.order.domain.CookDishCheckDTO; import com.bonus.canteen.core.order.domain.CookDishCheckDTO;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -18,23 +18,37 @@ import java.util.*;
@Component @Component
public class MenuModule { public class MenuModule {
@Autowired @Autowired
private ICookH5Service cookH5Service; private ICookRecipeService cookRecipeService;
public Map<Integer, List<CookH5ReserveRecipeDishesVO>> getMenuRecipeDish(CookDishCheckDTO cookDishCheckDTO) { public Map<Long, List<CookRecipeDishesVO>> getMenuRecipeDish(CookDishCheckDTO cookDishCheckDTO) {
CookH5ReserveRecipeDTO cookH5ReserveRecipeDTO = new CookH5ReserveRecipeDTO(); CookRecipeDTO menurecipe = new CookRecipeDTO();
cookH5ReserveRecipeDTO.setApplyDate(LocalDate.parse(cookDishCheckDTO.getApplyDate())); menurecipe.setApplyDate(LocalDate.parse(cookDishCheckDTO.getApplyDate()));
cookH5ReserveRecipeDTO.setRecipeId(cookDishCheckDTO.getRecipeId()); menurecipe.setCanteenId(cookDishCheckDTO.getCanteenId());
Map<Integer, List<CookH5ReserveRecipeDishesVO>> mealTimeTypeMap = new HashMap<>(); menurecipe.setStallId(cookDishCheckDTO.getStallId());
List<CookH5ReserveRecipeDetailsVO> cookRecipeList = cookH5Service.getReserveRecipeDetailList(cookH5ReserveRecipeDTO); menurecipe.setKey(cookDishCheckDTO.getApplyType());
if (CollUtil.isNotEmpty(cookRecipeList)) { Map<Long, List<CookRecipeDishesVO>> mealTimeTypeMap = new HashMap<>();
for (CookH5ReserveRecipeDetailsVO cookRecipeDetailVO : cookRecipeList) { List<CookRecipeVO> menuRecipeList = cookRecipeService.selectCookRecipeList4Current(menurecipe);
if(Objects.nonNull(cookRecipeDetailVO.getMealtimeType()) && CollUtil.isNotEmpty(cookRecipeDetailVO.getTypeList())) { if (CollUtil.isNotEmpty(menuRecipeList) && menuRecipeList.size() == 1) {
List<CookH5ReserveRecipeDishesVO> allDishesList = new ArrayList<>(); List<CookRecipeDateVO> recipeDateList = menuRecipeList.get(0).getRecipeDateList();
for(CookH5ReserveRecipeTypeVO typeVO : cookRecipeDetailVO.getTypeList()) { if(CollUtil.isNotEmpty(recipeDateList) && recipeDateList.size() == 1) {
allDishesList.addAll(typeVO.getDishesList()); List<CookRecipeDetailVO> cookRecipeDetail = recipeDateList.get(0).getDetailList();
if(CollUtil.isNotEmpty(cookRecipeDetail)) {
Long mealType = null;
List<CookRecipeDishesVO> dishsIdList = new ArrayList<>();
for (CookRecipeDetailVO cookRecipeDetailVO : cookRecipeDetail) {
mealType = cookRecipeDetailVO.getMealtimeType();
if(CollUtil.isNotEmpty(cookRecipeDetailVO.getDishesList())) {
dishsIdList.addAll(cookRecipeDetailVO.getDishesList());
}
} }
mealTimeTypeMap.put(cookRecipeDetailVO.getMealtimeType(), allDishesList); if(Objects.nonNull(mealType)) {
mealTimeTypeMap.put(mealType, dishsIdList);
}
}else {
throw new ServiceException("菜谱信息异常");
} }
}else {
throw new ServiceException("菜谱信息异常");
} }
}else { }else {
throw new ServiceException("菜谱信息异常"); throw new ServiceException("菜谱信息异常");

View File

@ -3,9 +3,6 @@ package com.bonus.canteen.core.order.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.bonus.canteen.core.cook.enums.CookRecipeSortEnum; import com.bonus.canteen.core.cook.enums.CookRecipeSortEnum;
import com.bonus.canteen.core.cook.vo.CookH5CurrentDishesDetailVO;
import com.bonus.canteen.core.cook.vo.CookH5ReserveRecipeDishesVO;
import com.bonus.canteen.core.cook.vo.CookH5ReserveRecipeTypeVO;
import com.bonus.canteen.core.cook.vo.CookRecipeDishesVO; import com.bonus.canteen.core.cook.vo.CookRecipeDishesVO;
import com.bonus.canteen.core.order.domain.CookDishCheckDTO; import com.bonus.canteen.core.order.domain.CookDishCheckDTO;
import com.bonus.canteen.core.order.domain.OrderCart; import com.bonus.canteen.core.order.domain.OrderCart;
@ -71,6 +68,11 @@ public class OrderCartServiceImpl implements IOrderCartService
return new ArrayList<>(); return new ArrayList<>();
} }
CookDishCheckDTO cookDishCheckDTO = new CookDishCheckDTO();
cookDishCheckDTO.setCanteenId(orderCartQueryParam.getCanteenId());
cookDishCheckDTO.setStallId(orderCartQueryParam.getStallId());
cookDishCheckDTO.setApplyType(CookRecipeSortEnum.MOBILE_RESERVE.getKey());
Map<String, List<OrderCart>> groupedByOrderDate = orderCartList.stream() Map<String, List<OrderCart>> groupedByOrderDate = orderCartList.stream()
.collect(Collectors.groupingBy(cart -> DateUtil.format(cart.getOrderDate(), "yyyy-MM-dd"))); .collect(Collectors.groupingBy(cart -> DateUtil.format(cart.getOrderDate(), "yyyy-MM-dd")));
@ -81,18 +83,9 @@ public class OrderCartServiceImpl implements IOrderCartService
List<OrderCart> carts = entry.getValue(); List<OrderCart> carts = entry.getValue();
String filteredOrderDate = orderCartQueryParam.getMenuDateList().stream().filter(orderDate -> orderDate.equals(orderDateStr)) String filteredOrderDate = orderCartQueryParam.getMenuDateList().stream().filter(orderDate -> orderDate.equals(orderDateStr))
.findFirst().orElse(null); .findFirst().orElse(null);
CookDishCheckDTO cookDishCheckDTO = new CookDishCheckDTO();
Optional<Long> maxRecipeId = carts.stream()
.sorted(Comparator.comparing(OrderCart::getCartId).reversed())
.map(OrderCart::getRecipeId)
.findFirst();
if (maxRecipeId.isPresent()) {
cookDishCheckDTO.setRecipeId(maxRecipeId.get());
} else {
continue;
}
cookDishCheckDTO.setApplyDate(orderDateStr); cookDishCheckDTO.setApplyDate(orderDateStr);
Map<Integer, List<CookH5ReserveRecipeDishesVO>> cookRecipeDishMap = new HashMap<>(); Map<Long, List<CookRecipeDishesVO>> cookRecipeDishMap = new HashMap<>();
try{ try{
cookRecipeDishMap = menuModule.getMenuRecipeDish(cookDishCheckDTO); cookRecipeDishMap = menuModule.getMenuRecipeDish(cookDishCheckDTO);
}catch (Exception ex) { }catch (Exception ex) {
@ -100,7 +93,7 @@ public class OrderCartServiceImpl implements IOrderCartService
} }
for (OrderCart shoppingCart : carts) { for (OrderCart shoppingCart : carts) {
OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap, cookDishCheckDTO.getRecipeId()); OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap);
if(filteredOrderDate == null) { if(filteredOrderDate == null) {
shoppingCartVO.setIsValid(0); shoppingCartVO.setIsValid(0);
} }
@ -112,24 +105,17 @@ public class OrderCartServiceImpl implements IOrderCartService
} }
private OrderCartVO convertToOrderCartVO(OrderCart orderCart, private OrderCartVO convertToOrderCartVO(OrderCart orderCart,
Map<Integer, List<CookH5ReserveRecipeDishesVO>> cookRecipeDishMap, Map<Long, List<CookRecipeDishesVO>> cookRecipeDishMap) {
Long recipeId) {
OrderCartVO orderCartVO = new OrderCartVO(); OrderCartVO orderCartVO = new OrderCartVO();
BeanUtils.copyProperties(orderCart, orderCartVO); BeanUtils.copyProperties(orderCart, orderCartVO);
orderCartVO.setIsValid(0); orderCartVO.setIsValid(0);
List<CookH5ReserveRecipeDishesVO> cookRecipeDishes = cookRecipeDishMap.get(orderCart.getMealtimeType()); List<CookRecipeDishesVO> cookRecipeDishes = cookRecipeDishMap.get(orderCart.getMealtimeType().longValue());
if (CollUtil.isNotEmpty(cookRecipeDishes)) { if (CollUtil.isNotEmpty(cookRecipeDishes)) {
outerLoop: for (CookRecipeDishesVO cookRecipeDishesVO : cookRecipeDishes) {
for (CookH5ReserveRecipeDishesVO cookRecipeDishesVO : cookRecipeDishes) { if (orderCart.getGoodsId().equals(cookRecipeDishesVO.getDishesId())) {
if(CollUtil.isNotEmpty(cookRecipeDishesVO.getDishesDetailList())) { orderCartVO.setIsValid(1);
for (CookH5CurrentDishesDetailVO dishesDetailVO : cookRecipeDishesVO.getDishesDetailList()) { break;
if (orderCart.getGoodsId().equals(dishesDetailVO.getDishesId())
&& orderCart.getRecipeId().equals(recipeId)) {
orderCartVO.setIsValid(1);
break outerLoop;
}
}
} }
} }
} }