|
|
@@ -1,6 +1,8 @@
|
|
|
package org.jeecg.modules.business.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Snowflake;
|
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
@@ -16,6 +18,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.checkerframework.checker.units.qual.C;
|
|
|
import org.jeecg.common.api.dto.message.MessageDTO;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
@@ -29,10 +32,7 @@ import org.jeecg.modules.business.mapper.BusRoomBookingOrdersMapper;
|
|
|
import org.jeecg.modules.business.service.*;
|
|
|
import org.jeecg.modules.business.util.MxTools;
|
|
|
import org.jeecg.modules.business.vo.*;
|
|
|
-import org.jeecg.modules.fw.entity.FwRoomClean;
|
|
|
-import org.jeecg.modules.fw.entity.FwRoomExamine;
|
|
|
-import org.jeecg.modules.fw.entity.FwRoomLock;
|
|
|
-import org.jeecg.modules.fw.entity.FwRoomRepair;
|
|
|
+import org.jeecg.modules.fw.entity.*;
|
|
|
import org.jeecg.modules.fw.service.IFwRoomCleanService;
|
|
|
import org.jeecg.modules.fw.service.IFwRoomExamineService;
|
|
|
import org.jeecg.modules.fw.service.IFwRoomLockService;
|
|
|
@@ -58,6 +58,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.Serializable;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.ParseException;
|
|
|
@@ -98,6 +99,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
private IBusLivingLayoutDayPriceService livingLayoutDayPriceService;
|
|
|
|
|
|
@Resource
|
|
|
+ IBusSchemeLayoutDailyPriceService schemeLayoutDailyPriceService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
private IBusTeamService teamService;
|
|
|
|
|
|
@Resource
|
|
|
@@ -639,7 +643,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
if(!item.getOrderInfo().getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
|
|
|
if(item.getOrderInfo().getDayCount() == null || item.getOrderInfo().getDayCount() <= 0)
|
|
|
throw new JeecgBootException("入住天数不能小于0");
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if(item.getRoomIds() == null || item.getRoomIds().size() == 0)
|
|
|
@@ -654,9 +657,11 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// 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<BusRoomBookingOrders> endClashOrder = clashOrder.stream().filter(e -> !StrUtil.equals(e.getId(), order.getId())).collect(Collectors.toList());
|
|
|
+ if (!endClashOrder.isEmpty()){
|
|
|
+ String arrivalTime = DateUtil.format(clashOrder.get(0).getArrivalTime(), "YYYY-MM-dd");
|
|
|
+ String dueOutTime = DateUtil.format(clashOrder.get(0).getDueOutTime(), "YYYY-MM-dd");
|
|
|
+ throw new JeecgBootException( "房间" + arrivalTime + "~" + dueOutTime + "有预约");
|
|
|
}
|
|
|
|
|
|
//这里不能直接删除 先查询预订单有没有入住记录,如果房间有入住,那么入住过的记录则不能删除
|
|
|
@@ -1081,8 +1086,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
CesRooms room = roomsService.getById(bkRoom.getRoomId());
|
|
|
if(room==null) throw new JeecgBootException("房间不存在");
|
|
|
room.setLivingOrderId(livingOrder.getId());
|
|
|
- room.setRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
|
|
|
- room.setLastRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
|
|
|
+ Integer roomStatus = roomsService.changeLivingRoomStatus(room.getRoomStatus(), room.getLastRoomStatus());
|
|
|
+ room.setLastRoomStatus(room.getRoomStatus());
|
|
|
+ room.setRoomStatus(roomStatus);
|
|
|
roomsService.updateById(room);
|
|
|
bkRoom.setRoomStatus(RoomStatusEnum.LIVE_DIRTY.getKey());
|
|
|
bookingRoomsService.updateById(bkRoom);
|
|
|
@@ -1132,38 +1138,26 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
// }
|
|
|
|
|
|
- /*添加消息通知*/
|
|
|
- BusHotel busHotel = busHotelService.getById(room.getHotelId());
|
|
|
- LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(SysUser::getDelFlag, 0);
|
|
|
- lambdaQueryWrapper.eq(SysUser::getRelTenantIds, busHotel.getTenantId());
|
|
|
- List<SysUser> sysUsers = sysUserService.list(lambdaQueryWrapper);
|
|
|
- String userIds = "";
|
|
|
- for (SysUser sysUser : sysUsers) {
|
|
|
- userIds += sysUser.getUsername() + ",";
|
|
|
- }
|
|
|
- if (!userIds.isEmpty()) {
|
|
|
- MessageDTO messageDTO = new MessageDTO();
|
|
|
- messageDTO.setFromUser("");
|
|
|
- messageDTO.setToUser(userIds);
|
|
|
- messageDTO.setTenantId(busHotel.getTenantId());
|
|
|
- messageDTO.setTitle(room.getPrefix() + room.getName() + "房间被入住-" + DateUtils.formatDate(new Date()));
|
|
|
- messageDTO.setContent(room.getPrefix() + room.getName() + "房间被入住-" + DateUtils.formatDate(new Date()));
|
|
|
- messageDTO.setCategory(CommonConstant.MSG_CATEGORY_1);
|
|
|
- messageDTO.setMsgCategoryDetail(CommonConstant.MSG_ORDER);
|
|
|
- sysBaseAPI.sendSysAnnouncement(messageDTO);
|
|
|
- }
|
|
|
|
|
|
CesAllDayPriceRule cesAllDayPriceRule = allDayPriceRuleService.getOne(Wrappers.<CesAllDayPriceRule>lambdaQuery().eq(CesAllDayPriceRule::getHotelId,hotelId).eq(CesAllDayPriceRule::getInvalid,false));
|
|
|
if(ObjectUtils.isEmpty(cesAllDayPriceRule)) {
|
|
|
throw new JeecgBootException("未找到超时收费规则");
|
|
|
}
|
|
|
- if (livingOrder.getLivingType() != 5){
|
|
|
+ if (ObjectUtil.equals(LivingTypeEnum.ALL_DAY.getKey(), livingOrder.getLivingType())){
|
|
|
Calendar calendar = getRemindTime(livingOrder, cesAllDayPriceRule, livingRoomOrderInfo.getBookingType());
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), calendar.getTimeInMillis());
|
|
|
- } else {
|
|
|
-
|
|
|
+ } else if (ObjectUtil.equals(LivingTypeEnum.HOURS_RENT.getKey(), livingOrder.getLivingType())){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(livingOrder.getDueOutTime());
|
|
|
+ calendar.add(Calendar.MINUTE, -30);
|
|
|
+ redisTemplate.opsForZSet().add("sys:cache:message:willEndOrder", livingOrder.getId(), calendar.getTimeInMillis());
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), livingOrder.getDueOutTime().getTime());
|
|
|
+ } else if(ObjectUtil.equals(LivingTypeEnum.LONG_RENT.getKey(), livingOrder.getLivingType())){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(livingOrder.getDueOutTime());
|
|
|
+ calendar.add(Calendar.DAY_OF_YEAR, -15);
|
|
|
+ redisTemplate.opsForZSet().add("sys:cache:message:willEndOrder", livingOrder.getId(), calendar.getTimeInMillis());
|
|
|
}
|
|
|
roomsService.getReserveRoom();
|
|
|
//</editor-fold>
|
|
|
@@ -1203,7 +1197,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
// 查看房间预约情况
|
|
|
List<BusRoomBookingOrders> clashOrder = baseMapper.findBookingOrder(roomIds, livingData.getOrderInfo().getArrivalTime(), livingData.getOrderInfo().getDueOutTime());
|
|
|
- if (!clashOrder.isEmpty()){
|
|
|
+ long count = clashOrder.stream().filter(e -> !StrUtil.equals(e.getId(), livingData.getOrderInfo().getId())).count();
|
|
|
+ if (count > 0) {
|
|
|
throw new JeecgBootException("房间已被预约");
|
|
|
}
|
|
|
// 是预约单先将预约单与房间关联删掉。因为原来这个接口是自己入住的接口,后来预定也要调这个接口,只能先将预定时添加的BusRoomBookingOrders关联表删掉,重新进行关联
|
|
|
@@ -1245,29 +1240,33 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// List<String> bookingOrderIds = rooms.stream().map(s->s.getBookingOrderId()).collect(Collectors.toList());
|
|
|
// 这里只获取当天预约的房间预约单,而非上面的那种情况,即:ces_rooms 表中的booking_order_id作废
|
|
|
List<TodayBookingQueryDto> roomBookingOrders = baseMapper.getTodayBookingOrder(rooms.stream().map(s->s.getId()).collect(Collectors.toList()));
|
|
|
- List<String> bookingOrderIds = roomBookingOrders.stream().map(s->s.getBookingOrderId()).collect(Collectors.toList());
|
|
|
- List<String> livingOrderIds = rooms.stream().map(s->s.getLivingOrderId()).collect(Collectors.toList());
|
|
|
- List<BusRoomBookingOrders> bookingOrders = bookingOrderIds.size() > 0 ?
|
|
|
+ List<String> bookingOrderIds = roomBookingOrders.stream().map(TodayBookingQueryDto::getBookingOrderId).collect(Collectors.toList());
|
|
|
+ List<String> livingOrderIds = rooms.stream().map(CesRooms::getLivingOrderId).collect(Collectors.toList());
|
|
|
+ List<BusRoomBookingOrders> bookingOrders = !bookingOrderIds.isEmpty() ?
|
|
|
this.list(Wrappers.<BusRoomBookingOrders>query().in("id",bookingOrderIds))
|
|
|
:new ArrayList<>();
|
|
|
- List<BusBookingLayoutDayPrice> bookingLayoutDayPrices =bookingOrderIds.size() > 0? dayPriceService.list(Wrappers.<BusBookingLayoutDayPrice>query()
|
|
|
+ List<BusBookingLayoutDayPrice> bookingLayoutDayPrices = !bookingOrderIds.isEmpty() ? dayPriceService.list(Wrappers.<BusBookingLayoutDayPrice>query()
|
|
|
.in("booking_order_id",bookingOrderIds)):new ArrayList<>();
|
|
|
- List<String> bookingCusIds = bookingOrders.stream().map(s->s.getContactId()).collect(Collectors.toList());
|
|
|
- List<BusCustomer> bookingCustomers =bookingCusIds.size() > 0? customerService.list(Wrappers.<BusCustomer>query()
|
|
|
+ List<String> bookingCusIds = bookingOrders.stream().map(BusRoomBookingOrders::getContactId).collect(Collectors.toList());
|
|
|
+ List<BusCustomer> bookingCustomers = !bookingCusIds.isEmpty() ? customerService.list(Wrappers.<BusCustomer>query()
|
|
|
.in("id",bookingCusIds)):new ArrayList<>();
|
|
|
- List<BusRoomsLivingOrder> livingOrders =livingOrderIds.size() > 0? roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
|
|
|
+ List<BusRoomsLivingOrder> livingOrders = !livingOrderIds.isEmpty() ? roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
|
|
|
.in("id",livingOrderIds)):new ArrayList<>();
|
|
|
- List<BusLivingCustomer> livingCustomers =livingOrderIds.size() > 0? livingCustomerService.list(Wrappers.<BusLivingCustomer>query()
|
|
|
+ List<BusLivingCustomer> livingCustomers = !livingOrderIds.isEmpty() ? livingCustomerService.list(Wrappers.<BusLivingCustomer>query()
|
|
|
.in("living_order_id",livingOrderIds)):new ArrayList<>();
|
|
|
- List<BusLivingLayoutDayPrice> livingLayoutDayPrices =livingOrderIds.size()>0? livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
|
|
|
+ // 每日房价
|
|
|
+ List<BusLivingLayoutDayPrice> livingLayoutDayPrices = !livingOrderIds.isEmpty() ? livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
|
|
|
.in("living_order_id",livingOrderIds)):new ArrayList<>();
|
|
|
+ Map<String, List<BusLivingLayoutDayPrice>> livingDayPriceMap = livingLayoutDayPrices.stream().collect(Collectors.groupingBy(BusLivingLayoutDayPrice::getLivingOrderId));
|
|
|
|
|
|
|
|
|
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);
|
|
|
-
|
|
|
+ List<BusOrderFee> fees = feeService.list(Wrappers.<BusOrderFee>query()
|
|
|
+ .in("living_order_id",livingOrderIds));
|
|
|
+ Map<String, List<BusOrderFee>> feesMap = fees.stream().collect(Collectors.groupingBy(BusOrderFee::getLivingOrderId));
|
|
|
rooms.forEach(s-> {
|
|
|
FloorBuildingRoomVo vo = new FloorBuildingRoomVo();
|
|
|
vo.setRoomId(s.getId());
|
|
|
@@ -1307,7 +1306,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
Optional<BusRoomsLivingOrder> opLivingOrder=livingOrders.stream().filter(a->a.getId().equals(s.getLivingOrderId())).findFirst();
|
|
|
if(opLivingOrder.isPresent()) {
|
|
|
BusRoomsLivingOrder livingOrder = opLivingOrder.get();
|
|
|
- Map<String,BigDecimal> feeMap = getRoomOrderFees(livingOrder.getId());
|
|
|
+ Map<String,BigDecimal> feeMap = getRoomOrderFees(livingOrder.getId(), feesMap);
|
|
|
livingOrder.setXiaoFei(feeMap.get("xf"));
|
|
|
livingOrder.setShouKuan(feeMap.get("sk"));
|
|
|
livingOrder.setDeposit(feeMap.get("yj"));
|
|
|
@@ -1332,15 +1331,17 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
vo.getLivingData().setLivingOrder(livingOrder);
|
|
|
Optional<BusLivingCustomer> opLivingCustomer = livingCustomers.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).findFirst();
|
|
|
opLivingCustomer.ifPresent(busLivingCustomer -> vo.getLivingData().setLivingCustomers(busLivingCustomer));
|
|
|
- vo.getLivingData().setPrice(
|
|
|
- livingLayoutDayPrices.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).collect(Collectors.toList())
|
|
|
- );
|
|
|
+// vo.getLivingData().setPrice(
|
|
|
+// livingLayoutDayPrices.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).collect(Collectors.toList()));
|
|
|
+ vo.getLivingData().setPrice(livingDayPriceMap.get(opLivingOrder.get().getId()));
|
|
|
}
|
|
|
roomVos.add(vo);
|
|
|
});
|
|
|
+
|
|
|
return roomVos;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private Integer getLivingDayCount(BusRoomsLivingOrder order) {
|
|
|
Calendar calendarBeijian = new GregorianCalendar();
|
|
|
calendarBeijian.setTime(order.getDueOutTime());
|
|
|
@@ -1350,9 +1351,11 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return count == 0 ? 1:count;
|
|
|
}
|
|
|
|
|
|
- private Map<String, BigDecimal> getRoomOrderFees(String livingOrderId) {
|
|
|
- List<BusOrderFee> fees = feeService.list(Wrappers.<BusOrderFee>query()
|
|
|
- .eq("living_order_id",livingOrderId));
|
|
|
+ private Map<String, BigDecimal> getRoomOrderFees(String livingOrderId, Map<String, List<BusOrderFee>> feesMap) {
|
|
|
+ List<BusOrderFee> fees = feesMap.get(livingOrderId);
|
|
|
+ if (fees.isEmpty()){
|
|
|
+ return new HashMap<>();
|
|
|
+ }
|
|
|
List<BusOrderFee> xiaofeiList = fees.stream().filter(s->s.getFeeType().equals(1)).collect(Collectors.toList());
|
|
|
List<BusOrderFee> shoukuanList = fees.stream().filter(s->s.getFeeType().equals(2)).collect(Collectors.toList());
|
|
|
List<BusOrderFee> depositList = shoukuanList.stream().filter(s->ObjectUtil.equals(s.getSubjectType(),"1")).collect(Collectors.toList());
|
|
|
@@ -1495,7 +1498,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
dayOrderFee.setRoomId(orderRoom.getId());
|
|
|
String roomName = orderRoom.getPrefix() != null?orderRoom.getPrefix():"";
|
|
|
roomName += roomName + orderRoom.getName();
|
|
|
- dayOrderFee.setRemark("【"+roomName + "】 "+ DateUtils.formatDate(new Date()) + " 当日房费");
|
|
|
+ dayOrderFee.setRemark(DateUtils.formatDate(new Date(), "MM-dd") + "房费");
|
|
|
dayOrderFee.setLivingOrderId(s.getId());
|
|
|
dayOrderFee.setHotelId(hotelId);
|
|
|
feeService.save(dayOrderFee);
|
|
|
@@ -1607,18 +1610,21 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
LambdaQueryWrapper<BusRoomsLivingOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.in(BusRoomsLivingOrder::getId,set);
|
|
|
+ queryWrapper.eq(BusRoomsLivingOrder::getHotelId,hotelId);
|
|
|
List<BusRoomsLivingOrder> livingOrderList = roomsLivingOrderService.list(queryWrapper);
|
|
|
+ List<String> bookingIds = livingOrderList.stream().map(BusRoomsLivingOrder::getBookingOrderId).collect(Collectors.toList());
|
|
|
+ if (bookingIds.isEmpty()){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ List<CesHourRoomRule> cesHourRoomRuleList = hourRoomRuleService.list(Wrappers.<CesHourRoomRule>lambdaQuery().eq(CesHourRoomRule::getHotelId, hotelId));
|
|
|
+ List<BusRoomBookingOrders> bookingOrders = list(Wrappers.<BusRoomBookingOrders>lambdaQuery().in(BusRoomBookingOrders::getId, bookingIds));
|
|
|
livingOrderList.forEach(e -> {
|
|
|
- BusRoomBookingOrders roomBookingOrder = getById(e.getBookingOrderId());
|
|
|
- if (ObjectUtil.isEmpty(roomBookingOrder)){
|
|
|
+ Optional<BusRoomBookingOrders> optional = bookingOrders.stream().filter(ele -> ele.getId().equals(e.getBookingOrderId())).findFirst();
|
|
|
+ if (!optional.isPresent()){
|
|
|
return;
|
|
|
}
|
|
|
- List<CesRooms> cesRooms = roomsService.list(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getLivingOrderId, e.getId()));
|
|
|
- if (CollUtil.isNotEmpty(cesRooms)){
|
|
|
- System.out.println(cesRooms.get(0).getName());
|
|
|
- }
|
|
|
// 全天房
|
|
|
- if (ObjectUtil.equals(1,roomBookingOrder.getBookingType())){
|
|
|
+ if (ObjectUtil.equals(1,optional.get().getBookingType())){
|
|
|
// 如果房间超时是按分钟加收费用
|
|
|
if (TimeOutRuleEnum.ADD_BY_MINUTE.getKey().equals(cesAllDayPriceRule.getTimeOutRule())){
|
|
|
addByMinute(e, cesAllDayPriceRule);
|
|
|
@@ -1628,14 +1634,110 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
notAdd(e, cesAllDayPriceRule);
|
|
|
}
|
|
|
// 钟点房
|
|
|
- } else if(ObjectUtil.equals(2,roomBookingOrder.getBookingType())){
|
|
|
- // TODO: 2023/10/24 钟点房超时收费
|
|
|
+ } else if(ObjectUtil.equals(2,optional.get().getBookingType())){
|
|
|
+ addHourFee(cesHourRoomRuleList, e, cesAllDayPriceRule);
|
|
|
}
|
|
|
});
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
+ private void addHourFee(List<CesHourRoomRule> cesHourRoomRuleList, BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule) {
|
|
|
+ // TODO: 2023/10/24 钟点房超时收费
|
|
|
+ Optional<CesHourRoomRule> ruleOptional = cesHourRoomRuleList.stream().filter(rule -> rule.getId().equals(livingOrder.getHourRoomId())).findFirst();
|
|
|
+ ruleOptional.ifPresent(rule -> {
|
|
|
+ Calendar nowCalendar = Calendar.getInstance();
|
|
|
+ Calendar nextCalendar = Calendar.getInstance();
|
|
|
+ nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
+ Integer overMinutes = Math.round((nowCalendar.getTimeInMillis() - nextCalendar.getTimeInMillis()) / (1000 * 60 ));
|
|
|
+ if (overMinutes <= 0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
+ if (ObjectUtil.isEmpty(bookingroom)){
|
|
|
+ log.info("未找到订单{}对应的房间", livingOrder.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
+ if (rule.getLimitTimeTransferAllDay() != 0 && overMinutes > rule.getLimitTimeTransferAllDay()){
|
|
|
+ // 转为全天房
|
|
|
+ Date arrivalTime = livingOrder.getArrivalTime();
|
|
|
+ Calendar arrivalCalendar = Calendar.getInstance();
|
|
|
+ arrivalCalendar.setTime(arrivalTime);
|
|
|
+ DateTime leaveTime = DateUtil.parse(cesAllDayPriceRule.getLeaveTime(), "HH:mm");
|
|
|
+ Calendar leaveCalendar = Calendar.getInstance();
|
|
|
+ leaveCalendar.setTime(leaveTime);
|
|
|
+ leaveCalendar.set(Calendar.YEAR, arrivalCalendar.get(Calendar.YEAR));
|
|
|
+ leaveCalendar.set(Calendar.MONTH, arrivalCalendar.get(Calendar.MONTH));
|
|
|
+ leaveCalendar.set(Calendar.DAY_OF_MONTH, arrivalCalendar.get(Calendar.DAY_OF_MONTH));
|
|
|
+ Calendar enterCalendar = Calendar.getInstance();
|
|
|
+ DateTime enterTime = DateUtil.parse(cesAllDayPriceRule.getEnterTime(), "HH:mm");
|
|
|
+ enterCalendar.setTime(enterTime);
|
|
|
+ if (arrivalCalendar.get(Calendar.HOUR) > enterCalendar.get(Calendar.HOUR)
|
|
|
+ || arrivalCalendar.get(Calendar.HOUR) == enterCalendar.get(Calendar.HOUR)
|
|
|
+ && arrivalCalendar.get(Calendar.MINUTE) > enterCalendar.get(Calendar.MINUTE)){
|
|
|
+ // 如果预抵时间在enterTime后面 则预离时间为隔天
|
|
|
+ leaveCalendar.add(Calendar.DAY_OF_YEAR, 1);
|
|
|
+ }
|
|
|
+ livingOrder.setDueOutTime(leaveCalendar.getTime());
|
|
|
+ livingOrder.setLivingType(LivingTypeEnum.ALL_DAY.getKey());
|
|
|
+ List<BusOrderFee> busOrderFees = feeService.list(Wrappers.<BusOrderFee>lambdaQuery()
|
|
|
+ .eq(BusOrderFee::getLivingOrderId, livingOrder.getId()).eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()));
|
|
|
+ Optional<BusOrderFee> orderFee = busOrderFees.stream().filter(e -> !e.getIsOverTime()).findFirst();
|
|
|
+
|
|
|
+ // 修改房费为全天房费
|
|
|
+ orderFee.ifPresent(e -> {
|
|
|
+ BusLivingLayoutDayPrice dayPrice = livingLayoutDayPriceService.getOne(Wrappers.<BusLivingLayoutDayPrice>lambdaQuery()
|
|
|
+ .eq(BusLivingLayoutDayPrice::getLivingOrderId, livingOrder.getId())
|
|
|
+ .eq(BusLivingLayoutDayPrice::getDayTime, DateUtils.formatDate(livingOrder.getArrivalTime())).last("limit 1"));
|
|
|
+ BigDecimal money = schemeLayoutDailyPriceService.getOneDayPrice(bookingroom.getRoomLayoutId(), livingOrder, new Date());
|
|
|
+ e.setMoney(money);
|
|
|
+ feeService.updateById(e);
|
|
|
+ if (dayPrice != null){
|
|
|
+ dayPrice.setPrice(money);
|
|
|
+ livingLayoutDayPriceService.updateById(dayPrice);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 删除超时收费项
|
|
|
+ Optional<BusOrderFee> overTimeFee = busOrderFees.stream().filter(BusOrderFee::getIsOverTime).findFirst();
|
|
|
+ overTimeFee.ifPresent(e -> {
|
|
|
+ feeService.removeById(e.getId());
|
|
|
+ });
|
|
|
+ roomsLivingOrderService.updateById(livingOrder);
|
|
|
+ leaveCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),leaveCalendar.getTimeInMillis());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //已经超时的 不足时间
|
|
|
+ Integer minutesDiff = overMinutes % rule.getExceedTime();
|
|
|
+ // 超出 超时时间 的数量
|
|
|
+ Integer minutesDiffNum = (int) Math.floor(overMinutes / rule.getExceedTime());
|
|
|
+ // 不足时间 数量
|
|
|
+ Integer moreThenMinuteDiffNum = (int) Math.floor(minutesDiff / rule.getNotReachExceedTime());
|
|
|
+ // 加上下一次不足时间 >= 超出时间,用超出时间
|
|
|
+ if (minutesDiff + rule.getNotReachExceedTime() > rule.getExceedTime()){
|
|
|
+ Integer newOverTime = rule.getExceedTime() * (minutesDiffNum + 1);
|
|
|
+ nextCalendar.add(Calendar.MINUTE, newOverTime);
|
|
|
+ }else {
|
|
|
+ nextCalendar.add(Calendar.MINUTE, rule.getNotReachExceedTime());
|
|
|
+ }
|
|
|
+ log.info("钟点房{}今日超时分钟{},超时时间数量{},不足时间数量{}",livingOrder.getId(),overMinutes,minutesDiffNum,moreThenMinuteDiffNum);
|
|
|
+ BigDecimal money = rule.getExceedPay().multiply(BigDecimal.valueOf(minutesDiffNum))
|
|
|
+ .add(rule.getNotReachExceedTimePay().multiply(BigDecimal.valueOf(moreThenMinuteDiffNum)));
|
|
|
+ // 有上限,且金额超过当前上限
|
|
|
+ if (rule.getMaxExtraPay().compareTo(new BigDecimal(0)) != 0 && rule.getMaxExtraPay().compareTo(money) < 0){
|
|
|
+ money = rule.getMaxExtraPay();
|
|
|
+ }
|
|
|
+ fee.setMoney(money);
|
|
|
+ fee.setDayTime(nowCalendar.getTime());
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
|
|
|
-
|
|
|
- return null;
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ log.info(format.format(nextCalendar.getTime()));
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
+ // 添加超时房费
|
|
|
+ feeService.saveOrUpdate(fee);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1680,6 +1782,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}else {
|
|
|
nextCalendar.add(Calendar.MINUTE, cesAllDayPriceRule.getMoreThenMinute());
|
|
|
}
|
|
|
+// log.info(DateUtil.format(nextCalendar.getTime(), "yyyy-MM-dd HH:mm"));
|
|
|
|
|
|
log.info("{}今日超时分钟{},超时时间数量{},不足时间数量{}",livingOrder.getId(),overMinutes,minutesDiffNum,moreThenMinuteDiffNum);
|
|
|
|
|
|
@@ -1695,14 +1798,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// 如果下一次增加收费时间大于 全天收费时间 设置
|
|
|
}else {
|
|
|
// 如果满足全天收费要求,预离时间增加1天
|
|
|
- CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
-
|
|
|
- BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
+ BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, bookingroom.getRoomLayoutId());
|
|
|
fee.setMoney(dayPrice.getPrice());
|
|
|
fee.setDayTime(date);
|
|
|
// 获取每天超时时间,如果超过预离时间,修改预离时间
|
|
|
nextCalendar = getNextCalendar(livingOrder, nowCalendar,cesAllDayPriceRule);
|
|
|
fee.setRemark(DateUtils.formatDate(nowCalendar.getTime(), "MM-dd") + "房费");
|
|
|
+ fee.setIsOverTime(false);
|
|
|
}
|
|
|
// 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
@@ -1721,19 +1823,19 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
log.info("未找到订单{}对应的房间", livingOrder.getId());
|
|
|
return;
|
|
|
}
|
|
|
- CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
// 查询当天房间超时消费
|
|
|
BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
// 需要支付完整费用时间的最后时间
|
|
|
Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
+ BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, bookingroom.getRoomLayoutId());
|
|
|
if (nextCalendar.getTime().compareTo(endTime) < 0){
|
|
|
// 超时收取半天费用
|
|
|
- fee.setMoney(layout.getMarketPrice().divide(new BigDecimal(2)));
|
|
|
+ fee.setMoney(dayPrice.getPrice().divide(new BigDecimal(2)));
|
|
|
nextCalendar.setTime(endTime);
|
|
|
} else {
|
|
|
// 添加每日房费
|
|
|
- BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
fee.setMoney(dayPrice.getPrice());
|
|
|
+ fee.setIsOverTime(false);
|
|
|
// 获取每天超时时间,如果超过预离时间,修改预离时间
|
|
|
nextCalendar = getNextCalendar(livingOrder, nowCalendar,cesAllDayPriceRule);
|
|
|
}
|
|
|
@@ -1752,15 +1854,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
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){
|
|
|
// 添加每日房费
|
|
|
- BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
+ BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, bookingroom.getRoomLayoutId());
|
|
|
fee.setMoney(dayPrice.getPrice());
|
|
|
+ fee.setIsOverTime(false);
|
|
|
// 获取每天超时时间,如果超过预离时间,修改预离时间
|
|
|
nextCalendar = getNextCalendar(livingOrder, nowCalendar,cesAllDayPriceRule);
|
|
|
}
|
|
|
@@ -1770,11 +1872,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
feeService.saveOrUpdate(fee);
|
|
|
}
|
|
|
|
|
|
- public BusLivingLayoutDayPrice addDayPrice(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom, BigDecimal money){
|
|
|
+ public BusLivingLayoutDayPrice addDayPrice(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom, String layoutId){
|
|
|
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()){
|
|
|
+ // 根据房价方案查询价格
|
|
|
+ BigDecimal money = schemeLayoutDailyPriceService.getOneDayPrice(layoutId, livingOrder, new Date());
|
|
|
BusLivingLayoutDayPrice nPrice = new BusLivingLayoutDayPrice();
|
|
|
nPrice.setBookingRoomId(livingOrder.getBookingRoomId());
|
|
|
try {
|
|
|
@@ -1782,6 +1886,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
} catch (ParseException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+
|
|
|
nPrice.setRoomId(bookingroom.getRoomId());
|
|
|
nPrice.setRoomLayoutId(bookingroom.getRoomLayoutId());
|
|
|
nPrice.setPrice(money);
|
|
|
@@ -1794,14 +1899,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
|
|
|
public BusOrderFee getOverTimeFee(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom){
|
|
|
- Calendar nowCalendar = Calendar.getInstance();
|
|
|
- nowCalendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- nowCalendar.set(Calendar.MINUTE, 0);
|
|
|
- nowCalendar.set(Calendar.SECOND, 0);
|
|
|
- nowCalendar.set(Calendar.MILLISECOND, 0);
|
|
|
+// Calendar nowCalendar = Calendar.getInstance();
|
|
|
+// nowCalendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+// nowCalendar.set(Calendar.MINUTE, 0);
|
|
|
+// nowCalendar.set(Calendar.SECOND, 0);
|
|
|
+// nowCalendar.set(Calendar.MILLISECOND, 0);
|
|
|
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()).ge(BusOrderFee::getCreateTime, nowCalendar.getTime()));
|
|
|
+ .eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()).eq(BusOrderFee::getIsOverTime, true)
|
|
|
+ .orderByDesc(BusOrderFee::getCreateTime));
|
|
|
if (CollUtil.isNotEmpty(feeList)) {
|
|
|
return feeList.get(0);
|
|
|
}
|
|
|
@@ -1815,6 +1921,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
fee.setFeeType(FeeType.CONSUME.getKey());
|
|
|
fee.setRoomId(bookingroom.getRoomId());
|
|
|
fee.setRemark("超时房费");
|
|
|
+ fee.setIsOverTime(true);
|
|
|
return fee;
|
|
|
}
|
|
|
|
|
|
@@ -3189,54 +3296,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
if(FeeSubjectType.val(s.getSubjectType()) == null) {
|
|
|
throw new JeecgBootException("收款项目不存在,请核对后操作");
|
|
|
}
|
|
|
-// BusRoomPayType payType = payTypeService.getById(s.getPayType());
|
|
|
-// if (payType == null){
|
|
|
-// throw new JeecgBootException("支付方式不存在");
|
|
|
-// }
|
|
|
-// if("会员卡".equals(payType.getName())){
|
|
|
-// BusMemberBalanceLog memberBalanceLog = new BusMemberBalanceLog();
|
|
|
-// if (user.getRelTenantIds() != null && !user.getRelTenantIds().isEmpty()) {
|
|
|
-// memberBalanceLog.setTenantId(user.getRelTenantIds());
|
|
|
-// } else {
|
|
|
-// throw new JeecgBootException("当前登录人租户信息错误");
|
|
|
-// }
|
|
|
-// memberBalanceLog.setWithhold(s.getMoney());
|
|
|
-// memberBalanceLog.setMoney(BigDecimal.valueOf(0));
|
|
|
-// memberBalanceLog.setMemberId(livingData.getOrderInfo().getVipCustomerId());
|
|
|
-// memberBalanceLog.setHotelId(livingData.getOrderInfo().getHotelId());
|
|
|
-// memberBalanceLog.setType(2);
|
|
|
-// memberBalanceLog.setOrderFeeId(s.getId());
|
|
|
-// memberBalanceLogService.saveBalance(memberBalanceLog);
|
|
|
-// }
|
|
|
});
|
|
|
-// if(!findRoomFees.isEmpty()) feeService.saveBatch(findRoomFees);
|
|
|
-// // 处理协议单位记账
|
|
|
-// findRoomFees.forEach(s->{
|
|
|
-// if(payTypes.stream().anyMatch(k->k.getId().equals(s.getPayType()) && k.getName().equals("单位记账")) ) {
|
|
|
-// BusAgreementOrderFee agreementOrderFee = new BusAgreementOrderFee();
|
|
|
-// if(s.getAgreementUnitId() == null || s.getAgreementUnitId().isEmpty()) throw new JeecgBootException("请选择协议单位");
|
|
|
-// BusMarketAgreementUnit unit = marketAgreementUnitService.getById(s.getAgreementUnitId());
|
|
|
-// if(unit == null) throw new JeecgBootException("协议单位未找到");
|
|
|
-// if(unit.getBookkStatus() != null && unit.getBookkStatus().equals(1)) throw new JeecgBootException("不允许该单位记账");
|
|
|
-// BigDecimal usedAmount;
|
|
|
-// if(unit.getAmountUsed() == null) usedAmount = new BigDecimal(0);
|
|
|
-// else usedAmount = unit.getAmountUsed();
|
|
|
-// double incrementBalance = (usedAmount.add(s.getMoney())).doubleValue();
|
|
|
-// // 记账限额超出,返回异常结果!
|
|
|
-// if(unit.getBookkeeping() != null && !unit.getBookkeeping().equals(new BigDecimal(0)) && unit.getBookkeeping().doubleValue() < incrementBalance)
|
|
|
-// throw new JeecgBootException("记账超额!记账单位限额为"+unit.getBookkeeping().doubleValue()+",已使用"+usedAmount.doubleValue());
|
|
|
-// agreementOrderFee.setAgreementUnitId(s.getAgreementUnitId());
|
|
|
-// agreementOrderFee.setOrderFeeId(s.getId());
|
|
|
-// agreementOrderFee.setCreatedTime(new Date());
|
|
|
-// agreementOrderFee.setCreateUserId(user != null ?user.getId():"");
|
|
|
-// agreementOrderFee.setSettleStatus(1);
|
|
|
-// agreementOrderFeeService.save(agreementOrderFee);
|
|
|
-// // 更新已使用的记账
|
|
|
-// unit.setAmountUsed(new BigDecimal(incrementBalance));
|
|
|
-// unit.setUpdateTime(new Date());
|
|
|
-// marketAgreementUnitService.updateById(unit);
|
|
|
-// }
|
|
|
-// });
|
|
|
feeService.collectionBatch(findRoomFees, hotelId);
|
|
|
}
|
|
|
|
|
|
@@ -3296,6 +3356,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
livingOrder.setTeamName(bkOrder.getTeamName());
|
|
|
livingOrder.setTeamTypeDicId(bkOrder.getTeamTypeDicId());
|
|
|
livingOrder.setRoomPriceSlnId(bkOrder.getRoomPriceSlnId());
|
|
|
+ livingOrder.setLongSchemeId(bkOrder.getLongSchemeId());
|
|
|
livingOrder.setLeaderName(bkOrder.getLeaderName());
|
|
|
livingOrder.setPublicConsumeFee(bkOrder.getPublicConsumeFee());
|
|
|
livingOrder.setPublicMeetingFee(bkOrder.getPublicMeetingFee());
|
|
|
@@ -3665,5 +3726,53 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void addWillLeaveMess(String parameter) {
|
|
|
+ BusHotel busHotel = busHotelService.getById(parameter);
|
|
|
+ if (busHotel == null){
|
|
|
+ log.info("通过id{}未找到酒店", parameter);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Set<Object> set = redisTemplate.opsForZSet().rangeByScore("sys:cache:message:willEndOrder", 0, Calendar.getInstance().getTimeInMillis());
|
|
|
+ if (CollUtil.isEmpty(set)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<CesRooms> cesRooms = roomsService.list(Wrappers.<CesRooms>lambdaQuery().in(CesRooms::getLivingOrderId, set).eq(CesRooms::getHotelId, parameter));
|
|
|
+ if (cesRooms.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<BusRoomsLivingOrder> roomsLivingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>lambdaQuery()
|
|
|
+ .in(BusRoomsLivingOrder::getId, set).eq(BusRoomsLivingOrder::getHotelId, parameter));
|
|
|
+ LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(SysUser::getDelFlag, 0);
|
|
|
+ lambdaQueryWrapper.eq(SysUser::getRelTenantIds, busHotel.getTenantId());
|
|
|
+ List<SysUser> sysUsers = sysUserService.list(lambdaQueryWrapper);
|
|
|
+ String userIds = "";
|
|
|
+ for (SysUser sysUser : sysUsers) {
|
|
|
+ userIds += sysUser.getUsername() + ",";
|
|
|
+ }
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String finalUserIds = userIds;
|
|
|
+ set.forEach(e -> {
|
|
|
+ Optional<BusRoomsLivingOrder> orderOptional = roomsLivingOrders.stream().filter(ele -> ele.getId().equals(e)).findFirst();
|
|
|
+ Optional<CesRooms> roomsOptional = cesRooms.stream().filter(ele -> ele.getLivingOrderId().equals(e)).findFirst();
|
|
|
+ if (orderOptional.isPresent() && roomsOptional.isPresent()){
|
|
|
+ /*添加消息通知*/
|
|
|
+ String mesStr = roomsOptional.get().getPrefix() == null ? "" : roomsOptional.get().getPrefix()
|
|
|
+ + roomsOptional.get().getName() + "房间 " + LivingTypeEnum.val(orderOptional.get().getLivingType()).getTitle() + "即将到达预离时间";
|
|
|
+ MessageDTO messageDTO = new MessageDTO();
|
|
|
+ messageDTO.setFromUser("");
|
|
|
+ messageDTO.setToUser(finalUserIds);
|
|
|
+ messageDTO.setTenantId(busHotel.getTenantId());
|
|
|
+ messageDTO.setTitle(mesStr);
|
|
|
+ messageDTO.setContent(mesStr);
|
|
|
+ messageDTO.setCategory(CommonConstant.MSG_CATEGORY_1);
|
|
|
+ messageDTO.setMsgCategoryDetail(CommonConstant.MSG_ROOM);
|
|
|
+ sysBaseAPI.sendSysAnnouncement(messageDTO);
|
|
|
+ redisTemplate.opsForZSet().remove("sys:cache:message:willEndOrder", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|