Skip to content

Commit

Permalink
fix request count.
Browse files Browse the repository at this point in the history
  • Loading branch information
2k4sm committed Apr 5, 2024
1 parent ebcb81f commit 509e426
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/zolobooky/booky/appeals/AppealService.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public AppealEntity updateAppealStatus(Integer trans_id, UpdateAppealDTO appealD
bookService.updateStatus(book.getId(), CustomStatus.BookStatus.AVAILABLE);

if (appealDTO.getTrans_status() == CustomStatus.TransactionStatus.COMPLETED) {
book.setRequestCount(book.getRequestCount() - 1);
this.bookRepository.save(book);

log.info(String.format("%s book return completed.", book.getName()));
this.fireService.sendNotification(appeal.getBorrowerId().getFcmToken(),
String.format("%s book recieved.", book.getName()),
Expand All @@ -165,15 +168,16 @@ public AppealEntity updateAppealStatus(Integer trans_id, UpdateAppealDTO appealD
"Thanks for using Zolo-booky.Hope you had a great experience.");
}
else {
book.setRequestCount(book.getRequestCount() - 1);
this.bookRepository.save(book);

log.info(String.format("request for %s book has been rejected.", book.getName()));
this.fireService.sendNotification(appeal.getBorrowerId().getFcmToken(),
String.format("Your request for %s book has been rejected.", book.getName()),
"Sorry for the inconvenience.Hope to see you next time.");
}
}

book.setRequestCount(book.getRequestCount() - 1);
this.bookRepository.save(book);

appeal.setTrans_status(appealDTO.getTrans_status());
appeal.setStatus_change_date(then);
Expand Down

0 comments on commit 509e426

Please sign in to comment.