|
|
@@ -1046,15 +1046,35 @@ public class ContractService {
|
|
|
@Scheduled(cron = "0 0 4 * * ?")
|
|
|
public void checkContractRoom() {
|
|
|
List<ContractBill> contractBills = contractBillRepo.findByRestLessThan(BigDecimal.ZERO);
|
|
|
+ List<RoomInfo> saveRecords = new ArrayList<>();
|
|
|
contractBills.forEach(contractBill -> {
|
|
|
Set<Long> roomIds = checkinInfoRepo.findAllRoomIdByOrderId(contractBill.getContractId());
|
|
|
List<RoomInfo> roomInfos = roomInfoRepo.findAllById(roomIds);
|
|
|
- List<RoomInfo> saveRecords = new ArrayList<>();
|
|
|
roomInfos.forEach(roomInfo -> {
|
|
|
roomInfo.setPaymentStatus(true);
|
|
|
saveRecords.add(roomInfo);
|
|
|
});
|
|
|
- roomInfoRepo.saveAll(saveRecords);
|
|
|
});
|
|
|
+ Set<Long> ids = saveRecords.stream().map(RoomInfo::getId).collect(Collectors.toSet());
|
|
|
+ List<RoomInfo> noArrears = roomInfoRepo.findAllByIdNotInAndPaymentStatus(ids, true);
|
|
|
+ noArrears.forEach(roomInfo -> {
|
|
|
+ roomInfo.setPaymentStatus(false);
|
|
|
+ saveRecords.add(roomInfo);
|
|
|
+ });
|
|
|
+ roomInfoRepo.saveAll(saveRecords);
|
|
|
+ }
|
|
|
+
|
|
|
+ // @Scheduled(cron = "0 0 4 * * ?")
|
|
|
+ public void checkRoom(Long cusId) {
|
|
|
+ List<Contract> contracts = contractRepo.findAllByCustomerId(cusId);
|
|
|
+ Set<Long> ids = contracts.stream().map(Contract::getId).collect(Collectors.toSet());
|
|
|
+ Set<Long> roomIds = checkinInfoRepo.findAllRoomIdByOrderIdIn(ids);
|
|
|
+ List<RoomInfo> roomInfos = roomInfoRepo.findAllByIdIn(roomIds);
|
|
|
+ List<RoomInfo> news = new ArrayList<>();
|
|
|
+ roomInfos.forEach(roomInfo -> {
|
|
|
+ roomInfo.setPaymentStatus(false);
|
|
|
+ news.add(roomInfo);
|
|
|
+ });
|
|
|
+ roomInfoRepo.saveAll(news);
|
|
|
}
|
|
|
}
|