Merge branch 'master' into removedishbase
This commit is contained in:
commit
815a9e5b09
|
|
@ -7,12 +7,8 @@ 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 Integer applyType;
|
private Long recipeId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.CookRecipeDateVO;
|
import com.bonus.canteen.core.cook.vo.*;
|
||||||
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,37 +18,23 @@ import java.util.*;
|
||||||
@Component
|
@Component
|
||||||
public class MenuModule {
|
public class MenuModule {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ICookRecipeService cookRecipeService;
|
private ICookH5Service cookH5Service;
|
||||||
|
|
||||||
public Map<Long, List<CookRecipeDishesVO>> getMenuRecipeDish(CookDishCheckDTO cookDishCheckDTO) {
|
public Map<Integer, List<CookH5ReserveRecipeDishesVO>> getMenuRecipeDish(CookDishCheckDTO cookDishCheckDTO) {
|
||||||
CookRecipeDTO menurecipe = new CookRecipeDTO();
|
CookH5ReserveRecipeDTO cookH5ReserveRecipeDTO = new CookH5ReserveRecipeDTO();
|
||||||
menurecipe.setApplyDate(LocalDate.parse(cookDishCheckDTO.getApplyDate()));
|
cookH5ReserveRecipeDTO.setApplyDate(LocalDate.parse(cookDishCheckDTO.getApplyDate()));
|
||||||
menurecipe.setCanteenId(cookDishCheckDTO.getCanteenId());
|
cookH5ReserveRecipeDTO.setRecipeId(cookDishCheckDTO.getRecipeId());
|
||||||
menurecipe.setStallId(cookDishCheckDTO.getStallId());
|
Map<Integer, List<CookH5ReserveRecipeDishesVO>> mealTimeTypeMap = new HashMap<>();
|
||||||
menurecipe.setKey(cookDishCheckDTO.getApplyType());
|
List<CookH5ReserveRecipeDetailsVO> cookRecipeList = cookH5Service.getReserveRecipeDetailList(cookH5ReserveRecipeDTO);
|
||||||
Map<Long, List<CookRecipeDishesVO>> mealTimeTypeMap = new HashMap<>();
|
if (CollUtil.isNotEmpty(cookRecipeList)) {
|
||||||
List<CookRecipeVO> menuRecipeList = cookRecipeService.selectCookRecipeList4Current(menurecipe);
|
for (CookH5ReserveRecipeDetailsVO cookRecipeDetailVO : cookRecipeList) {
|
||||||
if (CollUtil.isNotEmpty(menuRecipeList) && menuRecipeList.size() == 1) {
|
if(Objects.nonNull(cookRecipeDetailVO.getMealtimeType()) && CollUtil.isNotEmpty(cookRecipeDetailVO.getTypeList())) {
|
||||||
List<CookRecipeDateVO> recipeDateList = menuRecipeList.get(0).getRecipeDateList();
|
List<CookH5ReserveRecipeDishesVO> allDishesList = new ArrayList<>();
|
||||||
if(CollUtil.isNotEmpty(recipeDateList) && recipeDateList.size() == 1) {
|
for(CookH5ReserveRecipeTypeVO typeVO : cookRecipeDetailVO.getTypeList()) {
|
||||||
List<CookRecipeDetailVO> cookRecipeDetail = recipeDateList.get(0).getDetailList();
|
allDishesList.addAll(typeVO.getDishesList());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(Objects.nonNull(mealType)) {
|
mealTimeTypeMap.put(cookRecipeDetailVO.getMealtimeType(), allDishesList);
|
||||||
mealTimeTypeMap.put(mealType, dishsIdList);
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
throw new ServiceException("菜谱信息异常");
|
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
throw new ServiceException("菜谱信息异常");
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
throw new ServiceException("菜谱信息异常");
|
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.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;
|
||||||
|
|
@ -68,11 +71,6 @@ 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")));
|
||||||
|
|
||||||
|
|
@ -83,9 +81,18 @@ 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<Long, List<CookRecipeDishesVO>> cookRecipeDishMap = new HashMap<>();
|
Map<Integer, List<CookH5ReserveRecipeDishesVO>> cookRecipeDishMap = new HashMap<>();
|
||||||
try{
|
try{
|
||||||
cookRecipeDishMap = menuModule.getMenuRecipeDish(cookDishCheckDTO);
|
cookRecipeDishMap = menuModule.getMenuRecipeDish(cookDishCheckDTO);
|
||||||
}catch (Exception ex) {
|
}catch (Exception ex) {
|
||||||
|
|
@ -93,7 +100,7 @@ public class OrderCartServiceImpl implements IOrderCartService
|
||||||
}
|
}
|
||||||
|
|
||||||
for (OrderCart shoppingCart : carts) {
|
for (OrderCart shoppingCart : carts) {
|
||||||
OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap);
|
OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap, cookDishCheckDTO.getRecipeId());
|
||||||
if(filteredOrderDate == null) {
|
if(filteredOrderDate == null) {
|
||||||
shoppingCartVO.setIsValid(0);
|
shoppingCartVO.setIsValid(0);
|
||||||
}
|
}
|
||||||
|
|
@ -105,17 +112,24 @@ public class OrderCartServiceImpl implements IOrderCartService
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderCartVO convertToOrderCartVO(OrderCart orderCart,
|
private OrderCartVO convertToOrderCartVO(OrderCart orderCart,
|
||||||
Map<Long, List<CookRecipeDishesVO>> cookRecipeDishMap) {
|
Map<Integer, List<CookH5ReserveRecipeDishesVO>> 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<CookRecipeDishesVO> cookRecipeDishes = cookRecipeDishMap.get(orderCart.getMealtimeType().longValue());
|
List<CookH5ReserveRecipeDishesVO> cookRecipeDishes = cookRecipeDishMap.get(orderCart.getMealtimeType());
|
||||||
if (CollUtil.isNotEmpty(cookRecipeDishes)) {
|
if (CollUtil.isNotEmpty(cookRecipeDishes)) {
|
||||||
for (CookRecipeDishesVO cookRecipeDishesVO : cookRecipeDishes) {
|
outerLoop:
|
||||||
if (orderCart.getGoodsId().equals(cookRecipeDishesVO.getDishesId())) {
|
for (CookH5ReserveRecipeDishesVO cookRecipeDishesVO : cookRecipeDishes) {
|
||||||
orderCartVO.setIsValid(1);
|
if(CollUtil.isNotEmpty(cookRecipeDishesVO.getDishesDetailList())) {
|
||||||
break;
|
for (CookH5CurrentDishesDetailVO dishesDetailVO : cookRecipeDishesVO.getDishesDetailList()) {
|
||||||
|
if (orderCart.getGoodsId().equals(dishesDetailVO.getDishesId())
|
||||||
|
&& orderCart.getRecipeId().equals(recipeId)) {
|
||||||
|
orderCartVO.setIsValid(1);
|
||||||
|
break outerLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue