|
|
@@ -18,7 +18,6 @@ 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;
|
|
|
@@ -32,7 +31,10 @@ 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.*;
|
|
|
+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.service.IFwRoomCleanService;
|
|
|
import org.jeecg.modules.fw.service.IFwRoomExamineService;
|
|
|
import org.jeecg.modules.fw.service.IFwRoomLockService;
|
|
|
@@ -41,6 +43,7 @@ import org.jeecg.modules.fw.vo.FwRoomLockVo;
|
|
|
import org.jeecg.modules.fw.vo.FwRoomRepairVo;
|
|
|
import org.jeecg.modules.kc.entity.KcDepositoryInGoods;
|
|
|
import org.jeecg.modules.kc.service.IKcDepositoryInGoodsService;
|
|
|
+import org.jeecg.modules.rooms.Enum.ChargeTypeEnum;
|
|
|
import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
|
|
|
import org.jeecg.modules.rooms.Enum.TimeOutRuleEnum;
|
|
|
import org.jeecg.modules.rooms.Vo.BookingRealtimeVo;
|
|
|
@@ -58,7 +61,6 @@ 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;
|
|
|
@@ -137,9 +139,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
private CesGoodsServiceImpl cesGoodsServiceImpl;
|
|
|
|
|
|
@Resource
|
|
|
- private IBusAgreementOrderFeeService agreementOrderFeeService;
|
|
|
-
|
|
|
- @Resource
|
|
|
private IBusMarketAgreementUnitService marketAgreementUnitService;
|
|
|
|
|
|
@Resource
|
|
|
@@ -165,6 +164,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
@Resource
|
|
|
private IBusCancelService cancelService;
|
|
|
+ @Autowired
|
|
|
+ private IBusParamPresetService busParamPresetService;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
|
@@ -178,6 +179,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Resource
|
|
|
private IBusHotelService busHotelService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ ICesHouseLongRentChargeService houseLongRentChargeService;
|
|
|
+ @Resource
|
|
|
+ ICesHouseLongRentMeterLogService houseLongRentMeterLogService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SysBaseApiImpl sysBaseAPI;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -194,12 +202,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
item.getOrderInfo().setBookingOrdersNo("YD"+sdf.format(System.currentTimeMillis()));
|
|
|
}
|
|
|
// 检测是否时间安排上有冲突
|
|
|
- List<String> roomIds = item.getRoomIds().stream().map(s->s.getRoomId()).collect(Collectors.toList());
|
|
|
+ List<String> roomIds = item.getRoomIds().stream().map(BookingLayoutRoomsDto::getRoomId).collect(Collectors.toList());
|
|
|
|
|
|
if(item.getConfirm() == null || !item.getConfirm()){
|
|
|
- if(roomIds.size() > 0) {
|
|
|
+ if(!roomIds.isEmpty()) {
|
|
|
List<BusBookingRooms> bookingRooms = baseMapper.conflictBookingTime(item.getOrderInfo().getArrivalTime(),item.getOrderInfo().getDueOutTime(),roomIds);
|
|
|
- if(bookingRooms.size() > 0) {
|
|
|
+ if(!bookingRooms.isEmpty()) {
|
|
|
String roomNames = bookingRooms.stream().map(p->p.getRoomId()).collect(Collectors.joining("|"));
|
|
|
throw new JeecgBootException("房间["+roomNames+"]与预约时间有冲突");
|
|
|
}
|
|
|
@@ -255,7 +263,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
} else {
|
|
|
item.getOrderInfo().setContactId(customer.getId());
|
|
|
}
|
|
|
- } else if(item.getLivingRoomDayPrices() != null && item.getLivingRoomDayPrices().size() > 0){
|
|
|
+ } else if(item.getLivingRoomDayPrices() != null && !item.getLivingRoomDayPrices().isEmpty()){
|
|
|
|
|
|
} else if (item.getOrderInfo().getBookingType() == 5) {
|
|
|
|
|
|
@@ -276,7 +284,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
throw new JeecgBootException("入住天数不能小于0");
|
|
|
|
|
|
}
|
|
|
- if(item.getRoomIds() == null || item.getRoomIds().size() == 0)
|
|
|
+ if(item.getRoomIds() == null || item.getRoomIds().isEmpty())
|
|
|
throw new JeecgBootException("请选择预定房间");
|
|
|
if(hotelId == null || hotelId.isEmpty()) throw new JeecgBootException("参数错误,酒店id");
|
|
|
item.getOrderInfo().setHotelId(hotelId);
|
|
|
@@ -317,12 +325,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
if (item.getOrderInfo().getBookingType() != 5){
|
|
|
// 处理预定每天的房型价格 Start
|
|
|
- if(item.getLivingRoomDayPrices() != null && item.getLivingRoomDayPrices().size() > 0) {
|
|
|
+ if(item.getLivingRoomDayPrices() != null && !item.getLivingRoomDayPrices().isEmpty()) {
|
|
|
if(item.getLivingRoomDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomId() == null))
|
|
|
throw new JeecgBootException("参数错误,请传入价格、日期、房型");
|
|
|
// 入住之后在save
|
|
|
} else {
|
|
|
- if(item.getLayoutDayPrices() == null || item.getLayoutDayPrices().size() == 0)
|
|
|
+ if(item.getLayoutDayPrices() == null || item.getLayoutDayPrices().isEmpty())
|
|
|
throw new JeecgBootException("参数错误,对应房型当天价格必传");
|
|
|
if(item.getLayoutDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null))
|
|
|
throw new JeecgBootException("参数错误,请传入价格、日期、房型");
|
|
|
@@ -333,7 +341,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
g.setBookingType(BookingOrdersType.NORMAL.getKey());
|
|
|
}
|
|
|
});
|
|
|
- List<String> lList = item.getRoomIds().stream().map(w->w.getLayoutId()).collect(Collectors.toList());
|
|
|
+ List<String> lList = item.getRoomIds().stream().map(BookingLayoutRoomsDto::getLayoutId).collect(Collectors.toList());
|
|
|
dayPriceService.saveBatch(item.getLayoutDayPrices().stream().filter(l->lList.contains(l.getRoomLayoutId())).collect(Collectors.toList()));
|
|
|
}
|
|
|
}
|
|
|
@@ -348,7 +356,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
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());
|
|
|
+ List<Integer> indexs = existTeams.stream().map(BusTeam::getSortIndex).collect(Collectors.toList());
|
|
|
while(true){
|
|
|
Integer finalSortIndex = sortIndex;
|
|
|
if(indexs.stream().filter(s->s.equals(finalSortIndex)).count() == 0) {
|
|
|
@@ -369,6 +377,14 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
addBusTeams(hotelId, bookingId);
|
|
|
}
|
|
|
}
|
|
|
+ redisTemplate.opsForZSet().remove("sys:cache:order:overTimerBooking", bookingId);
|
|
|
+ } else {
|
|
|
+ BusParamPreset paramPreset = busParamPresetService.getOne(Wrappers.<BusParamPreset>lambdaQuery().eq(BusParamPreset::getHotelId, hotelId));
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ if (ObjectUtil.equals(paramPreset.getStatus(), 1)) {
|
|
|
+ calendar.add(Calendar.MINUTE, paramPreset.getMinute());
|
|
|
+ }
|
|
|
+ redisTemplate.opsForZSet().add("sys:cache:order:overTimerBooking", bookingId, calendar.getTimeInMillis());
|
|
|
}
|
|
|
//</editor-fold>
|
|
|
roomsService.getReserveRoom();
|
|
|
@@ -377,7 +393,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
} else if(item.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
|
|
|
if(item.getOrderInfo().getTeamName() == null || item.getOrderInfo().getTeamName().isEmpty())
|
|
|
throw new JeecgBootException("请填写团队名称");
|
|
|
- if(item.getBatchRooms() == null || item.getBatchRooms().size() == 0)
|
|
|
+ if(item.getBatchRooms() == null || item.getBatchRooms().isEmpty())
|
|
|
throw new JeecgBootException("请添加批次信息");
|
|
|
saveOrUpdate(item.getOrderInfo());
|
|
|
item.getBatchRooms().forEach(c->{
|
|
|
@@ -392,7 +408,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
if(c.getDayCount() == null || c.getDayCount() <= 0)
|
|
|
throw new JeecgBootException("入住天数不能小于0");
|
|
|
}
|
|
|
- if(c.getRoomIds() == null || c.getRoomIds().size() == 0)
|
|
|
+ if(c.getRoomIds() == null || c.getRoomIds().isEmpty())
|
|
|
throw new JeecgBootException("请选择批次房间");
|
|
|
SimpleDateFormat sdfPc = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
|
|
c.setBatchNo("YDPC"+sdfPc.format(System.currentTimeMillis()));
|
|
|
@@ -543,7 +559,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
});
|
|
|
result.setLivingRoomIds(livingRooms);
|
|
|
//</editor-fold>
|
|
|
- BusTeam team = teamService.getOne(Wrappers.<BusTeam>query().eq("booking_order_id",orderId).eq("is_delete",0));
|
|
|
+ BusTeam team = teamService.getOne(Wrappers.<BusTeam>query().eq("booking_order_id",orderId).eq("is_delete",0).last("limit 1"));
|
|
|
if(team != null) {
|
|
|
result.setTeamTag(team.getSortIndex());
|
|
|
}
|
|
|
@@ -1034,25 +1050,24 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers, String hotelId, Boolean bookingLiving,
|
|
|
- BusRoomBookingOrders livingRoomOrderInfo, CesHouseLongRentScheme longRentScheme, List<BusLivingLayoutDayPrice> livingRoomDayPrices) {
|
|
|
+ BookingLayoutRoomsDto roomInfo, List<BusLivingLayoutDayPrice> livingRoomDayPrices) {
|
|
|
BusBookingRooms bkRoom = bookingRoomsService.getById(bookingRoomId);
|
|
|
if(bkRoom == null) throw new JeecgBootException("关联房间不存在");
|
|
|
BusRoomBookingOrders bookingOrders = getById(bkRoom.getBookingOrdersId());
|
|
|
if(bookingOrders == null) throw new JeecgBootException("房间预约单不存在");
|
|
|
LoginUser user = TokenUtils.getAuthUser();
|
|
|
-
|
|
|
//<editor-fold desc="订单复制 -- 散客入住">
|
|
|
BusRoomsLivingOrder livingOrder = null;
|
|
|
if(bkRoom.getBookingType().equals(BookingOrdersType.NORMAL.getKey())) {
|
|
|
//todo other
|
|
|
- if(livingRoomOrderInfo != null) {
|
|
|
- livingRoomOrderInfo.setId(bookingOrders.getId());
|
|
|
+ if(roomInfo.getRoomOrderInfo() != null) {
|
|
|
+ roomInfo.getRoomOrderInfo().setId(bookingOrders.getId());
|
|
|
// 设置为当前时间
|
|
|
- livingRoomOrderInfo.setArrivalTime(new Date());
|
|
|
+ roomInfo.getRoomOrderInfo().setArrivalTime(new Date());
|
|
|
} else {
|
|
|
- livingRoomOrderInfo = bookingOrders;
|
|
|
+ roomInfo.setRoomOrderInfo(bookingOrders);
|
|
|
}
|
|
|
- livingOrder = copyBookingToAcceptOrder(livingRoomOrderInfo);
|
|
|
+ livingOrder = copyBookingToAcceptOrder(roomInfo.getRoomOrderInfo());
|
|
|
livingOrder.setBookingRoomId(bookingRoomId);
|
|
|
} else if(bkRoom.getBookingType().equals(BookingOrdersType.TEAM.getKey())) {
|
|
|
BusBookingBatch batch = bookingBatchService.getById(bkRoom.getBookingBatchId());
|
|
|
@@ -1067,9 +1082,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
livingOrder.setArrivalTime(new Date());// todo 这个地方的入住开始时间应该怎么算
|
|
|
if(customers != null && !customers.isEmpty()) {
|
|
|
- if (StrUtil.isEmpty(customers.get(0).getCustomerId())){
|
|
|
+ BusCustomer customer = customerService.getOne(Wrappers.<BusCustomer>query().eq("name",customers.get(0).getCustomerName())
|
|
|
+ .eq("phone",customers.get(0).getPhone()));
|
|
|
+ if (customer == null){
|
|
|
long id = new Snowflake().nextId();
|
|
|
customers.get(0).setCustomerId(StrUtil.toString(id));
|
|
|
+ } else {
|
|
|
+ customers.get(0).setCustomerId(customer.getId());
|
|
|
}
|
|
|
livingOrder.setContactId(customers.get(0).getCustomerId());
|
|
|
} else throw new JeecgBootException("请添加入住人信息");
|
|
|
@@ -1089,6 +1108,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
Integer roomStatus = roomsService.changeLivingRoomStatus(room.getRoomStatus(), room.getLastRoomStatus());
|
|
|
room.setLastRoomStatus(room.getRoomStatus());
|
|
|
room.setRoomStatus(roomStatus);
|
|
|
+ room.setWaterMeter(roomInfo.getWaterMeter());
|
|
|
+ room.setEnergyMeter(roomInfo.getEnergyMeter());
|
|
|
+ room.setGasMeter(roomInfo.getGasMeter());
|
|
|
roomsService.updateById(room);
|
|
|
bkRoom.setRoomStatus(RoomStatusEnum.LIVE_DIRTY.getKey());
|
|
|
bookingRoomsService.updateById(bkRoom);
|
|
|
@@ -1134,7 +1156,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
//<editor-fold desc="todo:账单相关">
|
|
|
// if(bookingLiving != null && bookingLiving) {
|
|
|
|
|
|
- feeService.addBillFee(livingOrder, room,longRentScheme,livingRoomDayPrices);
|
|
|
+ feeService.addBillFee(livingOrder, room,roomInfo.getLongRentScheme(),livingRoomDayPrices);
|
|
|
|
|
|
// }
|
|
|
|
|
|
@@ -1144,8 +1166,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
throw new JeecgBootException("未找到超时收费规则");
|
|
|
}
|
|
|
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");
|
|
|
+ Calendar calendar = getRemindTime(livingOrder, cesAllDayPriceRule, roomInfo.getRoomOrderInfo().getBookingType());
|
|
|
redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), calendar.getTimeInMillis());
|
|
|
} else if (ObjectUtil.equals(LivingTypeEnum.HOURS_RENT.getKey(), livingOrder.getLivingType())){
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
@@ -1156,7 +1177,22 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
} 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);
|
|
|
+ calendar.add(Calendar.DAY_OF_YEAR, -7);
|
|
|
+ if (CollUtil.isEmpty(roomInfo.getLongRentScheme().getHouseLongRentChargeList())){
|
|
|
+ throw new JeecgBootException("未找到长租房收费项");
|
|
|
+ }
|
|
|
+ Optional<CesHouseLongRentCharge> chargeOptional = roomInfo.getLongRentScheme().getHouseLongRentChargeList().stream().filter(e -> e.getChargeType() == 2 && e.getIsMust()).findFirst();
|
|
|
+ if (!chargeOptional.isPresent()){
|
|
|
+ throw new JeecgBootException("未找到房租费项");
|
|
|
+ }
|
|
|
+ Integer cycle = chargeOptional.get().getNum();
|
|
|
+ Calendar nextCalendar = Calendar.getInstance();
|
|
|
+ nextCalendar.setTime(livingOrder.getArrivalTime());
|
|
|
+ calendar.setTime(livingOrder.getArrivalTime());
|
|
|
+ calendar.add(Calendar.MONTH, cycle);
|
|
|
+
|
|
|
+ log.info(DateUtil.format(calendar.getTime(),"yyyy-MM-dd"));
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), calendar.getTimeInMillis());
|
|
|
redisTemplate.opsForZSet().add("sys:cache:message:willEndOrder", livingOrder.getId(), calendar.getTimeInMillis());
|
|
|
}
|
|
|
roomsService.getReserveRoom();
|
|
|
@@ -1183,8 +1219,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
return calendar;
|
|
|
}
|
|
|
- @Resource
|
|
|
- private SysBaseApiImpl sysBaseAPI;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String customerLiving(BookingOrderSaveDto livingData, Boolean isTeam, String hotelId) {
|
|
|
@@ -1258,8 +1293,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
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<CesHouseLongRentCharge> houseLongRentCharges = houseLongRentChargeService.list(Wrappers.<CesHouseLongRentCharge>lambdaQuery().in(CesHouseLongRentCharge::getLivingOrderId, livingOrderIds));
|
|
|
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));
|
|
|
@@ -1334,6 +1368,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// vo.getLivingData().setPrice(
|
|
|
// livingLayoutDayPrices.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).collect(Collectors.toList()));
|
|
|
vo.getLivingData().setPrice(livingDayPriceMap.get(opLivingOrder.get().getId()));
|
|
|
+ List<CesHouseLongRentCharge> charges = houseLongRentCharges.stream().filter(charge -> livingOrder.getId().equals(charge.getLivingOrderId())).collect(Collectors.toList());
|
|
|
+ vo.getLivingData().setLongRentChargeList(charges);
|
|
|
}
|
|
|
roomVos.add(vo);
|
|
|
});
|
|
|
@@ -1393,6 +1429,17 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
queryWrapper.eq(BusOrderFee::getPreferentialStatus, 1);
|
|
|
}
|
|
|
List<BusOrderFee> orderFees = feeService.list(queryWrapper);
|
|
|
+ List<String> readMeterFeeIds = orderFees.stream().filter(e -> ObjectUtil.equals(
|
|
|
+ e.getSubjectType(), FeeSubjectType.SHUI_DIAN_MEI.getKey())).map(BusOrderFee::getId).collect(Collectors.toList());
|
|
|
+ List<CesHouseLongRentMeterLog> longRentMeterLogs;
|
|
|
+ if (!readMeterFeeIds.isEmpty()){
|
|
|
+ // 水电燃气读表日志
|
|
|
+ longRentMeterLogs = houseLongRentMeterLogService.list(Wrappers
|
|
|
+ .<CesHouseLongRentMeterLog>lambdaQuery().in(CesHouseLongRentMeterLog::getOrderFeeId, readMeterFeeIds));
|
|
|
+ } else {
|
|
|
+ longRentMeterLogs = new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
List<BusOrderFee> strikeBalanceFees = orderFees.stream().filter(e -> e.getReturnItem() && FeeType.CONSUME.getKey()
|
|
|
.equals(e.getFeeType())).collect(Collectors.toList());
|
|
|
// 最终返回费用。当费用是商品消费时找出商品。消费的费用 需要处理掉 冲账的费用
|
|
|
@@ -1412,6 +1459,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
Optional<BusOrderFeeGoodsVo> busOrderFeeGoodsVo = busOrderFeeGoodVos.stream()
|
|
|
.filter(orderFeeGoodVo -> StrUtil.equals(orderFeeGoodVo.getOrderFeeId(), e.getId())).findFirst();
|
|
|
busOrderFeeGoodsVo.ifPresent(e::setFeeGoodVo);
|
|
|
+ } else if (FeeSubjectType.SHUI_DIAN_MEI.getKey().equals(e.getSubjectType())){
|
|
|
+ Optional<CesHouseLongRentMeterLog> houseLongRentMeterLogs = longRentMeterLogs.stream()
|
|
|
+ .filter(meterLog -> StrUtil.equals(meterLog.getOrderFeeId(), e.getId())).findFirst();
|
|
|
+ houseLongRentMeterLogs.ifPresent(e::setLongRentMeterLog);
|
|
|
}
|
|
|
orderFeeList.add(e);
|
|
|
}
|
|
|
@@ -1510,94 +1561,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
- public Boolean syncDayRoomOrder(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(s->s.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");
|
|
|
- if(dueDate.getTime() < currDate.getTime()){
|
|
|
- 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;
|
|
|
- Date date = s.getDueOutTime();
|
|
|
- Calendar calendar = new GregorianCalendar();
|
|
|
- calendar.setTime(date);
|
|
|
- calendar.add(Calendar.DATE,1);
|
|
|
- s.setDueOutTime(calendar.getTime());
|
|
|
- roomsLivingOrderService.updateById(s);// 更新订单
|
|
|
- BusOrderFee dayOrderFee = new BusOrderFee();
|
|
|
- dayOrderFee.setDayTime(date);
|
|
|
- dayOrderFee.setCreateTime(new Date());
|
|
|
-
|
|
|
- dayOrderFee.setFeeType(1);
|
|
|
- dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
|
|
|
-
|
|
|
- List<BusLivingLayoutDayPrice> dayPrices = livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
|
|
|
- .eq("living_order_id",s.getId()));
|
|
|
- Optional<BusLivingLayoutDayPrice> opPrice = dayPrices.stream().filter(a-> DateUtils.formatDate(a.getDayTime()).equals(s)).findFirst();
|
|
|
- if(!opPrice.isPresent()){
|
|
|
- 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);
|
|
|
- }
|
|
|
- CesRooms orderRoom = inLiveRooms.stream().filter(a->a.getLivingOrderId().equals(s.getId())).findFirst().get();
|
|
|
- BigDecimal money = new BigDecimal(0);
|
|
|
-
|
|
|
- if(opPrice.isPresent()) {
|
|
|
- money = opPrice.get().getPrice();
|
|
|
- } else {
|
|
|
- money = layout.getMarketPrice();
|
|
|
- }
|
|
|
-
|
|
|
- dayOrderFee.setMoney(money);
|
|
|
- dayOrderFee.setRoomId(orderRoom.getId());
|
|
|
- String roomName = orderRoom.getPrefix() != null?orderRoom.getPrefix():"";
|
|
|
- roomName += roomName + orderRoom.getName();
|
|
|
- dayOrderFee.setRemark("【"+roomName + "】 "+ DateUtils.formatDate(date) + " 当日房费");
|
|
|
- dayOrderFee.setLivingOrderId(s.getId());
|
|
|
- dayOrderFee.setHotelId(hotelId);
|
|
|
- feeService.save(dayOrderFee);
|
|
|
- }
|
|
|
- } catch (ParseException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- });
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
public Boolean syncRoomOverTimeOrder(String hotelId) {
|
|
|
// 查询出当前时间内需要处理的超时订单
|
|
|
Set<Object> set = redisTemplate.opsForZSet().rangeByScore("overTimerOrder", 0, Calendar.getInstance().getTimeInMillis());
|
|
|
@@ -1636,11 +1599,75 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// 钟点房
|
|
|
} else if(ObjectUtil.equals(2,optional.get().getBookingType())){
|
|
|
addHourFee(cesHourRoomRuleList, e, cesAllDayPriceRule);
|
|
|
+ } else if(ObjectUtil.equals(5,optional.get().getBookingType())) {
|
|
|
+ addLongRentFee(e);
|
|
|
}
|
|
|
});
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public void addLongRentFee(BusRoomsLivingOrder livingOrder) {
|
|
|
+ BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
+ if (ObjectUtil.isEmpty(bookingroom)){
|
|
|
+ log.info("未找到订单{}对应的房间", livingOrder.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CesRooms room = roomsService.getById(bookingroom.getRoomId());
|
|
|
+ List<CesHouseLongRentCharge> list = houseLongRentChargeService.list(Wrappers.<CesHouseLongRentCharge>
|
|
|
+ lambdaQuery().eq(CesHouseLongRentCharge::getLivingOrderId, livingOrder.getId())
|
|
|
+ .eq(CesHouseLongRentCharge::getChargeType, ChargeTypeEnum.PERIODICITY.getKey()));
|
|
|
+ if (list.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Integer cycle = list.get(0).getNum();
|
|
|
+ List<BusOrderFee> orderFees = new ArrayList<>();
|
|
|
+ Calendar nowCalendar = Calendar.getInstance();
|
|
|
+ Calendar arriveCalendar = Calendar.getInstance();
|
|
|
+ arriveCalendar.setTime(livingOrder.getArrivalTime());
|
|
|
+ int year = nowCalendar.get(Calendar.YEAR) - arriveCalendar.get(Calendar.YEAR);
|
|
|
+ int month = nowCalendar.get(Calendar.MONTH) - arriveCalendar.get(Calendar.MONTH);
|
|
|
+ // 当前与入住时相距月份
|
|
|
+ int monthDiffer = year * 12 + month;
|
|
|
+ Calendar dueOutCalendar = Calendar.getInstance();
|
|
|
+ dueOutCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
+ int allYear = dueOutCalendar.get(Calendar.YEAR) - arriveCalendar.get(Calendar.YEAR);
|
|
|
+ int allMonth = dueOutCalendar.get(Calendar.MONTH) - arriveCalendar.get(Calendar.MONTH);
|
|
|
+ // 总入住月份
|
|
|
+ int allMonthDiffer = allYear * 12 + allMonth;
|
|
|
+ if (monthDiffer >= allMonthDiffer){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 下一次收费月份
|
|
|
+ arriveCalendar.set(Calendar.YEAR, nowCalendar.get(Calendar.YEAR));
|
|
|
+ arriveCalendar.set(Calendar.MONTH, nowCalendar.get(Calendar.MONTH));
|
|
|
+ Integer nextMonthNum = allMonthDiffer - monthDiffer < cycle ? allMonthDiffer - monthDiffer : cycle;
|
|
|
+ arriveCalendar.add(Calendar.MONTH, nextMonthNum);
|
|
|
+ list.forEach(e -> {
|
|
|
+ BusOrderFee dayOrderFee = new BusOrderFee();
|
|
|
+ dayOrderFee.setDayTime(new Date());
|
|
|
+ dayOrderFee.setCreateTime(new Date());
|
|
|
+ dayOrderFee.setRemark(e.getName());
|
|
|
+ String roomName = room.getPrefix() != null? room.getPrefix():"";
|
|
|
+ roomName += roomName + room.getName();
|
|
|
+ dayOrderFee.setMoney(e.getMoney());
|
|
|
+ dayOrderFee.setSubjectType(FeeSubjectType.OTHER.getKey());
|
|
|
+ dayOrderFee.setMoney(e.getMoney().multiply(BigDecimal.valueOf(nextMonthNum)));
|
|
|
+ if (e.getIsMust() != null && e.getIsMust()){
|
|
|
+ dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
|
|
|
+ dayOrderFee.setRemark(DateUtil.format(new Date(), "yyyy-MM") + e.getName());
|
|
|
+ }
|
|
|
+ dayOrderFee.setFeeType(1);
|
|
|
+ dayOrderFee.setRoomId(room.getId());
|
|
|
+ dayOrderFee.setLivingOrderId(livingOrder.getId());
|
|
|
+ dayOrderFee.setHotelId(room.getHotelId());
|
|
|
+ orderFees.add(dayOrderFee);
|
|
|
+ });
|
|
|
+ feeService.saveBatch(orderFees);
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(), arriveCalendar.getTimeInMillis());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
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();
|
|
|
@@ -1658,8 +1685,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return;
|
|
|
}
|
|
|
BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
+ // 转为全天房
|
|
|
if (rule.getLimitTimeTransferAllDay() != 0 && overMinutes > rule.getLimitTimeTransferAllDay()){
|
|
|
- // 转为全天房
|
|
|
Date arrivalTime = livingOrder.getArrivalTime();
|
|
|
Calendar arrivalCalendar = Calendar.getInstance();
|
|
|
arrivalCalendar.setTime(arrivalTime);
|
|
|
@@ -1672,8 +1699,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
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)
|
|
|
+ if (arrivalCalendar.get(Calendar.HOUR_OF_DAY) > enterCalendar.get(Calendar.HOUR_OF_DAY)
|
|
|
+ || arrivalCalendar.get(Calendar.HOUR_OF_DAY) == enterCalendar.get(Calendar.HOUR_OF_DAY)
|
|
|
&& arrivalCalendar.get(Calendar.MINUTE) > enterCalendar.get(Calendar.MINUTE)){
|
|
|
// 如果预抵时间在enterTime后面 则预离时间为隔天
|
|
|
leaveCalendar.add(Calendar.DAY_OF_YEAR, 1);
|
|
|
@@ -2362,8 +2389,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return roomLivings;
|
|
|
}
|
|
|
@Override
|
|
|
- public IPage<KeLiItemVo> getLivingOrderKL(Integer status,String keyw,String hotelId,String thirdUserId, Page<KeLiItemVo> page, Date startTime,Date endTime) {
|
|
|
- IPage<KeLiItemVo> pRes = baseMapper.getKeLiLiving(page,thirdUserId,hotelId,keyw,status,startTime,endTime);
|
|
|
+ public IPage<KeLiItemVo> getLivingOrderKL(Integer status,String keyw,String hotelId,String thirdUserId,String layoutId,String customerType, Page<KeLiItemVo> page, Date startTime,Date endTime) {
|
|
|
+ IPage<KeLiItemVo> pRes = baseMapper.getKeLiLiving(page,thirdUserId,hotelId,keyw,status, layoutId,customerType, startTime,endTime);
|
|
|
List<String> livingIds = pRes.getRecords().stream().map(s->s.getId()).collect(Collectors.toList());
|
|
|
List<BusLivingLayoutDayPrice> prices = livingIds.size() >0? livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
|
|
|
.in("living_order_id",livingIds).orderByAsc("day_time")) : new ArrayList<>();
|
|
|
@@ -2471,7 +2498,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
livingCustomer.setId(null);
|
|
|
livingCustomer.setLivingOrderId(null);
|
|
|
customers.add(livingCustomer);
|
|
|
- String livingOrderId = bookingToLive(bookingRooms.getId(), customers,hotelId,null,null, null,null);
|
|
|
+ String livingOrderId = bookingToLive(bookingRooms.getId(), customers,hotelId,null, null,null);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
@@ -3271,7 +3298,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
if(customers == null || customers.isEmpty()) throw new JeecgBootException("请添加客户信息");
|
|
|
|
|
|
// 保存入住单,修改房间状态
|
|
|
- String livingOrderId = bookingToLive(bkRoom.getId(), customers,hotelId,null, bkRoomItem.getRoomOrderInfo(),bkRoomItem.getLongRentScheme(), livingData.getLivingRoomDayPrices());
|
|
|
+ String livingOrderId = bookingToLive(bkRoom.getId(), customers,hotelId,null, bkRoomItem, livingData.getLivingRoomDayPrices());
|
|
|
// 将预约时交的押金,放到主房
|
|
|
if (bkRoom.getIsMain()){
|
|
|
LambdaUpdateWrapper<BusOrderFee> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
@@ -3774,5 +3801,31 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void overTimerBooking(String hotelId) {
|
|
|
+ Set<Object> set = redisTemplate.opsForZSet().rangeByScore("sys:cache:order:overTimerBooking", 0, Calendar.getInstance().getTimeInMillis());
|
|
|
+ if (CollUtil.isEmpty(set)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<BusRoomBookingOrders> bookingOrders = list(Wrappers.<BusRoomBookingOrders>lambdaQuery().in(BusRoomBookingOrders::getId, set)
|
|
|
+ .eq(BusRoomBookingOrders::getBookingStatus, BookingStatusTypeEnum.NORMAL.getKey()).eq(BusRoomBookingOrders::getHotelId, hotelId));
|
|
|
+ List<String> bookingIds = bookingOrders.stream().map(BusRoomBookingOrders::getId).collect(Collectors.toList());
|
|
|
+ if (bookingIds.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<BusBookingRooms> bookingRoomsList = bookingRoomsService.list(Wrappers.<BusBookingRooms>lambdaQuery().in(BusBookingRooms::getBookingOrdersId, bookingIds));
|
|
|
+ Set<String> roomIds = bookingRoomsList.stream().map(BusBookingRooms::getRoomId).collect(Collectors.toSet());
|
|
|
+ if (!roomIds.isEmpty()){
|
|
|
+ List<CesRooms> cesRoomList = roomsService.list(Wrappers.<CesRooms>lambdaQuery().in(CesRooms::getId, roomIds).eq(CesRooms::getRoomStatus, RoomStatusEnum.RESERVE.getKey()));
|
|
|
+ cesRoomList.forEach(e -> e.setRoomStatus(e.getLastRoomStatus()));
|
|
|
+ roomsService.updateBatchById(cesRoomList);
|
|
|
+ }
|
|
|
+ bookingOrders.forEach(e -> {
|
|
|
+ e.setBookingStatus(BookingStatusTypeEnum.INVALID.getKey());
|
|
|
+ redisTemplate.opsForZSet().remove("sys:cache:order:overTimerBooking", e.getId());
|
|
|
+ });
|
|
|
+ updateBatchById(bookingOrders);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|