订单管理
This commit is contained in:
parent
cd6ec9e759
commit
a3c6f9d218
|
|
@ -2,13 +2,19 @@ package com.bonus.canteen.core.order.domain;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bonus
|
* @author Bonus
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CookDishCheckDTO {
|
public class CookDishCheckDTO {
|
||||||
|
/** 食堂id */
|
||||||
|
private Long canteenId;
|
||||||
|
/** 档口id */
|
||||||
|
private Long stallId;
|
||||||
/** 供应日期 */
|
/** 供应日期 */
|
||||||
private String applyDate;
|
private LocalDate applyDate;
|
||||||
|
/** 适用类型 */
|
||||||
private Long recipeId;
|
private Integer applyType;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,7 +65,7 @@ public class OrderCart extends BaseEntity
|
||||||
/** 订单日期 yyyy-MM-dd */
|
/** 订单日期 yyyy-MM-dd */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date orderDate;
|
private LocalDate orderDate;
|
||||||
|
|
||||||
/** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */
|
/** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */
|
||||||
@Excel(name = "餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵")
|
@Excel(name = "餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵")
|
||||||
|
|
@ -180,14 +181,12 @@ public class OrderCart extends BaseEntity
|
||||||
return detailType;
|
return detailType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderDate(Date orderDate)
|
public LocalDate getOrderDate() {
|
||||||
{
|
return orderDate;
|
||||||
this.orderDate = orderDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getOrderDate()
|
public void setOrderDate(LocalDate orderDate) {
|
||||||
{
|
this.orderDate = orderDate;
|
||||||
return orderDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMealtimeType(Integer mealtimeType)
|
public void setMealtimeType(Integer mealtimeType)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -63,7 +64,7 @@ public class OrderCartVO extends BaseEntity
|
||||||
/** 订单日期 yyyy-MM-dd */
|
/** 订单日期 yyyy-MM-dd */
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||||
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date orderDate;
|
private LocalDate orderDate;
|
||||||
|
|
||||||
/** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */
|
/** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */
|
||||||
@Excel(name = "餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵")
|
@Excel(name = "餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵")
|
||||||
|
|
|
||||||
|
|
@ -18,27 +18,20 @@ 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 AllocRecipeStallVO getMenuRecipeDish(CookDishCheckDTO cookDishCheckDTO) {
|
||||||
CookH5ReserveRecipeDTO cookH5ReserveRecipeDTO = new CookH5ReserveRecipeDTO();
|
AllocRecipeStallDTO allocRecipeStallDTO = new AllocRecipeStallDTO();
|
||||||
cookH5ReserveRecipeDTO.setApplyDate(LocalDate.parse(cookDishCheckDTO.getApplyDate()));
|
allocRecipeStallDTO.setApplyDate(cookDishCheckDTO.getApplyDate());
|
||||||
cookH5ReserveRecipeDTO.setRecipeId(cookDishCheckDTO.getRecipeId());
|
allocRecipeStallDTO.setCanteenId(cookDishCheckDTO.getCanteenId());
|
||||||
|
allocRecipeStallDTO.setStallId(cookDishCheckDTO.getStallId());
|
||||||
|
allocRecipeStallDTO.setKey(cookDishCheckDTO.getApplyType());
|
||||||
Map<Integer, List<CookH5ReserveRecipeDishesVO>> mealTimeTypeMap = new HashMap<>();
|
Map<Integer, List<CookH5ReserveRecipeDishesVO>> mealTimeTypeMap = new HashMap<>();
|
||||||
List<CookH5ReserveRecipeDetailsVO> cookRecipeList = cookH5Service.getReserveRecipeDetailList(cookH5ReserveRecipeDTO);
|
List<AllocRecipeStallVO> cookRecipeList = cookRecipeService.selectCookRecipeList4Current(allocRecipeStallDTO);
|
||||||
if (CollUtil.isNotEmpty(cookRecipeList)) {
|
if (CollUtil.isNotEmpty(cookRecipeList) && cookRecipeList.size() == 1) {
|
||||||
for (CookH5ReserveRecipeDetailsVO cookRecipeDetailVO : cookRecipeList) {
|
return cookRecipeList.get(0);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else {
|
}else {
|
||||||
throw new ServiceException("菜谱信息异常");
|
throw new ServiceException("菜谱信息异常");
|
||||||
}
|
}
|
||||||
return mealTimeTypeMap;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,7 @@ 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.*;
|
||||||
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.CookDishCheckDTO;
|
||||||
import com.bonus.canteen.core.order.domain.OrderCart;
|
import com.bonus.canteen.core.order.domain.OrderCart;
|
||||||
import com.bonus.canteen.core.order.domain.param.OrderCartQueryParam;
|
import com.bonus.canteen.core.order.domain.param.OrderCartQueryParam;
|
||||||
|
|
@ -22,6 +19,7 @@ import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -70,74 +68,55 @@ public class OrderCartServiceImpl implements IOrderCartService
|
||||||
if (CollUtil.isEmpty(orderCartList)) {
|
if (CollUtil.isEmpty(orderCartList)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, List<OrderCart>> groupedByOrderDate = orderCartList.stream()
|
|
||||||
.collect(Collectors.groupingBy(cart -> DateUtil.format(cart.getOrderDate(), "yyyy-MM-dd")));
|
|
||||||
|
|
||||||
List<OrderCartVO> orderCartVOList = new ArrayList<>();
|
List<OrderCartVO> orderCartVOList = new ArrayList<>();
|
||||||
|
for (OrderCart orderCart : orderCartList) {
|
||||||
for (Map.Entry<String, List<OrderCart>> entry : groupedByOrderDate.entrySet()) {
|
boolean filteredOrderDate = orderCartQueryParam.getMenuDateList().stream()
|
||||||
String orderDateStr = entry.getKey();
|
.anyMatch(menuDate -> LocalDate.parse(menuDate).equals(orderCart.getOrderDate()));
|
||||||
List<OrderCart> carts = entry.getValue();
|
OrderCartVO orderCartVO = new OrderCartVO();
|
||||||
String filteredOrderDate = orderCartQueryParam.getMenuDateList().stream().filter(orderDate -> orderDate.equals(orderDateStr))
|
BeanUtils.copyProperties(orderCart, orderCartVO);
|
||||||
.findFirst().orElse(null);
|
orderCartVO.setIsValid(0);
|
||||||
CookDishCheckDTO cookDishCheckDTO = new CookDishCheckDTO();
|
orderCartVOList.add(orderCartVO);
|
||||||
Optional<Long> maxRecipeId = carts.stream()
|
if(!filteredOrderDate) {
|
||||||
.sorted(Comparator.comparing(OrderCart::getCartId).reversed())
|
|
||||||
.map(OrderCart::getRecipeId)
|
|
||||||
.findFirst();
|
|
||||||
if (maxRecipeId.isPresent()) {
|
|
||||||
cookDishCheckDTO.setRecipeId(maxRecipeId.get());
|
|
||||||
} else {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cookDishCheckDTO.setApplyDate(orderDateStr);
|
CookDishCheckDTO cookDishCheckDTO = new CookDishCheckDTO();
|
||||||
Map<Integer, List<CookH5ReserveRecipeDishesVO>> cookRecipeDishMap = new HashMap<>();
|
cookDishCheckDTO.setApplyDate(orderCart.getOrderDate());
|
||||||
|
cookDishCheckDTO.setCanteenId(orderCart.getCanteenId());
|
||||||
|
cookDishCheckDTO.setStallId(orderCart.getStallId());
|
||||||
|
cookDishCheckDTO.setApplyType(CookRecipeSortEnum.MOBILE_RESERVE.getKey());
|
||||||
|
AllocRecipeStallVO allocRecipeStallVO = null;
|
||||||
try{
|
try{
|
||||||
cookRecipeDishMap = menuModule.getMenuRecipeDish(cookDishCheckDTO);
|
allocRecipeStallVO = menuModule.getMenuRecipeDish(cookDishCheckDTO);
|
||||||
}catch (Exception ex) {
|
}catch (Exception ex) {
|
||||||
log.info("菜单数据获取失败:{}", ex.getMessage(), ex);
|
log.error("菜单数据获取失败:{}", ex.getMessage(), ex);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (OrderCart shoppingCart : carts) {
|
if(Objects.isNull(allocRecipeStallVO) || Objects.isNull(allocRecipeStallVO.getDetail())
|
||||||
OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap, cookDishCheckDTO.getRecipeId());
|
|| CollUtil.isEmpty(allocRecipeStallVO.getDetail().getDetailList())) {
|
||||||
if(filteredOrderDate == null) {
|
continue;
|
||||||
shoppingCartVO.setIsValid(0);
|
|
||||||
}
|
|
||||||
orderCartVOList.add(shoppingCartVO);
|
|
||||||
}
|
}
|
||||||
}
|
if(!allocRecipeStallVO.getRecipeId().equals(orderCart.getRecipeId())) {
|
||||||
|
continue;
|
||||||
return orderCartVOList;
|
}
|
||||||
}
|
List<CookRecipeDetailVO> cookRecipeDishList = allocRecipeStallVO.getDetail().getDetailList();
|
||||||
|
|
||||||
private OrderCartVO convertToOrderCartVO(OrderCart orderCart,
|
|
||||||
Map<Integer, List<CookH5ReserveRecipeDishesVO>> cookRecipeDishMap,
|
|
||||||
Long recipeId) {
|
|
||||||
OrderCartVO orderCartVO = new OrderCartVO();
|
|
||||||
BeanUtils.copyProperties(orderCart, orderCartVO);
|
|
||||||
orderCartVO.setIsValid(0);
|
|
||||||
|
|
||||||
List<CookH5ReserveRecipeDishesVO> cookRecipeDishes = cookRecipeDishMap.get(orderCart.getMealtimeType());
|
|
||||||
if (CollUtil.isNotEmpty(cookRecipeDishes)) {
|
|
||||||
outerLoop:
|
outerLoop:
|
||||||
for (CookH5ReserveRecipeDishesVO cookRecipeDishesVO : cookRecipeDishes) {
|
for(CookRecipeDetailVO cookRecipeDish :cookRecipeDishList) {
|
||||||
if(CollUtil.isNotEmpty(cookRecipeDishesVO.getDishesDetailList())) {
|
if(cookRecipeDish.getMealtimeType().equals(orderCart.getMealtimeType().longValue())) {
|
||||||
for (CookH5CurrentDishesDetailVO dishesDetailVO : cookRecipeDishesVO.getDishesDetailList()) {
|
if(CollUtil.isNotEmpty(cookRecipeDish.getDishesList())) {
|
||||||
if (orderCart.getGoodsId().equals(dishesDetailVO.getDishesId())
|
for (CookRecipeDishesVO cookRecipeDishesVO : cookRecipeDish.getDishesList()) {
|
||||||
&& orderCart.getRecipeId().equals(recipeId)) {
|
if(cookRecipeDishesVO.getDishesId().equals(orderCart.getGoodsId())) {
|
||||||
orderCartVO.setIsValid(1);
|
orderCartVO.setIsValid(1);
|
||||||
break outerLoop;
|
break outerLoop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return orderCartVOList;
|
||||||
return orderCartVO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增订单购物车
|
* 新增订单购物车
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue