wangqifan il y a 3 ans
Parent
commit
5f9314f24b

+ 2 - 0
src/main/java/com/izouma/zhumj/domain/RoomInfo.java

@@ -142,4 +142,6 @@ public class RoomInfo extends BaseEntity implements Serializable {
     private String deleteReason;
 
     private String cardData;
+
+    private boolean paymentStatus = false;
 }

+ 3 - 0
src/main/java/com/izouma/zhumj/repo/CheckinInfoRepo.java

@@ -98,6 +98,9 @@ public interface CheckinInfoRepo extends JpaRepository<CheckinInfo, Long>, JpaSp
     @Query("SELECT s.roomId FROM CheckinInfo s WHERE s.checkout = false  and s.storeId = ?1  and (s.name like CONCAT(?2,'%') or s.phone like CONCAT(?2,'%') or s.teamName like CONCAT(?2,'%'))")
     Set<Long> findAllRoomIdByStoreIdAndSearchKey(Long storeId, String searchKey);
 
+    @Query("SELECT s.roomId FROM CheckinInfo s WHERE s.checkout = false  and s.orderId = ?2 ")
+    Set<Long> findAllRoomIdByOrderId(Long orderId);
+
     Long countAllByStoreId(Long storeId);
 
     List<CheckinInfo> findByStoreIdAndCheckinTimeBetweenOrderByCheckinTime(Long storeId, LocalDateTime start, LocalDateTime end);

+ 2 - 0
src/main/java/com/izouma/zhumj/repo/sale/ContractBillRepo.java

@@ -75,4 +75,6 @@ public interface ContractBillRepo extends JpaRepository<ContractBill, Long>, Jpa
 
     List<ContractBill> findByStartTimeBeforeAndEndTimeAfterAndCustomerIdAndStatusNot(LocalDateTime start, LocalDateTime endTime, Long customerId, BillStatus billStatus);
 
+    List<ContractBill> findByRestLessThan(BigDecimal money);
+
 }

+ 11 - 0
src/main/java/com/izouma/zhumj/service/CustomerAccountService.java

@@ -60,6 +60,7 @@ public class CustomerAccountService {
     private final CheckinInfoRepo           checkinInfoRepo;
     private final ContractViolationRepo     contractViolationRepo;
     private final RoomTypeInfoRepo          roomTypeInfoRepo;
+    private final RoomInfoRepo              roomInfoRepo;
 
 
     public Page<CustomerAccountDTO> all(String name, PageQuery pageQuery, LocalDateTime start, LocalDateTime end, Long storeId) {
@@ -415,6 +416,16 @@ public class CustomerAccountService {
                 contractBill.setStatus(BillStatus.CONFIRMED);
                 contractBill.setConfirmTime(LocalDateTime.now());
             }
+            if (compare2 >= 0) {
+                Set<Long> roomIds = checkinInfoRepo.findAllRoomIdByOrderId(contractBill.getContractId());
+                List<RoomInfo> roomInfos = roomInfoRepo.findAllById(roomIds);
+                List<RoomInfo> saveRecords = new ArrayList<>();
+                roomInfos.forEach(roomInfo -> {
+                    roomInfo.setPaymentStatus(false);
+                    saveRecords.add(roomInfo);
+                });
+                roomInfoRepo.saveAll(saveRecords);
+            }
         }
         contractBill.setRecharged(contractBill.getRecharged().add(money));
         contractBill.setRest(rest);

+ 16 - 0
src/main/java/com/izouma/zhumj/service/sale/ContractService.java

@@ -80,6 +80,7 @@ public class ContractService {
     private final PersonalFeeTypeRepo         personalFeeTypeRepo;
     private final ContractEntryAccountRepo    contractEntryAccountRepo;
     private final BookInfoRepo                bookInfoRepo;
+    private final RoomInfoRepo                roomInfoRepo;
 
     public static List<ContractBill> calcBills(Contract contract) {
         fixContractProperties(contract);
@@ -1041,4 +1042,19 @@ public class ContractService {
         contract.setStatus(ContractStatus.STAY_IN);
         contractRepo.save(contract);
     }
+
+    @Scheduled(cron = "0 0 4 * * ?")
+    public void checkContractRoom() {
+        List<ContractBill> contractBills = contractBillRepo.findByRestLessThan(BigDecimal.ZERO);
+        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);
+        });
+    }
 }

+ 3 - 0
src/main/vue/src/views/Operation/RoomStatus.vue

@@ -844,6 +844,9 @@ export default {
                         } else if (i.checkInStatus != 'FREE') {
                             i.statusLabel = '在住';
                             i.statusStyle = 'normal';
+                        } else if (i.paymentStatus == true) {
+                            i.statusLabel = '欠费';
+                            i.statusStyle = 'danger';
                         } else {
                             i.statusLabel = '空净';
                             i.statusStyle = 'success';