Skip to content

Commit a31f8ad

Browse files
committed
feat: 라이브물품 currentPrice 추가, 낙찰 시 최종가 반영
1 parent 2b33085 commit a31f8ad

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

src/main/java/devut/buzzerbidder/domain/liveBid/service/LiveBidService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public LiveBidResponse bid(LiveBidRequest request, User bidder) {
5555
);
5656

5757
// 입찰 시도 결과에 따른 분기 처리
58-
return handleBidResult(result, request, bidder, liveItem.getSellerUserId(), redisKey, depositAmount);
58+
return handleBidResult(result, request, bidder, liveItem, redisKey, depositAmount);
5959
}
6060

6161
/**
@@ -83,7 +83,7 @@ private LiveBidResponse handleBidResult(
8383
BidAtomicResult result,
8484
LiveBidRequest request,
8585
User bidder,
86-
Long sellerId,
86+
LiveItem liveItem,
8787
String redisKey,
8888
long depositAmount
8989
) {
@@ -100,7 +100,7 @@ private LiveBidResponse handleBidResult(
100100
throw new BusinessException(ErrorCode.UNEXPECTED_REDIS_SCRIPT_RETURN);
101101
}
102102

103-
processSuccessfulBid(request, bidder, sellerId);
103+
processSuccessfulBid(request, bidder, liveItem.getSellerUserId());
104104

105105
walletHistoryService.recordWalletHistory(
106106
bidder,

src/main/java/devut/buzzerbidder/domain/liveitem/controller/LiveItemController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import devut.buzzerbidder.domain.liveitem.dto.response.LiveItemDetailResponse;
99
import devut.buzzerbidder.domain.liveitem.dto.response.LiveItemListResponse;
1010
import devut.buzzerbidder.domain.liveitem.dto.response.LiveItemModifyResponse;
11-
import devut.buzzerbidder.domain.liveitem.dto.response.LiveItemResponse;
1211
import devut.buzzerbidder.domain.liveitem.service.LiveItemService;
1312
import devut.buzzerbidder.global.response.ApiResponse;
1413
import devut.buzzerbidder.global.security.CustomUserDetails;

src/main/java/devut/buzzerbidder/domain/liveitem/dto/response/LiveItemDetailResponse.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public record LiveItemDetailResponse(
2121
String preferredPlace,
2222
List<String> images,
2323
Long likeCount,
24+
Long initPrice,
2425
Long currentPrice,
2526
Boolean isLiked
2627
) {

src/main/java/devut/buzzerbidder/domain/liveitem/dto/response/LiveItemResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public record LiveItemResponse(
1010
String image,
1111
LocalDateTime startAt,
1212
AuctionStatus auctionStatus,
13+
Long initPrice,
1314
Long currentPrice,
1415
Boolean isLiked
1516
) {
@@ -21,6 +22,7 @@ public LiveItemResponse(LiveItem liveItem,Boolean isLiked ) {
2122
liveItem.getLiveTime(),
2223
liveItem.getAuctionStatus(),
2324
liveItem.getInitPrice(),
25+
liveItem.getCurrentPrice(),
2426
isLiked
2527
);
2628
}

src/main/java/devut/buzzerbidder/domain/liveitem/entity/LiveItem.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
import java.time.LocalDateTime;
1616
import java.util.ArrayList;
1717
import java.util.List;
18-
import lombok.AllArgsConstructor;
19-
import lombok.Builder;
20-
import lombok.Getter;
21-
import lombok.NoArgsConstructor;
18+
19+
import lombok.*;
2220
import org.hibernate.annotations.BatchSize;
2321

2422
@Getter
@@ -64,6 +62,10 @@ public enum Category {
6462
@Column(name = "init_price", nullable = false)
6563
private Long initPrice;
6664

65+
@Setter
66+
@Column(name = "current_price", nullable = false)
67+
private Long currentPrice;
68+
6769
@Column(name = "delivery_include")
6870
@NotNull(message = "배송비 포함 여부는 필수입니다.")
6971
private Boolean deliveryInclude;
@@ -131,6 +133,7 @@ public LiveItem(LiveItemCreateRequest request, User user) {
131133
this.category = request.category();
132134
this.description = request.description();
133135
this.initPrice = request.initPrice();
136+
this.currentPrice = request.initPrice();
134137
this.deliveryInclude = request.deliveryInclude();
135138
this.itemStatus = request.itemStatus();
136139
this.auctionStatus = AuctionStatus.BEFORE_BIDDING;

src/main/java/devut/buzzerbidder/domain/liveitem/service/LiveItemService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public LiveItemDetailResponse getLiveItem(Long id, Long userId) {
386386
String redisKey = "liveItem:" + liveItem.getId();
387387

388388
String currentMaxPriceStr = liveBidRedisService.getHashField(redisKey, "maxBidPrice");
389-
Long currentMaxPrice = (currentMaxPriceStr != null) ? Integer.parseInt(currentMaxPriceStr) : liveItem.getInitPrice();
389+
Long currentMaxPrice = (currentMaxPriceStr != null) ? Integer.parseInt(currentMaxPriceStr) : liveItem.getCurrentPrice();
390390

391391
return new LiveItemDetailResponse(
392392
liveItem.getId(),
@@ -405,6 +405,7 @@ public LiveItemDetailResponse getLiveItem(Long id, Long userId) {
405405
.map(LiveItemImage::getImageUrl)
406406
.toList(),
407407
likeCount,
408+
liveItem.getInitPrice(),
408409
currentMaxPrice,
409410
isLiked
410411
);
@@ -502,6 +503,7 @@ public LiveItemListResponse getLiveItems(
502503
item.image(),
503504
item.startAt(),
504505
item.auctionStatus(),
506+
item.initPrice(),
505507
currentMaxBidPrice,
506508
isLiked
507509
);
@@ -562,6 +564,7 @@ public LiveItemListResponse getHotLiveItems(
562564
item.image(),
563565
item.startAt(),
564566
item.auctionStatus(),
567+
item.initPrice(),
565568
currentMaxBidPrice,
566569
isLiked
567570
);
@@ -649,6 +652,7 @@ public void endAuction(Long itemId) {
649652
Long maxBidPrice = Long.parseLong(maxBidPriceStr);
650653

651654
liveDealService.createDeal(itemId, currentBidderId, maxBidPrice);
655+
liveItem.setCurrentPrice(maxBidPrice);
652656

653657
Long winnerDeposit = null;
654658
if (currentBidderIdStr != null && !currentBidderIdStr.isBlank()) {

0 commit comments

Comments
 (0)