Skip to content

Commit

Permalink
Merge pull request #138 from phuuthanh-dev/develop
Browse files Browse the repository at this point in the history
buyNowRealtime
  • Loading branch information
phuuthanh-dev authored Jul 16, 2024
2 parents 01d6330 + f029f2a commit 0ed7142
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion db/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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', '[email protected]', 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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public record BidResponse (
Double lastPrice,
Double buyNowPrice,
Integer auctionId,
Timestamp endDate,
Long bonusTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 4 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0ed7142

Please sign in to comment.