Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
06cd735852
|
|
@ -5,6 +5,8 @@ import com.bonus.canteen.core.android.dto.AppDTO;
|
|||
import com.bonus.canteen.core.android.service.DeviceService;
|
||||
import com.bonus.canteen.core.android.vo.CookRecipeCompressVO;
|
||||
import com.bonus.canteen.core.android.vo.DeviceTimeIntervalVO;
|
||||
import com.bonus.canteen.core.device.domain.DeviceSearchDTO;
|
||||
import com.bonus.canteen.core.device.service.IDeviceInfoService;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -26,7 +28,8 @@ import java.util.Map;
|
|||
public class DeviceController extends BaseController {
|
||||
@Resource
|
||||
private DeviceService deviceService;
|
||||
|
||||
@Resource
|
||||
private IDeviceInfoService deviceInfoService;
|
||||
|
||||
|
||||
@ApiOperation("获取设备信息")
|
||||
|
|
@ -69,4 +72,14 @@ public class DeviceController extends BaseController {
|
|||
return this.deviceService.intervalConfig(HeaderFetchUtil.getMachineSn(headers));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新设备在线状态")
|
||||
@PostMapping({"/updateTimeBySn"})
|
||||
public AjaxResult updateTimeBySn(@RequestBody DeviceSearchDTO dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getDeviceSn())) {
|
||||
throw new ServiceException("设备sn不能为空");
|
||||
}
|
||||
this.deviceInfoService.updateTimeBySn(dto.getDeviceSn());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.canteen.core.device.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
|
@ -34,7 +35,7 @@ import com.bonus.common.core.web.page.TableDataInfo;
|
|||
@RestController
|
||||
@RequestMapping("/device_info")
|
||||
public class DeviceInfoController extends BaseController {
|
||||
@Autowired
|
||||
@Resource
|
||||
private IDeviceInfoService deviceInfoService;
|
||||
|
||||
/**
|
||||
|
|
@ -107,14 +108,5 @@ public class DeviceInfoController extends BaseController {
|
|||
return toAjax(deviceInfoService.deleteDeviceInfoByDeviceIds(deviceIds));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新设备在线状态")
|
||||
@PostMapping({"/updateTimeBySn"})
|
||||
public AjaxResult updateTimeBySn(@RequestBody DeviceSearchDTO dto) {
|
||||
if (ObjectUtil.isEmpty(dto.getDeviceSn())) {
|
||||
throw new ServiceException("设备sn不能为空");
|
||||
}
|
||||
this.deviceInfoService.updateTimeBySn(dto.getDeviceSn());
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,19 @@ package com.bonus.canteen.core.order.domain;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author Bonus
|
||||
*/
|
||||
@Data
|
||||
public class CookDishCheckDTO {
|
||||
/** 食堂id */
|
||||
private Long canteenId;
|
||||
/** 档口id */
|
||||
private Long stallId;
|
||||
/** 供应日期 */
|
||||
private String applyDate;
|
||||
|
||||
private Long recipeId;
|
||||
private LocalDate applyDate;
|
||||
/** 适用类型 */
|
||||
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.ToStringStyle;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +65,7 @@ public class OrderCart extends BaseEntity
|
|||
/** 订单日期 yyyy-MM-dd */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date orderDate;
|
||||
private LocalDate orderDate;
|
||||
|
||||
/** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */
|
||||
@Excel(name = "餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵")
|
||||
|
|
@ -180,14 +181,12 @@ public class OrderCart extends BaseEntity
|
|||
return detailType;
|
||||
}
|
||||
|
||||
public void setOrderDate(Date orderDate)
|
||||
{
|
||||
this.orderDate = orderDate;
|
||||
public LocalDate getOrderDate() {
|
||||
return orderDate;
|
||||
}
|
||||
|
||||
public Date getOrderDate()
|
||||
{
|
||||
return orderDate;
|
||||
public void setOrderDate(LocalDate orderDate) {
|
||||
this.orderDate = orderDate;
|
||||
}
|
||||
|
||||
public void setMealtimeType(Integer mealtimeType)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
|
|||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -63,7 +64,7 @@ public class OrderCartVO extends BaseEntity
|
|||
/** 订单日期 yyyy-MM-dd */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
@Excel(name = "订单日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date orderDate;
|
||||
private LocalDate orderDate;
|
||||
|
||||
/** 餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵 */
|
||||
@Excel(name = "餐次类型 1-早餐 2-午餐 3-晚餐 4-下午茶 5-夜宵")
|
||||
|
|
|
|||
|
|
@ -18,27 +18,20 @@ import java.util.*;
|
|||
@Component
|
||||
public class MenuModule {
|
||||
@Autowired
|
||||
private ICookH5Service cookH5Service;
|
||||
private ICookRecipeService cookRecipeService;
|
||||
|
||||
public Map<Integer, List<CookH5ReserveRecipeDishesVO>> getMenuRecipeDish(CookDishCheckDTO cookDishCheckDTO) {
|
||||
CookH5ReserveRecipeDTO cookH5ReserveRecipeDTO = new CookH5ReserveRecipeDTO();
|
||||
cookH5ReserveRecipeDTO.setApplyDate(LocalDate.parse(cookDishCheckDTO.getApplyDate()));
|
||||
cookH5ReserveRecipeDTO.setRecipeId(cookDishCheckDTO.getRecipeId());
|
||||
public AllocRecipeStallVO getMenuRecipeDish(CookDishCheckDTO cookDishCheckDTO) {
|
||||
AllocRecipeStallDTO allocRecipeStallDTO = new AllocRecipeStallDTO();
|
||||
allocRecipeStallDTO.setApplyDate(cookDishCheckDTO.getApplyDate());
|
||||
allocRecipeStallDTO.setCanteenId(cookDishCheckDTO.getCanteenId());
|
||||
allocRecipeStallDTO.setStallId(cookDishCheckDTO.getStallId());
|
||||
allocRecipeStallDTO.setKey(cookDishCheckDTO.getApplyType());
|
||||
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);
|
||||
}
|
||||
}
|
||||
List<AllocRecipeStallVO> cookRecipeList = cookRecipeService.selectCookRecipeList4Current(allocRecipeStallDTO);
|
||||
if (CollUtil.isNotEmpty(cookRecipeList) && cookRecipeList.size() == 1) {
|
||||
return cookRecipeList.get(0);
|
||||
}else {
|
||||
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.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.cook.vo.*;
|
||||
import com.bonus.canteen.core.order.domain.CookDishCheckDTO;
|
||||
import com.bonus.canteen.core.order.domain.OrderCart;
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -70,74 +68,55 @@ public class OrderCartServiceImpl implements IOrderCartService
|
|||
if (CollUtil.isEmpty(orderCartList)) {
|
||||
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<>();
|
||||
|
||||
for (Map.Entry<String, List<OrderCart>> entry : groupedByOrderDate.entrySet()) {
|
||||
String orderDateStr = entry.getKey();
|
||||
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 {
|
||||
for (OrderCart orderCart : orderCartList) {
|
||||
boolean filteredOrderDate = orderCartQueryParam.getMenuDateList().stream()
|
||||
.anyMatch(menuDate -> LocalDate.parse(menuDate).equals(orderCart.getOrderDate()));
|
||||
OrderCartVO orderCartVO = new OrderCartVO();
|
||||
BeanUtils.copyProperties(orderCart, orderCartVO);
|
||||
orderCartVO.setIsValid(0);
|
||||
orderCartVOList.add(orderCartVO);
|
||||
if(!filteredOrderDate) {
|
||||
continue;
|
||||
}
|
||||
cookDishCheckDTO.setApplyDate(orderDateStr);
|
||||
Map<Integer, List<CookH5ReserveRecipeDishesVO>> cookRecipeDishMap = new HashMap<>();
|
||||
CookDishCheckDTO cookDishCheckDTO = new CookDishCheckDTO();
|
||||
cookDishCheckDTO.setApplyDate(orderCart.getOrderDate());
|
||||
cookDishCheckDTO.setCanteenId(orderCart.getCanteenId());
|
||||
cookDishCheckDTO.setStallId(orderCart.getStallId());
|
||||
cookDishCheckDTO.setApplyType(CookRecipeSortEnum.MOBILE_RESERVE.getKey());
|
||||
AllocRecipeStallVO allocRecipeStallVO = null;
|
||||
try{
|
||||
cookRecipeDishMap = menuModule.getMenuRecipeDish(cookDishCheckDTO);
|
||||
allocRecipeStallVO = menuModule.getMenuRecipeDish(cookDishCheckDTO);
|
||||
}catch (Exception ex) {
|
||||
log.info("菜单数据获取失败:{}", ex.getMessage(), ex);
|
||||
log.error("菜单数据获取失败:{}", ex.getMessage(), ex);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (OrderCart shoppingCart : carts) {
|
||||
OrderCartVO shoppingCartVO = convertToOrderCartVO(shoppingCart, cookRecipeDishMap, cookDishCheckDTO.getRecipeId());
|
||||
if(filteredOrderDate == null) {
|
||||
shoppingCartVO.setIsValid(0);
|
||||
}
|
||||
orderCartVOList.add(shoppingCartVO);
|
||||
if(Objects.isNull(allocRecipeStallVO) || Objects.isNull(allocRecipeStallVO.getDetail())
|
||||
|| CollUtil.isEmpty(allocRecipeStallVO.getDetail().getDetailList())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return orderCartVOList;
|
||||
}
|
||||
|
||||
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)) {
|
||||
if(!allocRecipeStallVO.getRecipeId().equals(orderCart.getRecipeId())) {
|
||||
continue;
|
||||
}
|
||||
List<CookRecipeDetailVO> cookRecipeDishList = allocRecipeStallVO.getDetail().getDetailList();
|
||||
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 outerLoop;
|
||||
for(CookRecipeDetailVO cookRecipeDish :cookRecipeDishList) {
|
||||
if(cookRecipeDish.getMealtimeType().equals(orderCart.getMealtimeType().longValue())) {
|
||||
if(CollUtil.isNotEmpty(cookRecipeDish.getDishesList())) {
|
||||
for (CookRecipeDishesVO cookRecipeDishesVO : cookRecipeDish.getDishesList()) {
|
||||
if(cookRecipeDishesVO.getDishesId().equals(orderCart.getGoodsId())) {
|
||||
orderCartVO.setIsValid(1);
|
||||
break outerLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return orderCartVO;
|
||||
return orderCartVOList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增订单购物车
|
||||
*
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
r.user_id as userId
|
||||
from( select
|
||||
user_id,
|
||||
IF(wallet_id = 1,wallet_bal,0) as personalWalletBalance,
|
||||
IF(wallet_id = 2,wallet_bal,0) as subsidiesBalance,
|
||||
IF(wallet_type = 1,wallet_bal,0) as personalWalletBalance,
|
||||
IF(wallet_type = 2,wallet_bal,0) as subsidiesBalance,
|
||||
wallet_bal
|
||||
from account_wallet_info)r
|
||||
GROUP BY r.user_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue