|
|
@@ -40,6 +40,7 @@ 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.FloorBuildingRoomVo;
|
|
|
+import org.jeecg.modules.rooms.Vo.LivingContinueVo;
|
|
|
import org.jeecg.modules.rooms.Vo.LivingRealtimeVo;
|
|
|
import org.jeecg.modules.rooms.entity.*;
|
|
|
import org.jeecg.modules.rooms.service.*;
|
|
|
@@ -76,9 +77,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
private BusBookingBatchServiceImpl bookingBatchService;
|
|
|
|
|
|
@Resource
|
|
|
- private IBusBookingLayoutDayPriceService dayPriceService;
|
|
|
-
|
|
|
- @Resource
|
|
|
private IBusCustomerService customerService;
|
|
|
|
|
|
@Resource
|
|
|
@@ -88,6 +86,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
private IBusLivingCustomerService livingCustomerService;
|
|
|
|
|
|
@Resource
|
|
|
+ private IBusBookingLayoutDayPriceService dayPriceService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
private IBusLivingLayoutDayPriceService livingLayoutDayPriceService;
|
|
|
|
|
|
@Resource
|
|
|
@@ -1069,33 +1070,36 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
//<editor-fold desc="同住人相关">
|
|
|
|
|
|
- BusRoomsLivingOrder finalLivingOrder = livingOrder;
|
|
|
- customers.forEach(s->{
|
|
|
- // 【添加客人信息 Start】
|
|
|
- if(s.getCustomerName() != null && !s.getCustomerName().isEmpty() && s.getPhone() != null && !s.getPhone().isEmpty()){
|
|
|
- BusCustomer customer = customerService.getOne(Wrappers.<BusCustomer>query().eq("name",s.getCustomerName())
|
|
|
- .eq("phone",s.getPhone()));
|
|
|
- if(customer == null) {
|
|
|
- // save customer
|
|
|
- BusCustomer newCustomer = new BusCustomer();
|
|
|
- newCustomer.setCreateTime(new Date());
|
|
|
- newCustomer.setCreateUser("");
|
|
|
- newCustomer.setTenantId(user.getRelTenantIds());
|
|
|
- newCustomer.setName(s.getCustomerName());
|
|
|
- newCustomer.setGender(s.getGender());
|
|
|
- newCustomer.setPhone(s.getPhone());
|
|
|
- newCustomer.setCertType(1); // 身份证
|
|
|
- newCustomer.setCertNo(s.getCertNo()); // 身份证
|
|
|
- customerService.save(newCustomer);
|
|
|
- s.setCustomerId(newCustomer.getId());
|
|
|
- } else {
|
|
|
- s.setCustomerId(customer.getId());
|
|
|
- }
|
|
|
- } else throw new JeecgBootException("客人信息不能为空");
|
|
|
- s.setLivingOrderId(finalLivingOrder.getId());
|
|
|
- livingCustomerService.save(s);
|
|
|
- // 【添加客人信息 end】
|
|
|
- });
|
|
|
+ BusRoomsLivingOrder finalLivingOrder = livingOrder;
|
|
|
+ customers.forEach(s->{
|
|
|
+ // 【添加客人信息 Start】
|
|
|
+ if(s.getCustomerName() != null && !s.getCustomerName().isEmpty() && s.getPhone() != null && !s.getPhone().isEmpty()){
|
|
|
+ BusCustomer customer = customerService.getOne(Wrappers.<BusCustomer>query().eq("name",s.getCustomerName())
|
|
|
+ .eq("phone",s.getPhone()));
|
|
|
+ if(customer == null) {
|
|
|
+ // save customer
|
|
|
+ BusCustomer newCustomer = new BusCustomer();
|
|
|
+ // 新顾客第一个会先自定义一个id,因为上面livingOrder要关联顾客id
|
|
|
+ newCustomer.setId(s.getCustomerId());
|
|
|
+ newCustomer.setCreateTime(new Date());
|
|
|
+ newCustomer.setCreateUser("");
|
|
|
+ newCustomer.setTenantId(user.getRelTenantIds());
|
|
|
+ newCustomer.setName(s.getCustomerName());
|
|
|
+ newCustomer.setGender(s.getGender());
|
|
|
+ newCustomer.setAddress(s.getAddress());
|
|
|
+ newCustomer.setPhone(s.getPhone());
|
|
|
+ newCustomer.setCertType(1); // 身份证
|
|
|
+ newCustomer.setCertNo(s.getCertNo()); // 身份证
|
|
|
+ customerService.save(newCustomer);
|
|
|
+ s.setCustomerId(newCustomer.getId());
|
|
|
+ } else {
|
|
|
+ s.setCustomerId(customer.getId());
|
|
|
+ }
|
|
|
+ } else throw new JeecgBootException("客人信息不能为空");
|
|
|
+ s.setLivingOrderId(finalLivingOrder.getId());
|
|
|
+ livingCustomerService.save(s);
|
|
|
+ // 【添加客人信息 end】
|
|
|
+ });
|
|
|
|
|
|
//</editor-fold>
|
|
|
|
|
|
@@ -1147,12 +1151,18 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String customerLiving(BookingOrderSaveDto livingData, Boolean isTeam, String hotelId) {
|
|
|
+ // 查看房间入住情况
|
|
|
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("房间已被入住");
|
|
|
}
|
|
|
+ // 查看房间预约情况
|
|
|
+ List<BusRoomBookingOrders> clashOrder = baseMapper.findBookingOrder(roomIds, livingData.getOrderInfo().getArrivalTime(), livingData.getOrderInfo().getDueOutTime());
|
|
|
+ if (!clashOrder.isEmpty()){
|
|
|
+ throw new JeecgBootException("房间已被预约");
|
|
|
+ }
|
|
|
// 是预约单先将预约单与房间关联删掉。因为原来这个接口是自己入住的接口,后来预定也要调这个接口,只能先将预定时添加的BusRoomBookingOrders关联表删掉,重新进行关联
|
|
|
if(StrUtil.isNotEmpty(livingData.getOrderInfo().getId())){
|
|
|
BusRoomBookingOrders bookingOrders = getById(livingData.getOrderInfo().getId());
|
|
|
@@ -1359,6 +1369,92 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
+ public Boolean syncDayRoomFee(String hotelId){
|
|
|
+ List<CesRooms> hotelRooms = roomsService.list(Wrappers.<CesRooms>query().eq("hotel_id",hotelId).eq("invalid",false));
|
|
|
+ List<CesRooms> inLiveRooms = hotelRooms.stream().filter(s->s.getLivingOrderId() != null && !s.getLivingOrderId().isEmpty()
|
|
|
+ && (s.getRoomStatus().equals(RoomStatusEnum.LIVE_DIRTY.getKey()) || s.getRoomStatus().equals(RoomStatusEnum.LIVE_CLEAR.getKey()))).collect(Collectors.toList());
|
|
|
+ List<String> livingOrderIds = inLiveRooms.stream().map(CesRooms::getLivingOrderId).collect(Collectors.toList());
|
|
|
+ List<BusRoomsLivingOrder> livingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
|
|
|
+ .in("id",livingOrderIds));
|
|
|
+ List<CesAllDayPriceRule> allDayPriceRules = allDayPriceRuleService.list();
|
|
|
+ Optional<CesAllDayPriceRule> opAllPrice = allDayPriceRules.stream().filter(a->a.getHotelId().equals(hotelId)).findFirst();
|
|
|
+// CesAllDayPriceRule allPrice;
|
|
|
+// if(!opAllPrice.isPresent()) {
|
|
|
+// allPrice = new CesAllDayPriceRule();
|
|
|
+// allPrice.setEndTime("16:00");
|
|
|
+// } else {
|
|
|
+// allPrice = opAllPrice.get();
|
|
|
+// }
|
|
|
+ livingOrders.forEach(s->{
|
|
|
+ try {
|
|
|
+ Date dueDate = DateUtils.parseDate(DateUtils.formatDate(s.getDueOutTime()),"yyyy-MM-dd");
|
|
|
+ Date currDate = DateUtils.parseDate(DateUtils.formatDate(new Date()),"yyyy-MM-dd");
|
|
|
+ List<BusOrderFee> hasFeeList = feeService.list(Wrappers.<BusOrderFee>lambdaQuery().eq(BusOrderFee::getFeeType, 1)
|
|
|
+ .eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()).ge(BusOrderFee::getCreateTime, currDate));
|
|
|
+ if (!hasFeeList.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<BusLivingLayoutDayPrice> dayPrices = livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
|
|
|
+ .eq("living_order_id",s.getId()));
|
|
|
+ Optional<BusLivingLayoutDayPrice> opPrice = dayPrices.stream().filter(a-> a.getDayTime().compareTo(currDate) == 0).findFirst();
|
|
|
+ BigDecimal money = new BigDecimal(0);
|
|
|
+ if(!opPrice.isPresent()){
|
|
|
+ BusBookingRooms br = bookingRoomsService.getOne(Wrappers.<BusBookingRooms>query()
|
|
|
+ .eq("id",s.getBookingRoomId()));
|
|
|
+ if(br == null) return;
|
|
|
+ CesRooms room = roomsService.getById(br.getRoomId());
|
|
|
+ if(room == null) return;
|
|
|
+ CesRoomLayout layout = layoutService.getById(room.getLayoutId());
|
|
|
+ if(layout == null) return;
|
|
|
+ BusLivingLayoutDayPrice nPrice = new BusLivingLayoutDayPrice();
|
|
|
+ nPrice.setBookingRoomId(s.getBookingRoomId());
|
|
|
+ try {
|
|
|
+ nPrice.setDayTime(DateUtils.parseDate(DateUtils.formatDate(new Date()),"yyyy-MM-dd"));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ nPrice.setRoomId(br.getRoomId());
|
|
|
+ nPrice.setRoomLayoutId(room.getLayoutId());
|
|
|
+ nPrice.setPrice(layout.getMarketPrice());
|
|
|
+ nPrice.setLivingOrderId(s.getId());
|
|
|
+ nPrice.setLivingType(s.getLivingType());
|
|
|
+ livingLayoutDayPriceService.save(nPrice);
|
|
|
+ // 更新订单日期
|
|
|
+ if(dueDate.getTime() < currDate.getTime()){
|
|
|
+ Date date = s.getDueOutTime();
|
|
|
+ Calendar calendar = new GregorianCalendar();
|
|
|
+ calendar.setTime(date);
|
|
|
+ calendar.add(Calendar.DATE,1);
|
|
|
+ s.setDueOutTime(calendar.getTime());
|
|
|
+ roomsLivingOrderService.updateById(s);
|
|
|
+ }
|
|
|
+ money = layout.getMarketPrice();
|
|
|
+ } else {
|
|
|
+ money = opPrice.get().getPrice();
|
|
|
+ }
|
|
|
+
|
|
|
+ BusOrderFee dayOrderFee = new BusOrderFee();
|
|
|
+ dayOrderFee.setDayTime(new Date());
|
|
|
+ dayOrderFee.setCreateTime(new Date());
|
|
|
+
|
|
|
+ dayOrderFee.setFeeType(1);
|
|
|
+ dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
|
|
|
+
|
|
|
+ CesRooms orderRoom = inLiveRooms.stream().filter(a->a.getLivingOrderId().equals(s.getId())).findFirst().get();
|
|
|
+ dayOrderFee.setMoney(money);
|
|
|
+ dayOrderFee.setRoomId(orderRoom.getId());
|
|
|
+ String roomName = orderRoom.getPrefix() != null?orderRoom.getPrefix():"";
|
|
|
+ roomName += roomName + orderRoom.getName();
|
|
|
+ dayOrderFee.setRemark("【"+roomName + "】 "+ DateUtils.formatDate(new Date()) + " 当日房费");
|
|
|
+ dayOrderFee.setLivingOrderId(s.getId());
|
|
|
+ dayOrderFee.setHotelId(hotelId);
|
|
|
+ feeService.save(dayOrderFee);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -1449,7 +1545,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Boolean syncRoomOrder(String hotelId) {
|
|
|
+ public Boolean syncRoomOverTimeOrder(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));
|
|
|
@@ -1502,6 +1598,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// 如果满足全天收费要求,预离时间增加1天
|
|
|
CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
fee.setMoney(layout.getMarketPrice());
|
|
|
+ fee.setDayTime(date);
|
|
|
nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
@@ -1509,19 +1606,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// 下一次收费时间戳
|
|
|
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);
|
|
|
+ addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
}
|
|
|
// 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
@@ -1559,19 +1644,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// 下一次收费时间戳
|
|
|
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);
|
|
|
+ addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
}
|
|
|
// 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
@@ -1605,19 +1678,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// 下一次收费时间戳
|
|
|
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);
|
|
|
+ addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
}
|
|
|
// 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
@@ -1627,21 +1688,43 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ public void addDayPrice(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom, BigDecimal money){
|
|
|
+ List<BusLivingLayoutDayPrice> dayPrices = livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
|
|
|
+ .eq("living_order_id",livingOrder.getId()));
|
|
|
+ Optional<BusLivingLayoutDayPrice> opPrice = dayPrices.stream().filter(a-> DateUtils.formatDate(a.getDayTime()).equals(DateUtils.formatDate(livingOrder.getDueOutTime()))).findFirst();
|
|
|
+ if(!opPrice.isPresent()){
|
|
|
+ BusLivingLayoutDayPrice nPrice = new BusLivingLayoutDayPrice();
|
|
|
+ nPrice.setBookingRoomId(livingOrder.getBookingRoomId());
|
|
|
+ try {
|
|
|
+ nPrice.setDayTime(DateUtils.parseDate(DateUtils.formatDate(new Date()),"yyyy-MM-dd"));
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ nPrice.setRoomId(bookingroom.getRoomId());
|
|
|
+ nPrice.setRoomLayoutId(bookingroom.getRoomLayoutId());
|
|
|
+ nPrice.setPrice(money);
|
|
|
+ nPrice.setLivingOrderId(livingOrder.getId());
|
|
|
+ nPrice.setLivingType(livingOrder.getLivingType());
|
|
|
+ livingLayoutDayPriceService.save(nPrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public BusOrderFee getOverTimeFee(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom){
|
|
|
- BusOrderFee fee = feeService.getOne(Wrappers.<BusOrderFee>lambdaQuery()
|
|
|
- .eq(BusOrderFee::getLivingOrderId, livingOrder.getId()).eq(BusOrderFee::getPreferentialStatus, "1")
|
|
|
+ List<BusOrderFee> feeList = feeService.list(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("超时房费");
|
|
|
+ if (CollUtil.isNotEmpty(feeList)) {
|
|
|
+ return feeList.get(0);
|
|
|
}
|
|
|
+ BusOrderFee 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;
|
|
|
}
|
|
|
|
|
|
@@ -1670,6 +1753,59 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean continueLiving2(List<LivingContinueVo> continueLiving, String hotelId) {
|
|
|
+ List<String> livingIds = continueLiving.stream().map(LivingContinueVo::getId).collect(Collectors.toList());
|
|
|
+ if (CollUtil.isEmpty(livingIds)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<BusRoomsLivingOrder> livingOrderList = roomsLivingOrderService.listByIds(livingIds);
|
|
|
+ if (livingIds.size() != livingOrderList.size()){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<BusOrderFee> orderFeeList = new ArrayList<>();
|
|
|
+ List<BusLivingLayoutDayPrice> dayPrices = new ArrayList<>();
|
|
|
+ continueLiving.forEach(living ->{
|
|
|
+ Optional<BusRoomsLivingOrder> orderOptional = livingOrderList.stream().filter(order -> order.getId().equals(living.getId())).findFirst();
|
|
|
+ orderOptional.ifPresent(e -> {
|
|
|
+ // 修改订单预离时间
|
|
|
+ e.setDueOutTime(living.getDueOutTime());
|
|
|
+ e.setBreakfastNum(living.getBreakfastNum());
|
|
|
+ // 添加收款单
|
|
|
+ if (ObjectUtil.isNotEmpty(living.getDayNum()) && living.getDayNum() > 0
|
|
|
+ && ObjectUtil.isNotEmpty(living.getPayMoney()) && living.getPayMoney().compareTo(new BigDecimal(0)) > 0){
|
|
|
+ if (StrUtil.isEmpty(living.getPayType())){
|
|
|
+ throw new JeecgBootException("未找到付款方式");
|
|
|
+ }
|
|
|
+ BusOrderFee orderFee = new BusOrderFee();
|
|
|
+ orderFee.setMoney(living.getPayMoney());
|
|
|
+ orderFee.setPayType(living.getPayType());
|
|
|
+ orderFee.setFeeType(2);
|
|
|
+ orderFee.setSubjectType(2);
|
|
|
+ orderFee.setRemark("预收房费");
|
|
|
+ orderFee.setLivingOrderId(e.getId());
|
|
|
+ orderFee.setPreferentialStatus(1);
|
|
|
+ orderFee.setRoomId(living.getRoomId());
|
|
|
+ orderFee.setHotelId(hotelId);
|
|
|
+ orderFeeList.add(orderFee);
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if (living.getDayNum() < 0){
|
|
|
+ // TODO: 2023/10/19 删除预约每日房价,还不确定要不要删
|
|
|
+ } else {
|
|
|
+ dayPrices.addAll(living.getLayoutDayPriceList());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ });
|
|
|
+ feeService.collectionBatch(orderFeeList, hotelId);
|
|
|
+ roomsLivingOrderService.updateBatchById(livingOrderList);
|
|
|
+ livingLayoutDayPriceService.saveBatch(dayPrices);
|
|
|
+ return true;
|
|
|
+// throw new JeecgBootException("设置失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean continueLiving(BusOrderFee settleFee, Date dueOutTime,String livingOrderId,String hotelId) {
|
|
|
BusRoomsLivingOrder order = roomsLivingOrderService.getById(livingOrderId);
|
|
|
if (order == null) throw new JeecgBootException("订单错误");
|
|
|
@@ -1704,26 +1840,28 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// throw new JeecgBootException("设置失败");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 判断续租是否跟预约订单冲突
|
|
|
*/
|
|
|
@Override
|
|
|
- public BookingOrderEditVo roomIdBooked(String livingOrderId, Date newDueOutTime) {
|
|
|
- BusRoomsLivingOrder order = roomsLivingOrderService.getById(livingOrderId);
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- String arrivalTimeStr = sdf.format(order.getArrivalTime());
|
|
|
- List<BusRoomBookingOrders> bookingOrdersByRooms = baseMapper.findBookingOrderByRoom(order.getBookingRoomId(), arrivalTimeStr);
|
|
|
- for (BusRoomBookingOrders bookingOrder: bookingOrdersByRooms) {
|
|
|
- if (bookingOrder.getArrivalTime().getTime() <= newDueOutTime.getTime()){
|
|
|
- BusCustomer busCustomer = customerService.getById(bookingOrder.getContactId());
|
|
|
- BookingOrderEditVo bookingOrderVo = new BookingOrderEditVo();
|
|
|
- bookingOrderVo.setOrderInfo(bookingOrder);
|
|
|
- bookingOrderVo.setContactName(busCustomer.getName());
|
|
|
- bookingOrderVo.setPhone(busCustomer.getPhone());
|
|
|
- return bookingOrderVo;
|
|
|
- };
|
|
|
+ public List<LivingContinueVo> roomIdBooked(List<LivingContinueVo> livingContinueList) {
|
|
|
+ List<String> livingIds = livingContinueList.stream().map(LivingContinueVo::getId).collect(Collectors.toList());
|
|
|
+ if (CollUtil.isEmpty(livingIds)) {
|
|
|
+ return null;
|
|
|
}
|
|
|
- return null;
|
|
|
+ List<BusRoomsLivingOrder> orders = roomsLivingOrderService.listByIds(livingIds);
|
|
|
+ if (livingIds.size() != orders.size()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<LivingContinueVo> returnLivingContinueVos = new ArrayList<>();
|
|
|
+ orders.forEach(e ->{
|
|
|
+ Optional<LivingContinueVo> continueOptional = livingContinueList.stream().filter(ele -> e.getId().equals(ele.getId())).findFirst();
|
|
|
+ List<LivingContinueVo> livingContinueVos =
|
|
|
+ baseMapper.findBookingOrderByRoom(e.getBookingRoomId(), new Date(), continueOptional.get().getDueOutTime());
|
|
|
+ returnLivingContinueVos.addAll(livingContinueVos);
|
|
|
+ });
|
|
|
+ return returnLivingContinueVos;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1888,7 +2026,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(livingOrderId);
|
|
|
if(livingOrder == null) throw new JeecgBootException("订单不存在");
|
|
|
BusBookingRooms bookingRoom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
- if(bookingRoom == null) throw new JeecgBootException("订单房间不存在");
|
|
|
+ if (bookingRoom == null){
|
|
|
+ throw new JeecgBootException("房间订单不存在");
|
|
|
+ }
|
|
|
+ if (SettleTypeEnum.UN_SETTLE_LEAVE.getKey().equals(livingOrder.getSettleType())){
|
|
|
+ throw new JeecgBootException("未结退房的房间不能拆房");
|
|
|
+ }
|
|
|
long count = roomsLivingOrderService.count(Wrappers.<BusRoomsLivingOrder>query().eq("booking_order_id", livingOrder.getBookingOrderId()));
|
|
|
if (count == 2){
|
|
|
UpdateWrapper<BusTeam> uw = new UpdateWrapper<>();
|
|
|
@@ -2450,9 +2593,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
order.setVipCustomerId(vipCustomerId);
|
|
|
order.setContractTeamId(contractTeamId);
|
|
|
order.setContractTeamProtocolId(marketAgreementCustomerId);
|
|
|
- // 找出房费订单和每日价格,按会员价算
|
|
|
+ // 找出未结算的房费订单,且不是冲账单 和每日价格,按会员价算
|
|
|
List<BusOrderFee> orderFeeList = feeService.list(Wrappers.<BusOrderFee>lambdaQuery()
|
|
|
- .eq(BusOrderFee::getLivingOrderId, order.getId()).eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()));
|
|
|
+ .eq(BusOrderFee::getLivingOrderId, order.getId()).eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey())
|
|
|
+ .eq(BusOrderFee::getPreferentialStatus, 1).gt(BusOrderFee::getMoney,0));
|
|
|
// 原始则扣和改变后的折扣
|
|
|
BigDecimal finalOriginalDiscount = originalDiscount;
|
|
|
BigDecimal finalChangeDiscount = changeDiscount;
|
|
|
@@ -2789,6 +2933,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// if(user == null) throw new JeecgBootException("请登录");
|
|
|
if(hotelId == null) throw new JeecgBootException("未找到酒店");
|
|
|
List<BusRoomPayType> payTypes = payTypeService.list();
|
|
|
+ // 如果未结算的只有一条,且是消费单(部分结账的时候)。收款单中关联这条消费单
|
|
|
+ String consumeFeeId;
|
|
|
+ if (feeItems != null && feeItems.size() == 1 && feeItems.get(0).getFeeType().equals(1)){
|
|
|
+ consumeFeeId = feeItems.get(0).getId();
|
|
|
+ } else {
|
|
|
+ consumeFeeId = null;
|
|
|
+ }
|
|
|
settleFees.forEach(s->{
|
|
|
if(BooleanUtil.isTrue(s.getIsPreferential())) {
|
|
|
if(s.getCouponscashId() != null && !s.getCouponscashId().isEmpty()) {
|
|
|
@@ -2848,17 +2999,19 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
s.setFeeType(2);
|
|
|
s.setSubjectType(FeeSubjectType.JIE_ZHANG.getKey());
|
|
|
s.setContactId(mainRoomOrder.getContactId());
|
|
|
+ s.setConsumeFeeId(consumeFeeId);
|
|
|
}
|
|
|
s.setPreferentialStatus(2);
|
|
|
s.setCreateTime(new Date());
|
|
|
s.setRoomId(mainRoom.getRoomId());
|
|
|
s.setLivingOrderId(mainRoomOrder.getId());
|
|
|
s.setHotelId(hotelId);
|
|
|
-
|
|
|
});
|
|
|
if(settleFees.size() > 0) {
|
|
|
+ // 保存收款单
|
|
|
feeService.saveBatch(settleFees);
|
|
|
} else throw new JeecgBootException("参数没有结账收费项目");
|
|
|
+ // 全部结账时是所有未结算的账单 ,部分结账时是勾选的消费账单
|
|
|
feeItems.forEach(s->{
|
|
|
s.setPreferentialStatus(2);
|
|
|
});
|
|
|
@@ -2877,14 +3030,23 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
throw new JeecgBootException("房间信息未找到");
|
|
|
BookingLayoutRoomsDto bkRoomItem = livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).findFirst().get();
|
|
|
List<BusLivingCustomer> customers = bkRoomItem.getLivingCustomers();
|
|
|
- if(customers == null || customers.size() == 0) throw new JeecgBootException("请添加客户信息");
|
|
|
+ if(customers == null || customers.isEmpty()) throw new JeecgBootException("请添加客户信息");
|
|
|
// 保存入住单,修改房间状态
|
|
|
String livingOrderId = bookingToLive(bkRoom.getId(), customers,hotelId,null, bkRoomItem.getRoomOrderInfo());
|
|
|
+ // 将预约时交的押金,放到主房
|
|
|
+ if (bkRoom.getIsMain()){
|
|
|
+ LambdaUpdateWrapper<BusOrderFee> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(BusOrderFee::getLivingOrderId, livingOrderId);
|
|
|
+ updateWrapper.set(BusOrderFee::getRoomId, bkRoom.getRoomId());
|
|
|
+ updateWrapper.eq(BusOrderFee::getBookingOrderId, bkRoom.getBookingOrdersId());
|
|
|
+ updateWrapper.eq(BusOrderFee::getBookingYj, true);
|
|
|
+ updateWrapper.isNull(BusOrderFee::getLivingOrderId);
|
|
|
+ feeService.update(updateWrapper);
|
|
|
+ }
|
|
|
// 费用关联到主房
|
|
|
- if(livingData.getOrderFees()!=null && livingData.getOrderFees().size() > 0 ) {
|
|
|
+ if(livingData.getOrderFees()!=null && !livingData.getOrderFees().isEmpty()) {
|
|
|
List<BusOrderFee> findRoomFees = livingData.getOrderFees().stream().filter(t->t.getRoomId().equals(bkRoom.getRoomId())).collect(Collectors.toList());
|
|
|
findRoomFees.forEach(s->{
|
|
|
-
|
|
|
s.setRoomId(bkRoom.getRoomId());
|
|
|
s.setLivingOrderId(livingOrderId);
|
|
|
s.setCreateTime(new Date());
|
|
|
@@ -2899,7 +3061,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
if("会员卡".equals(payType.getName())){
|
|
|
BusMemberBalanceLog memberBalanceLog = new BusMemberBalanceLog();
|
|
|
- if (user.getRelTenantIds() != null && !user.getRelTenantIds().equals("")) {
|
|
|
+ if (user.getRelTenantIds() != null && !user.getRelTenantIds().isEmpty()) {
|
|
|
memberBalanceLog.setTenantId(user.getRelTenantIds());
|
|
|
} else {
|
|
|
throw new JeecgBootException("当前登录人租户信息错误");
|
|
|
@@ -2913,7 +3075,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
memberBalanceLogService.saveBalance(memberBalanceLog);
|
|
|
}
|
|
|
});
|
|
|
- if(findRoomFees.size() > 0) feeService.saveBatch(findRoomFees);
|
|
|
+ if(!findRoomFees.isEmpty()) feeService.saveBatch(findRoomFees);
|
|
|
// 处理协议单位记账
|
|
|
findRoomFees.forEach(s->{
|
|
|
if(payTypes.stream().anyMatch(k->k.getId().equals(s.getPayType()) && k.getName().equals("单位记账")) ) {
|
|
|
@@ -3213,15 +3375,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// 换房
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Boolean changeLivingRoom(List<BusLivingLayoutDayPrice> prices,String livingOrderId, String roomId) {
|
|
|
- if(prices == null || prices.size() == 0) throw new JeecgBootException("请传入房价");
|
|
|
- BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(livingOrderId);
|
|
|
+ public Boolean changeLivingRoom(LivingContinueVo param) {
|
|
|
+ if(CollUtil.isEmpty(param.getLayoutDayPriceList())) throw new JeecgBootException("请传入房价");
|
|
|
+ BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(param.getId());
|
|
|
if(livingOrder == null) throw new JeecgBootException("入住记录不存在");
|
|
|
BusBookingRooms bkRoom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
if(bkRoom == null) throw new JeecgBootException("入住房间记录不存在");
|
|
|
CesRooms origLivingRoom = roomsService.getById(bkRoom.getRoomId());
|
|
|
if(origLivingRoom == null) throw new JeecgBootException("原房间不存在");
|
|
|
- CesRooms changeRoom = roomsService.getById(roomId);
|
|
|
+ CesRooms changeRoom = roomsService.getById(param.getRoomId());
|
|
|
if(changeRoom == null) throw new JeecgBootException("更换房间不存在");
|
|
|
bkRoom.setRoomId(changeRoom.getId());
|
|
|
bkRoom.setLayoutId(changeRoom.getLayoutId());
|
|
|
@@ -3230,27 +3392,28 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
origLivingRoom.setRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
|
roomsService.updateById(origLivingRoom);
|
|
|
changeRoom.setRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
|
|
|
- changeRoom.setLivingOrderId(livingOrderId);
|
|
|
+ changeRoom.setLivingOrderId(param.getId());
|
|
|
roomsService.updateById(changeRoom);
|
|
|
feeService.update(Wrappers.<BusOrderFee>lambdaUpdate().set(BusOrderFee::getRoomId, changeRoom.getId())
|
|
|
- .eq(BusOrderFee::getLivingOrderId, livingOrderId));
|
|
|
- livingLayoutDayPriceService.remove(Wrappers.<BusLivingLayoutDayPrice>query().eq("living_order_id",livingOrderId));
|
|
|
- prices.forEach(s->{
|
|
|
+ .eq(BusOrderFee::getLivingOrderId, param.getId()));
|
|
|
+ livingLayoutDayPriceService.remove(Wrappers.<BusLivingLayoutDayPrice>query().eq("living_order_id",param.getId()));
|
|
|
+ param.getLayoutDayPriceList().forEach(s->{
|
|
|
s.setRoomLayoutId(changeRoom.getLayoutId());
|
|
|
s.setRoomId(changeRoom.getId());
|
|
|
s.setLivingType(1);
|
|
|
- s.setLivingOrderId(livingOrderId);
|
|
|
+ s.setLivingOrderId(param.getId());
|
|
|
if(DateUtils.formatDate(new Date()).equals(DateUtils.formatDate(s.getDayTime()))){
|
|
|
// 修改当日房价 产生的当日房费账单也要改
|
|
|
- BusOrderFee fee = feeService.getOne(Wrappers.<BusOrderFee>query()
|
|
|
+ List<BusOrderFee> fees = feeService.list(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);
|
|
|
+ if(CollUtil.isNotEmpty(fees)) {
|
|
|
+ fees.get(0).setMoney(s.getPrice());
|
|
|
+ feeService.updateById(fees.get(0));
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- livingLayoutDayPriceService.saveBatch(prices);
|
|
|
+ feeService.collectionBatch(param.getOrderFeeList(),livingOrder.getHotelId());
|
|
|
+ livingLayoutDayPriceService.saveBatch(param.getLayoutDayPriceList());
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -3346,5 +3509,22 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return isUpdate;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<LivingContinueVo> getContinueOrder(String bookingOrderId, String hotelId) {
|
|
|
+ List<LivingContinueVo> livingContinueList = baseMapper.getContinueOrder(bookingOrderId, hotelId);
|
|
|
+ if (CollUtil.isEmpty(livingContinueList)){
|
|
|
+ throw new JeecgBootException("订单未找到");
|
|
|
+ }
|
|
|
+ List<CesRoomLayout> layoutList = layoutService.list();
|
|
|
+ livingContinueList.forEach(e -> {
|
|
|
+ Optional<CesRoomLayout> layoutOptional = layoutList.stream().filter(layout -> layout.getId().equals(e.getLayoutId())).findFirst();
|
|
|
+ layoutOptional.ifPresent(ele -> {
|
|
|
+ e.setRoomLayout(layoutOptional.get());
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return livingContinueList;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|