diff --git a/db/init.sql b/db/init.sql index 632c0ec..18767ab 100644 --- a/db/init.sql +++ b/db/init.sql @@ -96,7 +96,9 @@ CREATE TABLE [dbo].[user] 'https://scontent.fsgn2-7.fna.fbcdn.net/v/t39.30808-6/438275285_1101091104487039_4035794765477072253_n.jpg?_nc_cat=108&ccb=1-7&_nc_sid=5f2048&_nc_ohc=7MHTOamLKXgQ7kNvgGdad4i&_nc_ht=scontent.fsgn2-7.fna&oh=00_AYDZ0L0Y3_1M_tK5YBX-b1PhjuTPFeLod8Jz1UhW3t_Gkg&oe=6665416E', N'Lâm Đồng', 'phuuthanh2003@gmail.com', N'Phùng', N'Thành', '$2a$12$j/1n5Pjv4JgzG76ZG0hyH.MD6ftohJNbjuZjRHQFt31Ta/jViwKQ2', '0912345670', N'Hà Nội', N'Hoang', 'ACTIVE', - 'phuuthanh2003', 1985, 'ADMIN', 7, '1030293193991', 'PHUNG HUU THANH', '2024-05-01 17:30:00', '01', '123456', 'CA NINH', ''); + 'phuuthanh2003', 1985, 'ADMIN', 7, '1030293193991', 'PHUNG HUU THANH', '2024-05-01 17:30:00', 'https://firebasestorage.googleapis.com/v0/b/auction-image-aecbe.appspot.com/o/images-cccd%2F49a92919-a92a-4d32-9f70-db2f641ccb51?alt=media&token=f50f52dc-8954-4a18-845e-16e855b076bb' + , 'https://firebasestorage.googleapis.com/v0/b/auction-image-aecbe.appspot.com/o/images-cccd%2F79f370d3-d4ea-4690-903e-88a99ade8d38?alt=media&token=b728a278-36fd-4e96-bd64-f34a8b03e5a1', + 'CA MAU', ''); CREATE TABLE [dbo].[jewelry] diff --git a/src/main/java/vn/webapp/backend/auction/dto/BidResponse.java b/src/main/java/vn/webapp/backend/auction/dto/BidResponse.java index 390fb29..84fb254 100644 --- a/src/main/java/vn/webapp/backend/auction/dto/BidResponse.java +++ b/src/main/java/vn/webapp/backend/auction/dto/BidResponse.java @@ -4,6 +4,7 @@ public record BidResponse ( Double lastPrice, + Double buyNowPrice, Integer auctionId, Timestamp endDate, Long bonusTime, diff --git a/src/main/java/vn/webapp/backend/auction/service/bid/AuctionHistoryServiceImpl.java b/src/main/java/vn/webapp/backend/auction/service/bid/AuctionHistoryServiceImpl.java index 7077459..f3124bb 100644 --- a/src/main/java/vn/webapp/backend/auction/service/bid/AuctionHistoryServiceImpl.java +++ b/src/main/java/vn/webapp/backend/auction/service/bid/AuctionHistoryServiceImpl.java @@ -17,6 +17,8 @@ import vn.webapp.backend.auction.repository.UserRepository; import java.security.SecureRandom; +import java.sql.Timestamp; +import java.time.Instant; import java.util.List; @Service @@ -89,10 +91,19 @@ public void saveBidByUserAndAuction(BidRequest request) { if (auction.getLastPrice() == null || request.priceGiven().compareTo(auction.getLastPrice()) > 0) { auction.setLastPrice(request.priceGiven()); - auctionRepository.save(auction); } else { throw new IllegalArgumentException("Giá đấu không hợp lệ."); } + + var currentTime = Timestamp.from(Instant.now()); + var endDate = auction.getEndDate(); + long minutesDifference = (endDate.getTime() - currentTime.getTime()) / (1000 * 60); + + // Thoi gian con be hon 15p + if (auction.getLastPrice() >= auction.getJewelry().getBuyNowPrice() && minutesDifference > 15) { + auction.setEndDate(new Timestamp(currentTime.getTime() + 15 * 60 * 1000)); + } + auctionRepository.save(auction); } @Override diff --git a/src/main/java/vn/webapp/backend/auction/service/realtime/RealTimeService.java b/src/main/java/vn/webapp/backend/auction/service/realtime/RealTimeService.java index bb96e52..6a02fb5 100644 --- a/src/main/java/vn/webapp/backend/auction/service/realtime/RealTimeService.java +++ b/src/main/java/vn/webapp/backend/auction/service/realtime/RealTimeService.java @@ -34,7 +34,7 @@ public BidResponse getLastPriceTogether(Integer id, Long bonusTime, String usern auction.setEndDate(newEndDate); auctionRepository.save(auction); - return new BidResponse(auction.getLastPrice(), auction.getId(), auction.getEndDate(), bonusTime, user.getUsername()); + return new BidResponse(auction.getLastPrice(), auction.getJewelry().getBuyNowPrice(), auction.getId(), auction.getEndDate(), bonusTime, user.getUsername()); } public KickOutResponse staffKickOutMember(Integer id, String username) { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 74e34a7..91042db 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -34,7 +34,9 @@ payment.vnPay.orderType=other # Config security application.security.jwt.secret-key=jAkq3Mbc9Tz7X4D5Y6L8Q5C9wK8z2Gf9A6PqS5R8tV3v2O5wF8rM7U6pR4yN3T9q # Access token expiration time (15 minutes) -application.security.jwt.expiration=900000 +#application.security.jwt.expiration=900000 +application.security.jwt.expiration=3600000 # Refresh token expiration time (1 hour) -application.security.jwt.refresh-token.expiration=3600000 +#application.security.jwt.refresh-token.expiration=3600000 +application.security.jwt.refresh-token.expiration=86400000