|
|
@@ -80,7 +80,8 @@ public class AuctionOrderService {
|
|
|
}
|
|
|
|
|
|
@RedisLock("'createAuctionOrder::'+#auctionId")
|
|
|
- public AuctionOrder create(Long userId, Long auctionId, Long addressId, Long auctionRecordId, AuctionPaymentType type) {
|
|
|
+ public AuctionOrder create(Long userId, Long auctionId, Long addressId, Long auctionRecordId,
|
|
|
+ AuctionPaymentType type, BigDecimal amount) {
|
|
|
User user = userRepo.findById(userId).orElseThrow(new BusinessException("无用户"));
|
|
|
|
|
|
AuctionActivity auction = auctionActivityRepo.findById(auctionId)
|
|
|
@@ -142,7 +143,7 @@ public class AuctionOrderService {
|
|
|
throw new BusinessException("拍卖已结束");
|
|
|
}
|
|
|
if (AuctionPaymentType.DEPOSIT.equals(type)) {
|
|
|
- return this.createDeposit(user, auction);
|
|
|
+ return this.createDeposit(user, auction, amount);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -193,7 +194,7 @@ public class AuctionOrderService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public AuctionOrder createDeposit(User user, AuctionActivity auction) {
|
|
|
+ public AuctionOrder createDeposit(User user, AuctionActivity auction, BigDecimal amount) {
|
|
|
if (user.getId().equals(auction.getSellerId())) {
|
|
|
throw new BusinessException("不可自己出价自己的");
|
|
|
}
|
|
|
@@ -224,8 +225,8 @@ public class AuctionOrderService {
|
|
|
|
|
|
AuctionRecord auctionRecord = AuctionRecord.builder()
|
|
|
.auctionId(auction.getId())
|
|
|
- .type(AuctionRecordType.DEPOSIT)
|
|
|
- .bidderPrice(auction.getDeposit())
|
|
|
+ .type(AuctionRecordType.BIDDER)
|
|
|
+ .bidderPrice(amount)
|
|
|
.auctionPic(null)
|
|
|
.userId(SecurityUtils.getAuthenticatedUser().getId())
|
|
|
.avatar(SecurityUtils.getAuthenticatedUser().getAvatar())
|
|
|
@@ -283,6 +284,14 @@ public class AuctionOrderService {
|
|
|
.orElseThrow(new BusinessException("无出价记录"));
|
|
|
record.setPayDeposit(true);
|
|
|
auctionRecordRepo.save(record);
|
|
|
+ if (auction.getPurchasePrice().compareTo(record.getBidderPrice()) <= 0) {
|
|
|
+ auction.setPurchasePrice(record.getBidderPrice());
|
|
|
+ auction.setPurchaser(record.getUser());
|
|
|
+ auction.setPurchaserId(record.getUserId());
|
|
|
+ auction.setRecordId(record.getId());
|
|
|
+ auction.setBids(auction.getBids() + 1);
|
|
|
+ auctionActivityRepo.save(auction);
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
|