|
|
@@ -1,6 +1,7 @@
|
|
|
package org.jeecg.modules.pos.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.lang.Snowflake;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
@@ -24,6 +25,7 @@ import org.jeecg.modules.pos.TableStateEnum;
|
|
|
import org.jeecg.modules.pos.entity.*;
|
|
|
import org.jeecg.modules.pos.mapper.PosOrderGoodsMapper;
|
|
|
import org.jeecg.modules.pos.service.*;
|
|
|
+import org.jeecg.modules.pos.vo.PosBooingOrderGoods;
|
|
|
import org.jeecg.modules.rooms.entity.CesGoods;
|
|
|
import org.jeecg.modules.rooms.service.CesGoodsServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -73,15 +75,15 @@ public class PosOrderGoodsServiceImpl extends ServiceImpl<PosOrderGoodsMapper, P
|
|
|
/**通过桌台id查询订单*/
|
|
|
@Override
|
|
|
public PosOrderGoods getOrderByTableId(String tableId) {
|
|
|
- LambdaQueryWrapper<PosOrderGoods> queryWrapper = new LambdaQueryWrapper<PosOrderGoods>()
|
|
|
- .eq(PosOrderGoods::getStatus, 0).eq(PosOrderGoods::getPosTableId, tableId);
|
|
|
- List<PosOrderGoods> orderGoods = list(queryWrapper);
|
|
|
- if (orderGoods.isEmpty()){
|
|
|
- throw new JeecgBootException("异常");
|
|
|
- }
|
|
|
- List<PosOrderGoodsDetail> goodsDetailList = posOrderGoodsDetailService.getGoodsDetail(orderGoods.get(0).getCode());
|
|
|
- orderGoods.get(0).setPosOrderGoodsDetailList(goodsDetailList);
|
|
|
- return orderGoods.get(0);
|
|
|
+ LambdaQueryWrapper<PosOrderGoods> queryWrapper = new LambdaQueryWrapper<PosOrderGoods>().eq(PosOrderGoods::getStatus, 0)
|
|
|
+ .eq(PosOrderGoods::getPosTableId, tableId).orderByDesc(PosOrderGoods::getCreateTime).last("limit 1");
|
|
|
+ PosOrderGoods orderGood = getOne(queryWrapper);
|
|
|
+ if (orderGood == null) {
|
|
|
+ throw new JeecgBootException("未找到订单");
|
|
|
+ }
|
|
|
+ List<PosOrderGoodsDetail> goodsDetailList = posOrderGoodsDetailService.getGoodsDetail(orderGood.getCode());
|
|
|
+ orderGood.setPosOrderGoodsDetailList(goodsDetailList);
|
|
|
+ return orderGood;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -90,10 +92,9 @@ public class PosOrderGoodsServiceImpl extends ServiceImpl<PosOrderGoodsMapper, P
|
|
|
lambdaQueryWrapper.eq(PosOrderGoods::getPosTableId, tableId);
|
|
|
lambdaQueryWrapper.eq(PosOrderGoods::getStatus, 0);
|
|
|
// 还未开台的预约单不显示
|
|
|
- lambdaQueryWrapper.eq(PosOrderGoods::getIsBooking, 0);
|
|
|
+ lambdaQueryWrapper.eq(PosOrderGoods::getIsBooking, false);
|
|
|
lambdaQueryWrapper.orderByDesc(PosOrderGoods::getCreateTime);
|
|
|
lambdaQueryWrapper.last("limit 1");
|
|
|
- lambdaQueryWrapper.orderByDesc(PosOrderGoods::getCreateTime);
|
|
|
PosOrderGoods posOrderGood = getOne(lambdaQueryWrapper);
|
|
|
if (posOrderGood == null || StrUtil.isEmpty(posOrderGood.getTeamId())){
|
|
|
return posOrderGood;
|
|
|
@@ -279,12 +280,12 @@ public class PosOrderGoodsServiceImpl extends ServiceImpl<PosOrderGoodsMapper, P
|
|
|
|
|
|
/***/
|
|
|
@Override
|
|
|
- public PosBookingOrder getBookingOrderById(String bookingOrderId){
|
|
|
- PosBookingOrder bookingOrder = posBookingService.getById(bookingOrderId);
|
|
|
+ public PosBookingOrder getBookingOrderById(String bookingId){
|
|
|
+ PosBookingOrder bookingOrder = posBookingService.getById(bookingId);
|
|
|
if (bookingOrder == null){
|
|
|
throw new JeecgBootException("未找到预约单");
|
|
|
}
|
|
|
- List<PosOrderGoods> orderGoodsList = list(Wrappers.<PosOrderGoods>lambdaQuery().eq(PosOrderGoods::getCode, bookingOrder.getCode()));
|
|
|
+ List<PosOrderGoods> orderGoodsList = list(Wrappers.<PosOrderGoods>lambdaQuery().eq(PosOrderGoods::getBookingCode, bookingOrder.getCode()));
|
|
|
if (orderGoodsList.isEmpty()){
|
|
|
throw new JeecgBootException("未找到相关订单");
|
|
|
}
|
|
|
@@ -324,6 +325,7 @@ public class PosOrderGoodsServiceImpl extends ServiceImpl<PosOrderGoodsMapper, P
|
|
|
/**根据桌号查询今日预约单*/
|
|
|
@Override
|
|
|
public List<PosBookingOrder> getBookingByTableId(String tableId) {
|
|
|
+ // 找到预约单
|
|
|
List<PosBookingOrder> bookingOrders = posBookingService.getTodayBooking();
|
|
|
if (bookingOrders.isEmpty()){
|
|
|
return bookingOrders;
|
|
|
@@ -332,12 +334,13 @@ public class PosOrderGoodsServiceImpl extends ServiceImpl<PosOrderGoodsMapper, P
|
|
|
if (codes.isEmpty()){
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
+ // 找到预约单下订单
|
|
|
List<PosOrderGoods> orderGoodsList = list(Wrappers.<PosOrderGoods>lambdaQuery().in(PosOrderGoods::getBookingCode, codes));
|
|
|
List<String> findCodes = orderGoodsList.stream().filter(e -> tableId.equals(e.getPosTableId())).map(PosOrderGoods::getBookingCode).collect(Collectors.toList());
|
|
|
if (findCodes.isEmpty()){
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
- return bookingOrders.stream().filter(e -> findCodes.contains(e.getId())).collect(Collectors.toList());
|
|
|
+ return bookingOrders.stream().filter(e -> findCodes.contains(e.getCode())).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/**预定开台*/
|
|
|
@@ -540,6 +543,11 @@ public class PosOrderGoodsServiceImpl extends ServiceImpl<PosOrderGoodsMapper, P
|
|
|
return posOrderGoodsDetailService.updateBatchById(orderGoodsDetailList);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<PosBooingOrderGoods> getBookingOrderPage(PosBookingOrder bookingOrder, Page<PosBooingOrderGoods> page, DateTime startTime, DateTime endTime) {
|
|
|
+ return page.setRecords(baseMapper.getBookingOrderPage(bookingOrder, page, startTime, endTime));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**设置订单的桌号/取餐号*/
|
|
|
private void setOrderTableNo(PosOrderGoods posOrderGoods) {
|