|
@@ -1,20 +1,20 @@
|
|
|
package org.jeecg.modules.business.service.impl;
|
|
package org.jeecg.modules.business.service.impl;
|
|
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.date.DateTime;
|
|
|
|
|
|
|
+import cn.hutool.core.lang.Snowflake;
|
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
|
-import net.sf.saxon.expr.instruct.ForEach;
|
|
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
@@ -26,7 +26,6 @@ import org.jeecg.modules.business.mapper.BusRoomBookingOrdersMapper;
|
|
|
import org.jeecg.modules.business.service.*;
|
|
import org.jeecg.modules.business.service.*;
|
|
|
import org.jeecg.modules.business.util.MxTools;
|
|
import org.jeecg.modules.business.util.MxTools;
|
|
|
import org.jeecg.modules.business.vo.*;
|
|
import org.jeecg.modules.business.vo.*;
|
|
|
-import org.jeecg.modules.finance.vo.OrderFeeVo;
|
|
|
|
|
import org.jeecg.modules.fw.entity.FwRoomClean;
|
|
import org.jeecg.modules.fw.entity.FwRoomClean;
|
|
|
import org.jeecg.modules.fw.entity.FwRoomExamine;
|
|
import org.jeecg.modules.fw.entity.FwRoomExamine;
|
|
|
import org.jeecg.modules.fw.entity.FwRoomLock;
|
|
import org.jeecg.modules.fw.entity.FwRoomLock;
|
|
@@ -37,15 +36,15 @@ import org.jeecg.modules.fw.service.IFwRoomLockService;
|
|
|
import org.jeecg.modules.fw.service.IFwRoomRepairService;
|
|
import org.jeecg.modules.fw.service.IFwRoomRepairService;
|
|
|
import org.jeecg.modules.fw.vo.FwRoomLockVo;
|
|
import org.jeecg.modules.fw.vo.FwRoomLockVo;
|
|
|
import org.jeecg.modules.fw.vo.FwRoomRepairVo;
|
|
import org.jeecg.modules.fw.vo.FwRoomRepairVo;
|
|
|
-import org.jeecg.modules.pos.service.IPosJialiaoConfigDetailService;
|
|
|
|
|
-import org.jeecg.modules.pos.service.IPosMealSectionService;
|
|
|
|
|
import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
|
|
import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
|
|
|
|
|
+import org.jeecg.modules.rooms.Enum.TimeOutRuleEnum;
|
|
|
import org.jeecg.modules.rooms.Vo.BookingRealtimeVo;
|
|
import org.jeecg.modules.rooms.Vo.BookingRealtimeVo;
|
|
|
import org.jeecg.modules.rooms.Vo.FloorBuildingRoomVo;
|
|
import org.jeecg.modules.rooms.Vo.FloorBuildingRoomVo;
|
|
|
import org.jeecg.modules.rooms.Vo.LivingRealtimeVo;
|
|
import org.jeecg.modules.rooms.Vo.LivingRealtimeVo;
|
|
|
import org.jeecg.modules.rooms.entity.*;
|
|
import org.jeecg.modules.rooms.entity.*;
|
|
|
import org.jeecg.modules.rooms.service.*;
|
|
import org.jeecg.modules.rooms.service.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -53,12 +52,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.text.DateFormat;
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.Duration;
|
|
|
|
|
-import java.time.LocalDate;
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
|
-import java.time.ZoneId;
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -69,6 +65,7 @@ import java.util.stream.Collectors;
|
|
|
* @Date: 2023-03-25
|
|
* @Date: 2023-03-25
|
|
|
* @Version: V1.0
|
|
* @Version: V1.0
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingOrdersMapper, BusRoomBookingOrders> implements IBusRoomBookingOrdersService {
|
|
public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingOrdersMapper, BusRoomBookingOrders> implements IBusRoomBookingOrdersService {
|
|
|
|
|
|
|
@@ -125,7 +122,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private CesAllDayPriceRuleServiceImpl allDayPriceRuleService;
|
|
private CesAllDayPriceRuleServiceImpl allDayPriceRuleService;
|
|
|
-
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private CesGoodsServiceImpl cesGoodsServiceImpl;
|
|
private CesGoodsServiceImpl cesGoodsServiceImpl;
|
|
|
|
|
|
|
@@ -159,6 +155,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Resource
|
|
@Resource
|
|
|
private IBusCancelService cancelService;
|
|
private IBusCancelService cancelService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam,Boolean isLiving,String hotelId) {
|
|
public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam,Boolean isLiving,String hotelId) {
|
|
@@ -229,6 +228,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
newCustomer.setName(item.getContactName());
|
|
newCustomer.setName(item.getContactName());
|
|
|
newCustomer.setPhone(item.getPhone());
|
|
newCustomer.setPhone(item.getPhone());
|
|
|
newCustomer.setCertType(1); // 身份证
|
|
newCustomer.setCertType(1); // 身份证
|
|
|
|
|
+ newCustomer.setCertNo(item.getCertNo()); // 身份证
|
|
|
customerService.save(newCustomer);
|
|
customerService.save(newCustomer);
|
|
|
item.getOrderInfo().setContactId(newCustomer.getId());
|
|
item.getOrderInfo().setContactId(newCustomer.getId());
|
|
|
} else {
|
|
} else {
|
|
@@ -253,7 +253,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
throw new JeecgBootException("入住天数不能小于0");
|
|
throw new JeecgBootException("入住天数不能小于0");
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
if(item.getRoomIds() == null || item.getRoomIds().size() == 0)
|
|
if(item.getRoomIds() == null || item.getRoomIds().size() == 0)
|
|
|
throw new JeecgBootException("请选择预定房间");
|
|
throw new JeecgBootException("请选择预定房间");
|
|
|
if(hotelId == null || hotelId.isEmpty()) throw new JeecgBootException("参数错误,酒店id");
|
|
if(hotelId == null || hotelId.isEmpty()) throw new JeecgBootException("参数错误,酒店id");
|
|
@@ -316,32 +315,35 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
|
|
// 处理预定每天的房型价格 End
|
|
// 处理预定每天的房型价格 End
|
|
|
|
|
|
|
|
- //<editor-fold msg="团队标志">
|
|
|
|
|
- if(isTeam && isLiving) {
|
|
|
|
|
- BusTeam team = new BusTeam();
|
|
|
|
|
- List<BusTeam> existTeams = teamService.list(Wrappers.<BusTeam>query().eq("is_delete", 0).eq("hotel_id", hotelId)
|
|
|
|
|
- .eq("rel_type",1)); // 1团队房,2联房
|
|
|
|
|
- Integer sortIndex = 1;
|
|
|
|
|
- List<Integer> indexs = existTeams.stream().map(s->s.getSortIndex()).collect(Collectors.toList());
|
|
|
|
|
- while(true){
|
|
|
|
|
- Integer finalSortIndex = sortIndex;
|
|
|
|
|
- if(indexs.stream().filter(s->s.equals(finalSortIndex)).count() == 0) {
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ // 预约时不添加联房和团队标识,入住时才添加
|
|
|
|
|
+ if (isLiving) {
|
|
|
|
|
+ if(isTeam) {
|
|
|
|
|
+ BusTeam team = new BusTeam();
|
|
|
|
|
+ List<BusTeam> existTeams = teamService.list(Wrappers.<BusTeam>query().eq("is_delete", 0).eq("hotel_id", hotelId)
|
|
|
|
|
+ .eq("rel_type",1)); // 1团队房,2联房
|
|
|
|
|
+ Integer sortIndex = 1;
|
|
|
|
|
+ List<Integer> indexs = existTeams.stream().map(s->s.getSortIndex()).collect(Collectors.toList());
|
|
|
|
|
+ while(true){
|
|
|
|
|
+ Integer finalSortIndex = sortIndex;
|
|
|
|
|
+ if(indexs.stream().filter(s->s.equals(finalSortIndex)).count() == 0) {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ sortIndex++;
|
|
|
|
|
+ }
|
|
|
|
|
+ team.setBookingOrderId(bookingId);
|
|
|
|
|
+ team.setIsDelete(0);
|
|
|
|
|
+ team.setHotelId(hotelId);
|
|
|
|
|
+ team.setSortIndex(sortIndex);
|
|
|
|
|
+ team.setRelType(1);
|
|
|
|
|
+
|
|
|
|
|
+ teamService.save(team);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 散客同时居住
|
|
|
|
|
+ if(item.getRoomIds().size() > 1) {
|
|
|
|
|
+ addBusTeams(hotelId, bookingId);
|
|
|
}
|
|
}
|
|
|
- sortIndex++;
|
|
|
|
|
}
|
|
}
|
|
|
- team.setBookingOrderId(bookingId);
|
|
|
|
|
- team.setIsDelete(0);
|
|
|
|
|
- team.setHotelId(hotelId);
|
|
|
|
|
- team.setSortIndex(sortIndex);
|
|
|
|
|
- team.setRelType(1);
|
|
|
|
|
|
|
|
|
|
- teamService.save(team);
|
|
|
|
|
- } else {
|
|
|
|
|
-// if(isLiving && item.getRoomIds().size() > 1) {
|
|
|
|
|
-// if(item.getRoomIds().size() > 1) {
|
|
|
|
|
-// addBusTeams(hotelId, bookingId);
|
|
|
|
|
-// }
|
|
|
|
|
}
|
|
}
|
|
|
//</editor-fold>
|
|
//</editor-fold>
|
|
|
roomsService.getReserveRoom();
|
|
roomsService.getReserveRoom();
|
|
@@ -417,6 +419,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
dayPriceService.saveBatch(c.getLayoutDayPrices().stream().filter(x->lList.contains(x.getRoomLayoutId())).collect(Collectors.toList()));
|
|
dayPriceService.saveBatch(c.getLayoutDayPrices().stream().filter(x->lList.contains(x.getRoomLayoutId())).collect(Collectors.toList()));
|
|
|
//批次中处理每天房型价格 End
|
|
//批次中处理每天房型价格 End
|
|
|
});
|
|
});
|
|
|
|
|
+ // 改变房间状态
|
|
|
roomsService.getReserveRoom();
|
|
roomsService.getReserveRoom();
|
|
|
return item.getOrderInfo().getBookingOrdersNo();
|
|
return item.getOrderInfo().getBookingOrdersNo();
|
|
|
} else { // not exist type
|
|
} else { // not exist type
|
|
@@ -464,19 +467,25 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
BookingOrderEditVo result = new BookingOrderEditVo();
|
|
BookingOrderEditVo result = new BookingOrderEditVo();
|
|
|
if(orderInfo.getBookingOrdersType().equals(BookingOrdersType.NORMAL.getKey())) {
|
|
if(orderInfo.getBookingOrdersType().equals(BookingOrdersType.NORMAL.getKey())) {
|
|
|
List<ExtendBusBookingRoomsVo> bookingRooms = bookingRoomsService.bookingRooms(orderId,BookingOrdersType.NORMAL.getKey());
|
|
List<ExtendBusBookingRoomsVo> bookingRooms = bookingRoomsService.bookingRooms(orderId,BookingOrdersType.NORMAL.getKey());
|
|
|
|
|
+
|
|
|
List<BusBookingLayoutDayPrice> layoutDayPrices = dayPriceService.list(Wrappers.<BusBookingLayoutDayPrice>query()
|
|
List<BusBookingLayoutDayPrice> layoutDayPrices = dayPriceService.list(Wrappers.<BusBookingLayoutDayPrice>query()
|
|
|
.eq("booking_order_id",orderId));
|
|
.eq("booking_order_id",orderId));
|
|
|
bookingRooms.forEach(s->{
|
|
bookingRooms.forEach(s->{
|
|
|
List<BusBookingLayoutDayPrice> findLayoutPrice = layoutDayPrices.stream().filter(a->a.getRoomLayoutId().equals(s.getRoomLayoutId())).collect(Collectors.toList());
|
|
List<BusBookingLayoutDayPrice> findLayoutPrice = layoutDayPrices.stream().filter(a->a.getRoomLayoutId().equals(s.getRoomLayoutId())).collect(Collectors.toList());
|
|
|
s.setLayoutDayPrices(findLayoutPrice);
|
|
s.setLayoutDayPrices(findLayoutPrice);
|
|
|
});
|
|
});
|
|
|
- result.setLayoutDayPrices(layoutDayPrices);
|
|
|
|
|
- // 设置不是住脏或者住净的 预约中的房间
|
|
|
|
|
- result.setRoomIds(bookingRooms.stream().filter(r->!(r.getRoomStatus().equals(RoomStatusEnum.LIVE_DIRTY.getKey()) || r.getRoomStatus().equals(RoomStatusEnum.LIVE_CLEAR.getKey()))).collect(Collectors.toList()));
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(orderInfo.getBookingStatus()) && orderInfo.getBookingStatus() == 2){
|
|
|
|
|
+ result.setLayoutDayPrices(new ArrayList<>());
|
|
|
|
|
+ // 设置不是住脏或者住净的 预约中的房间
|
|
|
|
|
+ result.setRoomIds(new ArrayList<>());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ result.setLayoutDayPrices(layoutDayPrices);
|
|
|
|
|
+ // 设置不是住脏或者住净的 预约中的房间
|
|
|
|
|
+ result.setRoomIds(bookingRooms.stream().filter(r->!(r.getRoomStatus().equals(RoomStatusEnum.LIVE_DIRTY.getKey()) || r.getRoomStatus().equals(RoomStatusEnum.LIVE_CLEAR.getKey()))).collect(Collectors.toList()));
|
|
|
|
|
+ }
|
|
|
//<editor-fold msg="入住相关信息查询">
|
|
//<editor-fold msg="入住相关信息查询">
|
|
|
List<ExtendBusBookingRoomsVo> livingRooms = bookingRooms.stream().filter(r->(r.getRoomStatus().equals(RoomStatusEnum.LIVE_DIRTY.getKey()) || r.getRoomStatus().equals(RoomStatusEnum.LIVE_CLEAR.getKey()))).collect(Collectors.toList());
|
|
List<ExtendBusBookingRoomsVo> livingRooms = bookingRooms.stream().filter(r->(r.getRoomStatus().equals(RoomStatusEnum.LIVE_DIRTY.getKey()) || r.getRoomStatus().equals(RoomStatusEnum.LIVE_CLEAR.getKey()))).collect(Collectors.toList());
|
|
|
List<String> livingBookingRoomIds = livingRooms.stream().map(r->r.getId()).collect(Collectors.toList());
|
|
List<String> livingBookingRoomIds = livingRooms.stream().map(r->r.getId()).collect(Collectors.toList());
|
|
|
-
|
|
|
|
|
List<BusRoomsLivingOrder> livingOrders =
|
|
List<BusRoomsLivingOrder> livingOrders =
|
|
|
livingBookingRoomIds.size() > 0?
|
|
livingBookingRoomIds.size() > 0?
|
|
|
roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
|
|
roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
|
|
@@ -622,7 +631,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
updateById(item.getOrderInfo());
|
|
updateById(item.getOrderInfo());
|
|
|
String bookingId = item.getOrderInfo().getId();
|
|
String bookingId = item.getOrderInfo().getId();
|
|
|
// todo 判定是否有安排冲突的房间
|
|
// todo 判定是否有安排冲突的房间
|
|
|
-
|
|
|
|
|
|
|
+ List<String> roomIds = item.getRoomIds().stream().map(BusBookingRooms::getRoomId).collect(Collectors.toList());
|
|
|
|
|
+ List<BusRoomBookingOrders> clashOrder = baseMapper.findBookingOrder(roomIds, item.getOrderInfo().getArrivalTime(), item.getOrderInfo().getDueOutTime());
|
|
|
|
|
+ long clashCount = clashOrder.stream().filter(e -> !StrUtil.equals(e.getId(), order.getId())).count();
|
|
|
|
|
+ if (clashCount > 0){
|
|
|
|
|
+ throw new JeecgBootException("房间预约有冲突");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//这里不能直接删除 先查询预订单有没有入住记录,如果房间有入住,那么入住过的记录则不能删除
|
|
//这里不能直接删除 先查询预订单有没有入住记录,如果房间有入住,那么入住过的记录则不能删除
|
|
|
List<BusRoomsLivingOrder> bookingLivings = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
|
|
List<BusRoomsLivingOrder> bookingLivings = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
|
|
@@ -786,10 +800,16 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
public Boolean setOrderStatus(BusRoomBookingOrders entity) {
|
|
public Boolean setOrderStatus(BusRoomBookingOrders entity) {
|
|
|
if(entity.getId() == null || entity.getBookingStatus() == null) throw new JeecgBootException("参数错误");
|
|
if(entity.getId() == null || entity.getBookingStatus() == null) throw new JeecgBootException("参数错误");
|
|
|
if(BookingStatusTypeEnum.val(entity.getBookingStatus()) == null) throw new JeecgBootException("状态错误");
|
|
if(BookingStatusTypeEnum.val(entity.getBookingStatus()) == null) throw new JeecgBootException("状态错误");
|
|
|
- BusRoomBookingOrders updateModel = new BusRoomBookingOrders();
|
|
|
|
|
- updateModel.setId(entity.getId());
|
|
|
|
|
- updateModel.setBookingStatus(entity.getBookingStatus());
|
|
|
|
|
- updateById(updateModel);
|
|
|
|
|
|
|
+ LambdaUpdateWrapper<BusRoomBookingOrders> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.set(BusRoomBookingOrders::getBookingStatus, entity.getBookingStatus());
|
|
|
|
|
+ updateWrapper.eq(BusRoomBookingOrders::getId, entity.getId());
|
|
|
|
|
+ update(updateWrapper);
|
|
|
|
|
+ if (BookingStatusTypeEnum.CANCEL.getKey().equals(entity.getBookingStatus())){
|
|
|
|
|
+ List<BusBookingRooms> bookingRoomsList = bookingRoomsService.list(Wrappers.<BusBookingRooms>lambdaQuery().eq(BusBookingRooms::getBookingOrdersId, entity.getId()));
|
|
|
|
|
+ List<String> roomIds = bookingRoomsList.stream().map(BusBookingRooms::getRoomId).collect(Collectors.toList());
|
|
|
|
|
+ roomsService.update(Wrappers.<CesRooms>update().setSql("room_status = last_room_status")
|
|
|
|
|
+ .eq("room_status",RoomStatusEnum.RESERVE.getKey()).in("id",roomIds));
|
|
|
|
|
+ }
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1019,7 +1039,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
livingOrder.setHotelId(hotelId);
|
|
livingOrder.setHotelId(hotelId);
|
|
|
|
|
|
|
|
livingOrder.setArrivalTime(new Date());// todo 这个地方的入住开始时间应该怎么算
|
|
livingOrder.setArrivalTime(new Date());// todo 这个地方的入住开始时间应该怎么算
|
|
|
- if(customers.size() > 0) livingOrder.setContactId(customers.get(0).getCustomerId());
|
|
|
|
|
|
|
+ if(customers != null && !customers.isEmpty()) {
|
|
|
|
|
+ if (StrUtil.isEmpty(customers.get(0).getCustomerId())){
|
|
|
|
|
+ long id = new Snowflake().nextId();
|
|
|
|
|
+ customers.get(0).setCustomerId(StrUtil.toString(id));
|
|
|
|
|
+ }
|
|
|
|
|
+ livingOrder.setContactId(customers.get(0).getCustomerId());
|
|
|
|
|
+ } else throw new JeecgBootException("请添加入住人信息");
|
|
|
roomsLivingOrderService.save(livingOrder);
|
|
roomsLivingOrderService.save(livingOrder);
|
|
|
|
|
|
|
|
// 添加查房记录 start
|
|
// 添加查房记录 start
|
|
@@ -1042,7 +1068,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
//</editor-fold>
|
|
//</editor-fold>
|
|
|
|
|
|
|
|
//<editor-fold desc="同住人相关">
|
|
//<editor-fold desc="同住人相关">
|
|
|
- if(customers != null && customers.size() > 0) {
|
|
|
|
|
|
|
+
|
|
|
BusRoomsLivingOrder finalLivingOrder = livingOrder;
|
|
BusRoomsLivingOrder finalLivingOrder = livingOrder;
|
|
|
customers.forEach(s->{
|
|
customers.forEach(s->{
|
|
|
// 【添加客人信息 Start】
|
|
// 【添加客人信息 Start】
|
|
@@ -1056,8 +1082,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
newCustomer.setCreateUser("");
|
|
newCustomer.setCreateUser("");
|
|
|
newCustomer.setTenantId(user.getRelTenantIds());
|
|
newCustomer.setTenantId(user.getRelTenantIds());
|
|
|
newCustomer.setName(s.getCustomerName());
|
|
newCustomer.setName(s.getCustomerName());
|
|
|
|
|
+ newCustomer.setGender(s.getGender());
|
|
|
newCustomer.setPhone(s.getPhone());
|
|
newCustomer.setPhone(s.getPhone());
|
|
|
newCustomer.setCertType(1); // 身份证
|
|
newCustomer.setCertType(1); // 身份证
|
|
|
|
|
+ newCustomer.setCertNo(s.getCertNo()); // 身份证
|
|
|
customerService.save(newCustomer);
|
|
customerService.save(newCustomer);
|
|
|
s.setCustomerId(newCustomer.getId());
|
|
s.setCustomerId(newCustomer.getId());
|
|
|
} else {
|
|
} else {
|
|
@@ -1068,9 +1096,11 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
livingCustomerService.save(s);
|
|
livingCustomerService.save(s);
|
|
|
// 【添加客人信息 end】
|
|
// 【添加客人信息 end】
|
|
|
});
|
|
});
|
|
|
- } else throw new JeecgBootException("请添加入住人信息");
|
|
|
|
|
|
|
+
|
|
|
//</editor-fold>
|
|
//</editor-fold>
|
|
|
|
|
|
|
|
|
|
+ //</editor-fold>
|
|
|
|
|
+
|
|
|
//<editor-fold desc="todo:账单相关">
|
|
//<editor-fold desc="todo:账单相关">
|
|
|
if(bookingLiving != null && bookingLiving) {
|
|
if(bookingLiving != null && bookingLiving) {
|
|
|
BigDecimal money = new BigDecimal(0);
|
|
BigDecimal money = new BigDecimal(0);
|
|
@@ -1099,6 +1129,17 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
dayOrderFee.setHotelId(hotelId);
|
|
dayOrderFee.setHotelId(hotelId);
|
|
|
feeService.save(dayOrderFee);
|
|
feeService.save(dayOrderFee);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ CesAllDayPriceRule cesAllDayPriceRule = allDayPriceRuleService.getOne(Wrappers.<CesAllDayPriceRule>lambdaQuery().eq(CesAllDayPriceRule::getHotelId,hotelId).eq(CesAllDayPriceRule::getInvalid,false));
|
|
|
|
|
+ if(ObjectUtils.isEmpty(cesAllDayPriceRule)) {
|
|
|
|
|
+ throw new JeecgBootException("未找到超时收费规则");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
|
+ calendar.setTime(livingOrder.getDueOutTime());
|
|
|
|
|
+ calendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), calendar.getTimeInMillis());
|
|
|
|
|
+ roomsService.getReserveRoom();
|
|
|
//</editor-fold>
|
|
//</editor-fold>
|
|
|
return livingOrder.getId();
|
|
return livingOrder.getId();
|
|
|
}
|
|
}
|
|
@@ -1107,7 +1148,11 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String customerLiving(BookingOrderSaveDto livingData, Boolean isTeam, String hotelId) {
|
|
public String customerLiving(BookingOrderSaveDto livingData, Boolean isTeam, String hotelId) {
|
|
|
List<String> roomIds = livingData.getRoomIds().stream().map(BookingLayoutRoomsDto::getRoomId).collect(Collectors.toList());
|
|
List<String> roomIds = livingData.getRoomIds().stream().map(BookingLayoutRoomsDto::getRoomId).collect(Collectors.toList());
|
|
|
-
|
|
|
|
|
|
|
+ List<CesRooms> rooms = roomsService.listByIds(roomIds);
|
|
|
|
|
+ Optional<CesRooms> optional = rooms.stream().filter(e -> StrUtil.isNotEmpty(e.getLivingOrderId())).findFirst();
|
|
|
|
|
+ if (optional.isPresent()){
|
|
|
|
|
+ throw new JeecgBootException("房间已被入住");
|
|
|
|
|
+ }
|
|
|
// 是预约单先将预约单与房间关联删掉。因为原来这个接口是自己入住的接口,后来预定也要调这个接口,只能先将预定时添加的BusRoomBookingOrders关联表删掉,重新进行关联
|
|
// 是预约单先将预约单与房间关联删掉。因为原来这个接口是自己入住的接口,后来预定也要调这个接口,只能先将预定时添加的BusRoomBookingOrders关联表删掉,重新进行关联
|
|
|
if(StrUtil.isNotEmpty(livingData.getOrderInfo().getId())){
|
|
if(StrUtil.isNotEmpty(livingData.getOrderInfo().getId())){
|
|
|
BusRoomBookingOrders bookingOrders = getById(livingData.getOrderInfo().getId());
|
|
BusRoomBookingOrders bookingOrders = getById(livingData.getOrderInfo().getId());
|
|
@@ -1121,7 +1166,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
BookingOrderEditVo bookingOrderVo = getBookingInfoById(null,bookingOrderNo);
|
|
BookingOrderEditVo bookingOrderVo = getBookingInfoById(null,bookingOrderNo);
|
|
|
// 散客取roomIds
|
|
// 散客取roomIds
|
|
|
if(bookingOrderVo.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.NORMAL.getKey())) {
|
|
if(bookingOrderVo.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.NORMAL.getKey())) {
|
|
|
- //
|
|
|
|
|
|
|
+ // 返回map中key为房间id, value为居住单id 。该方法添加房间,费用等入住信息,
|
|
|
Map<String,String> roomOrderMap = bookingRoomToLiving(livingData, bookingOrderVo.getRoomIds(), bookingOrderVo,hotelId);
|
|
Map<String,String> roomOrderMap = bookingRoomToLiving(livingData, bookingOrderVo.getRoomIds(), bookingOrderVo,hotelId);
|
|
|
livingData.getLivingRoomDayPrices().forEach(g->{
|
|
livingData.getLivingRoomDayPrices().forEach(g->{
|
|
|
String livingOrderId = roomOrderMap.get(g.getRoomId());
|
|
String livingOrderId = roomOrderMap.get(g.getRoomId());
|
|
@@ -1133,6 +1178,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
livingLayoutDayPriceService.saveBatch(livingData.getLivingRoomDayPrices());
|
|
livingLayoutDayPriceService.saveBatch(livingData.getLivingRoomDayPrices());
|
|
|
} else if(bookingOrderVo.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
|
|
} else if(bookingOrderVo.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
|
|
|
bookingOrderVo.getBatchRooms().forEach(b->{
|
|
bookingOrderVo.getBatchRooms().forEach(b->{
|
|
|
|
|
+ /*保存入住单,保存入住费用*/
|
|
|
bookingRoomToLiving(livingData, b.getRoomIds(), bookingOrderVo,hotelId);
|
|
bookingRoomToLiving(livingData, b.getRoomIds(), bookingOrderVo,hotelId);
|
|
|
});
|
|
});
|
|
|
} else throw new JeecgBootException("订单类型错误");
|
|
} else throw new JeecgBootException("订单类型错误");
|
|
@@ -1162,26 +1208,49 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
.in("living_order_id",livingOrderIds)):new ArrayList<>();
|
|
.in("living_order_id",livingOrderIds)):new ArrayList<>();
|
|
|
List<BusLivingLayoutDayPrice> livingLayoutDayPrices =livingOrderIds.size()>0? livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
|
|
List<BusLivingLayoutDayPrice> livingLayoutDayPrices =livingOrderIds.size()>0? livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
|
|
|
.in("living_order_id",livingOrderIds)):new ArrayList<>();
|
|
.in("living_order_id",livingOrderIds)):new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<BusTeam> teamOrders_all = teamService.list(Wrappers.<BusTeam>lambdaQuery().eq(BusTeam::getIsDelete, 0));
|
|
|
|
|
+ List<String> booingIds = teamOrders_all.stream().map(BusTeam::getBookingOrderId).collect(Collectors.toList());
|
|
|
|
|
+// List<BusBookingRooms> bookingRoomsList = bookingRoomsService.bookingRoomsDetail(Wrappers.<BusBookingRooms>lambdaQuery().in(BusBookingRooms::getBookingOrdersId, booingIds));
|
|
|
|
|
+ List<BusBookingRooms> bookingRoomsList = bookingRoomsService.bookingRoomsDetail(booingIds);
|
|
|
|
|
+
|
|
|
rooms.forEach(s-> {
|
|
rooms.forEach(s-> {
|
|
|
FloorBuildingRoomVo vo = new FloorBuildingRoomVo();
|
|
FloorBuildingRoomVo vo = new FloorBuildingRoomVo();
|
|
|
vo.setRoomId(s.getId());
|
|
vo.setRoomId(s.getId());
|
|
|
vo.setBookingData(new BookingRealtimeVo());
|
|
vo.setBookingData(new BookingRealtimeVo());
|
|
|
vo.setLivingData(new LivingRealtimeVo());
|
|
vo.setLivingData(new LivingRealtimeVo());
|
|
|
|
|
+ // 通过房间id找出对应的预约单号, 实际上目前数据库房间表的预约订单id全部未空
|
|
|
Optional<TodayBookingQueryDto> optionalTodayBookingQueryDto = roomBookingOrders.stream().filter(t->t.getRoomId().equals(s.getId())).findFirst();
|
|
Optional<TodayBookingQueryDto> optionalTodayBookingQueryDto = roomBookingOrders.stream().filter(t->t.getRoomId().equals(s.getId())).findFirst();
|
|
|
if(optionalTodayBookingQueryDto.isPresent()) {
|
|
if(optionalTodayBookingQueryDto.isPresent()) {
|
|
|
s.setBookingOrderId(optionalTodayBookingQueryDto.get().getBookingOrderId());
|
|
s.setBookingOrderId(optionalTodayBookingQueryDto.get().getBookingOrderId());
|
|
|
|
|
+ // 找出当前房间的预约单
|
|
|
Optional<BusRoomBookingOrders> opBookingOrder = bookingOrders.stream().filter(a->a.getId().equals(s.getBookingOrderId())).findFirst();
|
|
Optional<BusRoomBookingOrders> opBookingOrder = bookingOrders.stream().filter(a->a.getId().equals(s.getBookingOrderId())).findFirst();
|
|
|
if(opBookingOrder.isPresent()) {
|
|
if(opBookingOrder.isPresent()) {
|
|
|
|
|
+ //设置团队联房标签
|
|
|
|
|
+ Optional<BusTeam> opTeam = teamOrders_all.stream().filter(r->r.getBookingOrderId().equals(opBookingOrder.get().getId())).findFirst();
|
|
|
|
|
+ if(opTeam.isPresent()) {
|
|
|
|
|
+ BusTeam t = opTeam.get();
|
|
|
|
|
+ if(t.getRelType().equals(1)) {
|
|
|
|
|
+ opBookingOrder.get().setIsTeam(true);
|
|
|
|
|
+ opBookingOrder.get().setTeamTag("团"+t.getSortIndex());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ opBookingOrder.get().setIsRel(true);
|
|
|
|
|
+ opBookingOrder.get().setRelTag("联"+t.getSortIndex());
|
|
|
|
|
+ }
|
|
|
|
|
+ // 关联房间
|
|
|
|
|
+ List<BusBookingRooms> releBookingRooms = bookingRoomsList.stream().filter(e ->
|
|
|
|
|
+ opBookingOrder.get().getId().equals(e.getBookingOrdersId())).collect(Collectors.toList());
|
|
|
|
|
+ vo.getBookingData().setReleBookingRooms(releBookingRooms);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
vo.getBookingData().setBookingOrder(opBookingOrder.get());
|
|
vo.getBookingData().setBookingOrder(opBookingOrder.get());
|
|
|
Optional<BusCustomer> opBookingCustomer = bookingCustomers.stream().filter(a->a.getId().equals(opBookingOrder.get().getContactId())).findFirst();
|
|
Optional<BusCustomer> opBookingCustomer = bookingCustomers.stream().filter(a->a.getId().equals(opBookingOrder.get().getContactId())).findFirst();
|
|
|
- if(opBookingCustomer.isPresent()){
|
|
|
|
|
- vo.getBookingData().setBookingCustomer(opBookingCustomer.get());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ opBookingCustomer.ifPresent(customer -> vo.getBookingData().setBookingCustomer(customer));
|
|
|
vo.getBookingData().setLayoutDayPrices(bookingLayoutDayPrices.stream().filter(a->a.getBookingOrderId().equals(opBookingOrder.get().getId())).collect(Collectors.toList()));
|
|
vo.getBookingData().setLayoutDayPrices(bookingLayoutDayPrices.stream().filter(a->a.getBookingOrderId().equals(opBookingOrder.get().getId())).collect(Collectors.toList()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 找出当前房间的居住单
|
|
|
Optional<BusRoomsLivingOrder> opLivingOrder=livingOrders.stream().filter(a->a.getId().equals(s.getLivingOrderId())).findFirst();
|
|
Optional<BusRoomsLivingOrder> opLivingOrder=livingOrders.stream().filter(a->a.getId().equals(s.getLivingOrderId())).findFirst();
|
|
|
if(opLivingOrder.isPresent()) {
|
|
if(opLivingOrder.isPresent()) {
|
|
|
BusRoomsLivingOrder livingOrder = opLivingOrder.get();
|
|
BusRoomsLivingOrder livingOrder = opLivingOrder.get();
|
|
@@ -1190,14 +1259,25 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
livingOrder.setShouKuan(feeMap.get("sk"));
|
|
livingOrder.setShouKuan(feeMap.get("sk"));
|
|
|
// 获取入住天数
|
|
// 获取入住天数
|
|
|
livingOrder.setLiveDayCount(getLivingDayCount(livingOrder));
|
|
livingOrder.setLiveDayCount(getLivingDayCount(livingOrder));
|
|
|
-
|
|
|
|
|
|
|
+ // 设置居住单的团队联房标签
|
|
|
|
|
+ Optional<BusTeam> opTeam = teamOrders_all.stream().filter(r->r.getBookingOrderId().equals(livingOrder.getBookingOrderId())).findFirst();
|
|
|
|
|
+ if(opTeam.isPresent()) {
|
|
|
|
|
+ BusTeam t = opTeam.get();
|
|
|
|
|
+ if(t.getRelType().equals(1)) {
|
|
|
|
|
+ livingOrder.setIsTeam(true);
|
|
|
|
|
+ livingOrder.setTeamTag("团"+opTeam.get().getSortIndex());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ livingOrder.setIsRel(true);
|
|
|
|
|
+ livingOrder.setRelTag("联"+opTeam.get().getSortIndex());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<BusBookingRooms> releBookingRooms = bookingRoomsList.stream().filter(e ->
|
|
|
|
|
+ livingOrder.getBookingOrderId().equals(e.getBookingOrdersId())).collect(Collectors.toList());
|
|
|
|
|
+ vo.getBookingData().setReleBookingRooms(releBookingRooms);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 赋值
|
|
|
vo.getLivingData().setLivingOrder(livingOrder);
|
|
vo.getLivingData().setLivingOrder(livingOrder);
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
Optional<BusLivingCustomer> opLivingCustomer = livingCustomers.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).findFirst();
|
|
Optional<BusLivingCustomer> opLivingCustomer = livingCustomers.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).findFirst();
|
|
|
- if(opLivingCustomer.isPresent()) {
|
|
|
|
|
- vo.getLivingData().setLivingCustomers(opLivingCustomer.get());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ opLivingCustomer.ifPresent(busLivingCustomer -> vo.getLivingData().setLivingCustomers(busLivingCustomer));
|
|
|
vo.getLivingData().setPrice(
|
|
vo.getLivingData().setPrice(
|
|
|
livingLayoutDayPrices.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).collect(Collectors.toList())
|
|
livingLayoutDayPrices.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).collect(Collectors.toList())
|
|
|
);
|
|
);
|
|
@@ -1368,6 +1448,220 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public Boolean syncRoomOrder(String hotelId) {
|
|
|
|
|
+ // 查询出当前时间内需要处理的超时订单
|
|
|
|
|
+ Set<Object> set = redisTemplate.opsForZSet().rangeByScore("overTimerOrder", 0, Calendar.getInstance().getTimeInMillis());
|
|
|
|
|
+ CesAllDayPriceRule cesAllDayPriceRule = allDayPriceRuleService.getOne(Wrappers.<CesAllDayPriceRule>lambdaQuery().eq(CesAllDayPriceRule::getHotelId,hotelId).eq(CesAllDayPriceRule::getInvalid,false));
|
|
|
|
|
+ if(CollUtil.isEmpty(set)){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(ObjectUtils.isEmpty(cesAllDayPriceRule)) {
|
|
|
|
|
+ throw new JeecgBootException("未找到超时收费规则");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果房间超时是按分钟加收费用
|
|
|
|
|
+ if (TimeOutRuleEnum.ADD_BY_MINUTE.getKey().equals(cesAllDayPriceRule.getTimeOutRule())){
|
|
|
|
|
+ addByMinute(set, cesAllDayPriceRule);
|
|
|
|
|
+ }else if (TimeOutRuleEnum.ADD_BY_DAY.getKey().equals(cesAllDayPriceRule.getTimeOutRule())){
|
|
|
|
|
+ addByDay(set, cesAllDayPriceRule);
|
|
|
|
|
+ }else if (TimeOutRuleEnum.NOT_ADD.getKey().equals(cesAllDayPriceRule.getTimeOutRule())) {
|
|
|
|
|
+ notAdd(set, cesAllDayPriceRule);
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 超时收费规则是按分钟
|
|
|
|
|
+ */
|
|
|
|
|
+ public void addByMinute(Set<Object> set, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+ Calendar nextCalendar = Calendar.getInstance();
|
|
|
|
|
+ set.forEach(e -> {
|
|
|
|
|
+ nextCalendar.setTime(date);
|
|
|
|
|
+ BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(e.toString());
|
|
|
|
|
+ if(ObjectUtil.isNotEmpty(livingOrder)){
|
|
|
|
|
+ BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
|
|
+ if (ObjectUtil.isEmpty(bookingroom)){
|
|
|
|
|
+ throw new JeecgBootException("未找到订单对应的房间");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 查询当天房间超时消费
|
|
|
|
|
+ BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
|
|
+ // 需要支付完整费用时间的最后时间
|
|
|
|
|
+ Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
|
|
+ // 当前时间加上超时收费时间
|
|
|
|
|
+ nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
|
|
+ // 当前时间加上超时收费时间 < 按全天收费时间的标准
|
|
|
|
|
+ if (nextCalendar.getTime().compareTo(endTime) < 0){
|
|
|
|
|
+ // 不满足的情况下,添加超时收费,设置下一次收费时间戳
|
|
|
|
|
+ fee.setDayTime(date);
|
|
|
|
|
+ fee.setMoney(fee.getMoney().add(cesAllDayPriceRule.getPrice()));
|
|
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
|
|
+
|
|
|
|
|
+ // 如果下一次增加收费时间大于 全天收费时间 设置
|
|
|
|
|
+ }else {
|
|
|
|
|
+ // 如果满足全天收费要求,预离时间增加1天
|
|
|
|
|
+ CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
|
|
+ fee.setMoney(layout.getMarketPrice());
|
|
|
|
|
+ nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
|
|
+ nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
|
|
+ livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
|
|
+ roomsLivingOrderService.updateById(livingOrder);
|
|
|
|
|
+ // 下一次收费时间戳
|
|
|
|
|
+ nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
|
|
+ // 添加每日房费
|
|
|
|
|
+ BusLivingLayoutDayPrice nPrice = new BusLivingLayoutDayPrice();
|
|
|
|
|
+ nPrice.setBookingRoomId(livingOrder.getBookingRoomId());
|
|
|
|
|
+ try {
|
|
|
|
|
+ nPrice.setDayTime(DateUtils.parseDate(DateUtils.formatDate(new Date()),"yyyy-MM-dd"));
|
|
|
|
|
+ } catch (ParseException ex) {
|
|
|
|
|
+ throw new RuntimeException(ex);
|
|
|
|
|
+ }
|
|
|
|
|
+ nPrice.setRoomId(bookingroom.getRoomId());
|
|
|
|
|
+ nPrice.setRoomLayoutId(bookingroom.getRoomLayoutId());
|
|
|
|
|
+ nPrice.setPrice(layout.getMarketPrice());
|
|
|
|
|
+ nPrice.setLivingOrderId(livingOrder.getId());
|
|
|
|
|
+ nPrice.setLivingType(livingOrder.getLivingType());
|
|
|
|
|
+ livingLayoutDayPriceService.save(nPrice);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
|
|
+ feeService.saveOrUpdate(fee);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void addByDay(Set<Object> set, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+ Calendar nextCalendar = Calendar.getInstance();
|
|
|
|
|
+ set.forEach(e -> {
|
|
|
|
|
+ BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(e.toString());
|
|
|
|
|
+ if(ObjectUtil.isNotEmpty(livingOrder)) {
|
|
|
|
|
+ BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
|
|
+ if (ObjectUtil.isEmpty(bookingroom)) {
|
|
|
|
|
+ log.info("未找到订单{}对应的房间", livingOrder.getId());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
|
|
+ // 查询当天房间超时消费
|
|
|
|
|
+ BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
|
|
+ // 需要支付完整费用时间的最后时间
|
|
|
|
|
+ Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
|
|
+ if (nextCalendar.getTime().compareTo(endTime) < 0){
|
|
|
|
|
+ fee.setMoney(layout.getMarketPrice().divide(new BigDecimal(2)));
|
|
|
|
|
+ nextCalendar.setTime(endTime);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fee.setMoney(layout.getMarketPrice());
|
|
|
|
|
+ nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
|
|
+ nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
|
|
+ livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
|
|
+ roomsLivingOrderService.updateById(livingOrder);
|
|
|
|
|
+ // 下一次收费时间戳
|
|
|
|
|
+ nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
|
|
+ // 添加每日房费
|
|
|
|
|
+ BusLivingLayoutDayPrice nPrice = new BusLivingLayoutDayPrice();
|
|
|
|
|
+ nPrice.setBookingRoomId(livingOrder.getBookingRoomId());
|
|
|
|
|
+ try {
|
|
|
|
|
+ nPrice.setDayTime(DateUtils.parseDate(DateUtils.formatDate(new Date()),"yyyy-MM-dd"));
|
|
|
|
|
+ } catch (ParseException ex) {
|
|
|
|
|
+ throw new RuntimeException(ex);
|
|
|
|
|
+ }
|
|
|
|
|
+ nPrice.setRoomId(bookingroom.getRoomId());
|
|
|
|
|
+ nPrice.setRoomLayoutId(bookingroom.getRoomLayoutId());
|
|
|
|
|
+ nPrice.setPrice(layout.getMarketPrice());
|
|
|
|
|
+ nPrice.setLivingOrderId(livingOrder.getId());
|
|
|
|
|
+ nPrice.setLivingType(livingOrder.getLivingType());
|
|
|
|
|
+ livingLayoutDayPriceService.save(nPrice);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
|
|
+ feeService.saveOrUpdate(fee);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void notAdd(Set<Object> set, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
|
|
+ Date date = new Date();
|
|
|
|
|
+ Calendar nextCalendar = Calendar.getInstance();
|
|
|
|
|
+ set.forEach(e -> {
|
|
|
|
|
+ BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(e.toString());
|
|
|
|
|
+ if(ObjectUtil.isNotEmpty(livingOrder)) {
|
|
|
|
|
+ BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
|
|
+ if (ObjectUtil.isEmpty(bookingroom)) {
|
|
|
|
|
+ throw new JeecgBootException("未找到订单对应的房间");
|
|
|
|
|
+ }
|
|
|
|
|
+ CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
|
|
+ // 查询当天房间超时消费
|
|
|
|
|
+ BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
|
|
+ // 需要支付完整费用时间的最后时间
|
|
|
|
|
+ Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
|
|
+ if (nextCalendar.getTime().compareTo(endTime) >= 0){
|
|
|
|
|
+ fee.setMoney(layout.getMarketPrice());
|
|
|
|
|
+ nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
|
|
+ nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
|
|
+ livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
|
|
+ roomsLivingOrderService.updateById(livingOrder);
|
|
|
|
|
+ // 下一次收费时间戳
|
|
|
|
|
+ nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
|
|
+ // 添加每日房费
|
|
|
|
|
+ BusLivingLayoutDayPrice nPrice = new BusLivingLayoutDayPrice();
|
|
|
|
|
+ nPrice.setBookingRoomId(livingOrder.getBookingRoomId());
|
|
|
|
|
+ try {
|
|
|
|
|
+ nPrice.setDayTime(DateUtils.parseDate(DateUtils.formatDate(new Date()),"yyyy-MM-dd"));
|
|
|
|
|
+ } catch (ParseException ex) {
|
|
|
|
|
+ throw new RuntimeException(ex);
|
|
|
|
|
+ }
|
|
|
|
|
+ nPrice.setRoomId(bookingroom.getRoomId());
|
|
|
|
|
+ nPrice.setRoomLayoutId(bookingroom.getRoomLayoutId());
|
|
|
|
|
+ nPrice.setPrice(layout.getMarketPrice());
|
|
|
|
|
+ nPrice.setLivingOrderId(livingOrder.getId());
|
|
|
|
|
+ nPrice.setLivingType(livingOrder.getLivingType());
|
|
|
|
|
+ livingLayoutDayPriceService.save(nPrice);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
|
|
+ feeService.saveOrUpdate(fee);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public BusOrderFee getOverTimeFee(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom){
|
|
|
|
|
+ BusOrderFee fee = feeService.getOne(Wrappers.<BusOrderFee>lambdaQuery()
|
|
|
|
|
+ .eq(BusOrderFee::getLivingOrderId, livingOrder.getId()).eq(BusOrderFee::getPreferentialStatus, "1")
|
|
|
|
|
+ .eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()).gt(BusOrderFee::getCreateTime, livingOrder.getDueOutTime()));
|
|
|
|
|
+ if (ObjectUtil.isEmpty(fee)){
|
|
|
|
|
+ fee = new BusOrderFee();
|
|
|
|
|
+ fee.setMoney(new BigDecimal(0));
|
|
|
|
|
+ fee.setCreateTime(new Date());
|
|
|
|
|
+ fee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
|
|
|
|
|
+ fee.setLivingOrderId(livingOrder.getId());
|
|
|
|
|
+ fee.setHotelId(livingOrder.getHotelId());
|
|
|
|
|
+ fee.setFeeType(FeeType.CONSUME.getKey());
|
|
|
|
|
+ fee.setRoomId(bookingroom.getRoomId());
|
|
|
|
|
+ fee.setRemark("超时房费");
|
|
|
|
|
+ }
|
|
|
|
|
+ return fee;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 完整费用时间
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public Date getFullFeeTime(Date date, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
|
|
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd ");
|
|
|
|
|
+ String endDateStr = dateFormat.format(date);
|
|
|
|
|
+ Date endTime = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(endDateStr + cesAllDayPriceRule.getEndTime());
|
|
|
|
|
+ } catch (ParseException ex) {
|
|
|
|
|
+ throw new JeecgBootException("结束时间格式异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ return endTime;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public BigDecimal getOrderFeeTotal(String livingOrderId, String bookingOrderId) {
|
|
public BigDecimal getOrderFeeTotal(String livingOrderId, String bookingOrderId) {
|
|
|
|
|
|
|
@@ -1484,14 +1778,18 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
s.setRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
s.setRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
|
s.setLastRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
s.setLastRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
|
s.setLivingOrderId("");
|
|
s.setLivingOrderId("");
|
|
|
|
|
+ s.setBookingOrderId("");
|
|
|
});
|
|
});
|
|
|
roomsService.updateBatchById(baseRooms);
|
|
roomsService.updateBatchById(baseRooms);
|
|
|
}
|
|
}
|
|
|
- BusTeam team = teamService.getOne(Wrappers.<BusTeam>query().eq("booking_order_id",bookingOrderId));
|
|
|
|
|
- if(team != null) {
|
|
|
|
|
- team.setIsDelete(1);
|
|
|
|
|
- teamService.updateById(team);
|
|
|
|
|
|
|
+ List<BusTeam> teams = teamService.list(Wrappers.<BusTeam>query().eq("booking_order_id",bookingOrderId));
|
|
|
|
|
+ if(CollUtil.isNotEmpty(teams)) {
|
|
|
|
|
+ teams.get(0).setIsDelete(1);
|
|
|
|
|
+ teamService.updateById(teams.get(0));
|
|
|
}
|
|
}
|
|
|
|
|
+ livingOrders.forEach(e -> {
|
|
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",e.getId());
|
|
|
|
|
+ });
|
|
|
return true;
|
|
return true;
|
|
|
// todo 对账
|
|
// todo 对账
|
|
|
} else throw new JeecgBootException("未找到任何入住订单");
|
|
} else throw new JeecgBootException("未找到任何入住订单");
|
|
@@ -1508,22 +1806,41 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
if(livingOrder == null) throw new JeecgBootException("未找到任何入住订单");
|
|
if(livingOrder == null) throw new JeecgBootException("未找到任何入住订单");
|
|
|
BusBookingRooms mainRoom = bookingRoomsService.getOne(Wrappers.<BusBookingRooms>query()
|
|
BusBookingRooms mainRoom = bookingRoomsService.getOne(Wrappers.<BusBookingRooms>query()
|
|
|
.eq("id",livingOrder.getBookingRoomId()));
|
|
.eq("id",livingOrder.getBookingRoomId()));
|
|
|
|
|
+ if(mainRoom == null) throw new JeecgBootException("没有找到房间");
|
|
|
List<BusRoomsLivingOrder> releLivingingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>lambdaQuery()
|
|
List<BusRoomsLivingOrder> releLivingingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>lambdaQuery()
|
|
|
.eq(BusRoomsLivingOrder::getBookingOrderId, livingOrder.getBookingOrderId()));
|
|
.eq(BusRoomsLivingOrder::getBookingOrderId, livingOrder.getBookingOrderId()));
|
|
|
if (CollUtil.isEmpty(releLivingingOrders)){
|
|
if (CollUtil.isEmpty(releLivingingOrders)){
|
|
|
throw new JeecgBootException("未找到预定订单");
|
|
throw new JeecgBootException("未找到预定订单");
|
|
|
}
|
|
}
|
|
|
|
|
+ releLivingingOrders = releLivingingOrders.stream().filter(e ->
|
|
|
|
|
+ ObjectUtil.equal(SettleTypeEnum.SETTLE_LEAVE.getKey(),e.getSettleType())).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
if(mainRoom.getIsMain().equals(true) && releLivingingOrders.size() > 1) throw new JeecgBootException("查询到其他关联房间,主房不能单独结账退房");
|
|
if(mainRoom.getIsMain().equals(true) && releLivingingOrders.size() > 1) throw new JeecgBootException("查询到其他关联房间,主房不能单独结账退房");
|
|
|
- if(mainRoom == null) throw new JeecgBootException("没有找到主房");
|
|
|
|
|
|
|
|
|
|
BusRoomsLivingOrder mainRoomOrder = livingOrder;
|
|
BusRoomsLivingOrder mainRoomOrder = livingOrder;
|
|
|
// fixbug 当结账后设置离店时间 2023-05-09
|
|
// fixbug 当结账后设置离店时间 2023-05-09
|
|
|
livingOrder.setDueOutTime(new Date());
|
|
livingOrder.setDueOutTime(new Date());
|
|
|
livingOrder.setSettleType(SettleTypeEnum.SETTLE_LEAVE.getKey());
|
|
livingOrder.setSettleType(SettleTypeEnum.SETTLE_LEAVE.getKey());
|
|
|
roomsLivingOrderService.updateById(livingOrder);
|
|
roomsLivingOrderService.updateById(livingOrder);
|
|
|
|
|
+ // 当前居住单中未结算的费用
|
|
|
List<BusOrderFee> feeItems = getLivingOrderFees(livingOrderId).stream().filter(
|
|
List<BusOrderFee> feeItems = getLivingOrderFees(livingOrderId).stream().filter(
|
|
|
s->s.getPreferentialStatus().equals(1)// 找到未结账的
|
|
s->s.getPreferentialStatus().equals(1)// 找到未结账的
|
|
|
).collect(Collectors.toList());
|
|
).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ final BigDecimal[] shoukuan = {new BigDecimal(0)};
|
|
|
|
|
+ final BigDecimal[] xiaofei = {new BigDecimal(0)};
|
|
|
|
|
+ feeItems.forEach(c->{
|
|
|
|
|
+ if(c.getFeeType().equals(1)) { // 收款
|
|
|
|
|
+ shoukuan[0] = shoukuan[0].add(c.getMoney());
|
|
|
|
|
+ } else if(c.getFeeType().equals(2)) { // 消费
|
|
|
|
|
+ xiaofei[0] = xiaofei[0].add(c.getMoney());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ BigDecimal m = shoukuan[0].subtract(xiaofei[0]);
|
|
|
|
|
+ BigDecimal nowMoney = settleFees.stream().map(BusOrderFee::getMoney).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
|
|
+ if (new BigDecimal(0).equals(m.add(nowMoney))){
|
|
|
|
|
+ throw new JeecgBootException("账单未平账");
|
|
|
|
|
+ }
|
|
|
// // 消费账单
|
|
// // 消费账单
|
|
|
// List<BusOrderFee> xiaoFeiFees = feeItems.stream().filter(s->s.getFeeType().equals(1)).collect(Collectors.toList());
|
|
// List<BusOrderFee> xiaoFeiFees = feeItems.stream().filter(s->s.getFeeType().equals(1)).collect(Collectors.toList());
|
|
|
// // 收款
|
|
// // 收款
|
|
@@ -1537,9 +1854,11 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
s.setRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
s.setRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
|
s.setLastRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
s.setLastRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
|
s.setLivingOrderId("");
|
|
s.setLivingOrderId("");
|
|
|
|
|
+ s.setBookingOrderId("");
|
|
|
});
|
|
});
|
|
|
roomsService.updateBatchById(baseRooms);
|
|
roomsService.updateBatchById(baseRooms);
|
|
|
}
|
|
}
|
|
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1585,6 +1904,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
save(newBookingOrder);
|
|
save(newBookingOrder);
|
|
|
livingOrder.setBookingOrderId(newBookingOrder.getId());
|
|
livingOrder.setBookingOrderId(newBookingOrder.getId());
|
|
|
roomsLivingOrderService.updateById(livingOrder);
|
|
roomsLivingOrderService.updateById(livingOrder);
|
|
|
|
|
+ LambdaUpdateWrapper<CesRooms> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.set(CesRooms::getBookingOrderId, "").eq(CesRooms::getId, bookingRoom.getRoomId());
|
|
|
|
|
+ roomsService.update(updateWrapper);
|
|
|
bookingRoom.setBookingOrdersId(newBookingOrder.getId());
|
|
bookingRoom.setBookingOrdersId(newBookingOrder.getId());
|
|
|
bookingRoom.setIsMain(true);
|
|
bookingRoom.setIsMain(true);
|
|
|
bookingRoomsService.updateById(bookingRoom);
|
|
bookingRoomsService.updateById(bookingRoom);
|
|
@@ -1653,13 +1975,32 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<RoomLivingQueryVo> getLivingPageData(Integer status,String keyw, Page<RoomLivingQueryVo> page,String hotelId) {
|
|
public IPage<RoomLivingQueryVo> getLivingPageData(Integer status,String keyw, Page<RoomLivingQueryVo> page,String hotelId) {
|
|
|
- IPage<RoomLivingQueryVo> RoomLivings = baseMapper.getPage(page, status, keyw, hotelId);
|
|
|
|
|
- RoomLivings.getRecords().stream().forEach(e ->{
|
|
|
|
|
|
|
+ IPage<RoomLivingQueryVo> roomLivings = baseMapper.getPage(page, status, keyw, hotelId);
|
|
|
|
|
+
|
|
|
|
|
+ roomLivings.getRecords().stream().forEach(e ->{
|
|
|
if (ObjectUtil.isNotEmpty(e.getRelType())){
|
|
if (ObjectUtil.isNotEmpty(e.getRelType())){
|
|
|
e.setGroupTag(TeamEnum.val(e.getRelType()).getTitle() + e.getSortIndex());
|
|
e.setGroupTag(TeamEnum.val(e.getRelType()).getTitle() + e.getSortIndex());
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- return RoomLivings;
|
|
|
|
|
|
|
+ return roomLivings;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public IPage<RoomLivingQueryVo> getUnionLivingPageData(String keyw, Page<RoomLivingQueryVo> page,String hotelId) {
|
|
|
|
|
+ IPage<RoomLivingQueryVo> roomLivings = baseMapper.getUnionPage(page, keyw, hotelId, true, null);
|
|
|
|
|
+ List<String> bookingIds = roomLivings.getRecords().stream().map(RoomLivingQueryVo::getBookingOrderId).collect(Collectors.toList());
|
|
|
|
|
+ Page<RoomLivingQueryVo> childPage = new Page<>();
|
|
|
|
|
+ childPage.setPages(1);
|
|
|
|
|
+ childPage.setSize(9999);
|
|
|
|
|
+ List<RoomLivingQueryVo> livingQueryVos = baseMapper.getUnionPage(childPage, keyw, hotelId, false, bookingIds).getRecords();
|
|
|
|
|
+ Map<String, List<RoomLivingQueryVo>> map = livingQueryVos.stream().collect(Collectors.groupingBy(RoomLivingQueryVo::getBookingOrderId));
|
|
|
|
|
+ roomLivings.getRecords().forEach(e ->{
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(e.getRelType())){
|
|
|
|
|
+ e.setChildren(map.get(e.getBookingOrderId()));
|
|
|
|
|
+ e.setGroupTag(TeamEnum.val(e.getRelType()).getTitle() + e.getSortIndex());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return roomLivings;
|
|
|
}
|
|
}
|
|
|
@Override
|
|
@Override
|
|
|
public IPage<KeLiItemVo> getLivingOrderKL(Integer status,String keyw,String hotelId,String thirdUserId, Page<KeLiItemVo> page) {
|
|
public IPage<KeLiItemVo> getLivingOrderKL(Integer status,String keyw,String hotelId,String thirdUserId, Page<KeLiItemVo> page) {
|
|
@@ -1759,7 +2100,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
livingOrderId.forEach(s->{
|
|
livingOrderId.forEach(s->{
|
|
|
this.mergeSingle(mainLivingOrder,s);
|
|
this.mergeSingle(mainLivingOrder,s);
|
|
|
});
|
|
});
|
|
|
- addBusTeams(hotelId, mainLivingOrder.getBookingOrderId());
|
|
|
|
|
|
|
+ List<BusTeam> teams = teamService.list(Wrappers.<BusTeam>lambdaQuery().eq(BusTeam::getBookingOrderId, mainLivingOrder.getBookingOrderId()).eq(BusTeam::getIsDelete, "0"));
|
|
|
|
|
+ if (teams.isEmpty()){
|
|
|
|
|
+ addBusTeams(hotelId, mainLivingOrder.getBookingOrderId());
|
|
|
|
|
+ }
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2285,12 +2629,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
//将修改后关联标识后的房间存好
|
|
//将修改后关联标识后的房间存好
|
|
|
bookingRoomsService.updateBatchById(bookingRoomsList);
|
|
bookingRoomsService.updateBatchById(bookingRoomsList);
|
|
|
needMergeLivingOrders.addAll(relationOtherLivingOrders);
|
|
needMergeLivingOrders.addAll(relationOtherLivingOrders);
|
|
|
-
|
|
|
|
|
-// BusBookingRooms mainBkRoom = bookingRoomsService.getOne(Wrappers.<BusBookingRooms>query().eq("booking_orders_id",bookingRooms.getBookingOrdersId()));
|
|
|
|
|
-// if(mainBkRoom != null) {
|
|
|
|
|
-// mainBkRoom.setIsMain(true);
|
|
|
|
|
-// bookingRoomsService.updateById(mainBkRoom); // 设置预约的主房
|
|
|
|
|
-// }
|
|
|
|
|
} else {
|
|
} else {
|
|
|
needMergeLivingOrders.add(mergeLivingOrder);
|
|
needMergeLivingOrders.add(mergeLivingOrder);
|
|
|
}
|
|
}
|
|
@@ -2540,7 +2878,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
BookingLayoutRoomsDto bkRoomItem = livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).findFirst().get();
|
|
BookingLayoutRoomsDto bkRoomItem = livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).findFirst().get();
|
|
|
List<BusLivingCustomer> customers = bkRoomItem.getLivingCustomers();
|
|
List<BusLivingCustomer> customers = bkRoomItem.getLivingCustomers();
|
|
|
if(customers == null || customers.size() == 0) throw new JeecgBootException("请添加客户信息");
|
|
if(customers == null || customers.size() == 0) throw new JeecgBootException("请添加客户信息");
|
|
|
- // 保存入住单
|
|
|
|
|
|
|
+ // 保存入住单,修改房间状态
|
|
|
String livingOrderId = bookingToLive(bkRoom.getId(), customers,hotelId,null, bkRoomItem.getRoomOrderInfo());
|
|
String livingOrderId = bookingToLive(bkRoom.getId(), customers,hotelId,null, bkRoomItem.getRoomOrderInfo());
|
|
|
// 费用关联到主房
|
|
// 费用关联到主房
|
|
|
if(livingData.getOrderFees()!=null && livingData.getOrderFees().size() > 0 ) {
|
|
if(livingData.getOrderFees()!=null && livingData.getOrderFees().size() > 0 ) {
|
|
@@ -2609,7 +2947,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
roomFee.setRoomId(bkRoom.getRoomId());
|
|
roomFee.setRoomId(bkRoom.getRoomId());
|
|
|
roomFee.setLivingOrderId(livingOrderId);
|
|
roomFee.setLivingOrderId(livingOrderId);
|
|
|
roomFee.setFeeType(1); // 消费
|
|
roomFee.setFeeType(1); // 消费
|
|
|
- List<BusLivingLayoutDayPrice> roomDayPrice = livingData.getLivingRoomDayPrices().stream().filter(i->i.getRoomId().equals(bkRoom.getRoomId())).collect(Collectors.toList());
|
|
|
|
|
|
|
+ List<BusLivingLayoutDayPrice> roomDayPrice = livingData.getLivingRoomDayPrices().stream()
|
|
|
|
|
+ .filter(i->i.getRoomId().equals(bkRoom.getRoomId())).collect(Collectors.toList());
|
|
|
BigDecimal dayRoomFee = currentDayFee(roomDayPrice,null);
|
|
BigDecimal dayRoomFee = currentDayFee(roomDayPrice,null);
|
|
|
if(dayRoomFee == null) throw new JeecgBootException("未找到当日房价");
|
|
if(dayRoomFee == null) throw new JeecgBootException("未找到当日房价");
|
|
|
roomFee.setMoney(dayRoomFee); // 取当日房费的优惠价 其他时间要查询房价方案、每日房价,房型门市价按照规则去取
|
|
roomFee.setMoney(dayRoomFee); // 取当日房费的优惠价 其他时间要查询房价方案、每日房价,房型门市价按照规则去取
|
|
@@ -2901,6 +3240,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
s.setRoomId(changeRoom.getId());
|
|
s.setRoomId(changeRoom.getId());
|
|
|
s.setLivingType(1);
|
|
s.setLivingType(1);
|
|
|
s.setLivingOrderId(livingOrderId);
|
|
s.setLivingOrderId(livingOrderId);
|
|
|
|
|
+ if(DateUtils.formatDate(new Date()).equals(DateUtils.formatDate(s.getDayTime()))){
|
|
|
|
|
+ // 修改当日房价 产生的当日房费账单也要改
|
|
|
|
|
+ BusOrderFee fee = feeService.getOne(Wrappers.<BusOrderFee>query()
|
|
|
|
|
+ .eq("DATE_FORMAT(day_time,'%Y-%m-%d')",DateUtils.formatDate(new Date())).eq("living_order_id",s.getLivingOrderId()));
|
|
|
|
|
+ if(fee != null) {
|
|
|
|
|
+ fee.setMoney(s.getPrice());
|
|
|
|
|
+ feeService.updateById(fee);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
livingLayoutDayPriceService.saveBatch(prices);
|
|
livingLayoutDayPriceService.saveBatch(prices);
|
|
|
return true;
|
|
return true;
|