Merge branch 'master' into removedishbase
This commit is contained in:
commit
815a9e5b09
|
|
@ -7,12 +7,8 @@ import lombok.Data;
|
|||
*/
|
||||
@Data
|
||||
public class CookDishCheckDTO {
|
||||
/** 食堂id */
|
||||
private Long canteenId;
|
||||
/** 档口id */
|
||||
private Long stallId;
|
||||
/** 供应日期 */
|
||||
private String applyDate;
|
||||
/** 适用类型 */
|
||||
private Integer applyType;
|
||||
|
||||
private Long recipeId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package com.bonus.canteen.core.order.module;
|
||||
|
||||
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.service.ICookH5Service;
|
||||
import com.bonus.canteen.core.cook.service.ICookRecipeService;
|
||||
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.cook.vo.*;
|
||||
import com.bonus.canteen.core.order.domain.CookDishCheckDTO;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -18,37 +18,23 @@ import java.util.*;
|
|||
@Component
|
||||
public class MenuModule {
|
||||
@Autowired
|
||||
private ICookRecipeService cookRecipeService;
|
||||
private ICookH5Service cookH5Service;
|
||||
|
||||
public Map<Long, List<CookRecipeDishesVO>> getMenuRecipeDish(CookDishCheckDTO cookDishCheckDTO) {
|
||||
CookRecipeDTO menurecipe = new CookRecipeDTO();
|
||||
menurecipe.setApplyDate(LocalDate.parse(cookDishCheckDTO.getApplyDate()));
|
||||
menurecipe.setCanteenId(cookDishCheckDTO.getCanteenId());
|
||||
menurecipe.setStallId(cookDishCheckDTO.getStallId());
|
||||
menurecipe.setKey(cookDishCheckDTO.getApplyType());
|
||||
Map<Long, List<CookRecipeDishesVO>> mealTimeTypeMap = new HashMap<>();
|
||||
List<CookRecipeVO> menuRecipeList = cookRecipeService.selectCookRecipeList4Current(menurecipe);
|
||||
if (CollUtil.isNotEmpty(menuRecipeList) && menuRecipeList.size() == 1) {
|
||||
List<CookRecipeDateVO> recipeDateList = menuRecipeList.get(0).getRecipeDateList();
|
||||
if(CollUtil.isNotEmpty(recipeDateList) && recipeDateList.size() == 1) {
|
||||
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());
|
||||
public Map<Integer, List<CookH5ReserveRecipeDishesVO>> getMenuRecipeDish(CookDishCheckDTO cookDishCheckDTO) {
|
||||
CookH5ReserveRecipeDTO cookH5ReserveRecipeDTO = new CookH5ReserveRecipeDTO();
|
||||
cookH5ReserveRecipeDTO.setApplyDate(LocalDate.parse(cookDishCheckDTO.getApplyDate()));
|
||||
cookH5ReserveRecipeDTO.setRecipeId(cookDishCheckDTO.getRecipeId());
|
||||
Map<Integer, List<CookH5ReserveRecipeDishesVO>> mealTimeTypeMap = new HashMap<>();
|
||||
List<CookH5ReserveRecipeDetailsVO> cookRecipeList = cookH5Service.getReserveRecipeDetailList(cookH5ReserveRecipeDTO);
|
||||
if (CollUtil.isNotEmpty(cookRecipeList)) {
|
||||
for (CookH5ReserveRecipeDetailsVO cookRecipeDetailVO : cookRecipeList) {
|
||||
if(Objects.nonNull(cookRecipeDetailVO.getMealtimeType()) && CollUtil.isNotEmpty(cookRecipeDetailVO.getTypeList())) {
|
||||
List<CookH5ReserveRecipeDishesVO> allDishesList = new ArrayList<>();
|
||||
for(CookH5ReserveRecipeTypeVO typeVO : cookRecipeDetailVO.getTypeList()) {
|
||||
allDishesList.addAll(typeVO.getDishesList());
|
||||
}
|
||||
mealTimeTypeMap.put(cookRecipeDetailVO.getMealtimeType(), allDishesList);
|
||||
}
|
||||
if(Objects.nonNull(mealType)) {
|
||||
mealTimeTypeMap.put(mealType, dishsIdList);
|
||||
}
|
||||
}else {
|
||||
throw new ServiceException("菜谱信息异常");
|
||||
}
|
||||
}else {
|
||||
throw new ServiceException("菜谱信息异常");
|
||||
}
|
||||
}else {
|
||||
throw new ServiceException("菜谱信息异常");
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ package com.bonus.canteen.core.order.service.impl;
|
|||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.order.domain.CookDishCheckDTO;
|
||||
import com.bonus.canteen.core.order.domain.OrderCart;
|
||||
|
|
@ -68,11 +71,6 @@ public class OrderCartServiceImpl implements IOrderCartService
|
|||
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()
|
||||
.collect(Collectors.groupingBy(cart -> DateUtil.format(cart.getOrderDate(), "yyyy-MM-dd")));
|
||||
|
||||
|
|
@ -83,9 +81,18 @@ public class OrderCartServiceImpl implements IOrderCartService
|
|||
List<OrderCart> carts = entry.getValue();
|
||||
String filteredOrderDate = orderCartQueryParam.getMenuDateList().stream().filter(orderDate -> orderDate.equals(orderDateStr))
|
||||
.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);
|
||||
Map<Long, List<CookRecipeDishesVO>> cookRecipeDishMap = new HashMap<>();
|
||||
Map<Integer, List<CookH5ReserveRecipeDishesVO>> cookRecipeDishMap = new HashMap<>();
|
||||
try{
|
||||
cookRecipeDishMap = menuModule.getMenuRecipeDish(cookDishCheckDTO);
|
||||
}catch (Exception ex) {
|
||||
|
|
@ -93,7 +100,7 @@ public class OrderCartServiceImpl implements IOrderCartService
|
|||
}
|
||||
|
||||
for (OrderCart shoppingCart : carts) {
|
||||
OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap);
|
||||
OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap, cookDishCheckDTO.getRecipeId());
|
||||
if(filteredOrderDate == null) {
|
||||
shoppingCartVO.setIsValid(0);
|
||||
}
|
||||
|
|
@ -105,17 +112,24 @@ public class OrderCartServiceImpl implements IOrderCartService
|
|||
}
|
||||
|
||||
private OrderCartVO convertToOrderCartVO(OrderCart orderCart,
|
||||
Map<Long, List<CookRecipeDishesVO>> cookRecipeDishMap) {
|
||||
Map<Integer, List<CookH5ReserveRecipeDishesVO>> cookRecipeDishMap,
|
||||
Long recipeId) {
|
||||
OrderCartVO orderCartVO = new OrderCartVO();
|
||||
BeanUtils.copyProperties(orderCart, orderCartVO);
|
||||
orderCartVO.setIsValid(0);
|
||||
|
||||
List<CookRecipeDishesVO> cookRecipeDishes = cookRecipeDishMap.get(orderCart.getMealtimeType().longValue());
|
||||
List<CookH5ReserveRecipeDishesVO> cookRecipeDishes = cookRecipeDishMap.get(orderCart.getMealtimeType());
|
||||
if (CollUtil.isNotEmpty(cookRecipeDishes)) {
|
||||
for (CookRecipeDishesVO cookRecipeDishesVO : cookRecipeDishes) {
|
||||
if (orderCart.getGoodsId().equals(cookRecipeDishesVO.getDishesId())) {
|
||||
outerLoop:
|
||||
for (CookH5ReserveRecipeDishesVO cookRecipeDishesVO : cookRecipeDishes) {
|
||||
if(CollUtil.isNotEmpty(cookRecipeDishesVO.getDishesDetailList())) {
|
||||
for (CookH5CurrentDishesDetailVO dishesDetailVO : cookRecipeDishesVO.getDishesDetailList()) {
|
||||
if (orderCart.getGoodsId().equals(dishesDetailVO.getDishesId())
|
||||
&& orderCart.getRecipeId().equals(recipeId)) {
|
||||
orderCartVO.setIsValid(1);
|
||||
break;
|
||||
break outerLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue