Skip to content

Commit

Permalink
Fix/invalid member (#114)
Browse files Browse the repository at this point in the history
* Fix: AuctionService nickname 검사없이 NULL가져오던거 수정

* Fix: AuctionService nickname 검사없이 NULL가져오던거 수정
  • Loading branch information
klkim1913 authored Aug 15, 2023
1 parent 1f68eb5 commit 7d0004a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.NoHandlerFoundException;

import javax.validation.ConstraintViolationException;

import java.sql.SQLIntegrityConstraintViolationException;

import static com.anywayclear.exception.ExceptionCode.*;
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/com/anywayclear/service/AuctionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,22 @@ public BiddingResponse Bidding(long auctionId, String consumerId, BiddingRequest
@Transactional
public void checkAuctionFinished(long auctionId) {
Auction auction = auctionRepository.findById(auctionId).orElseThrow(() -> new CustomException(INVALID_AUCTION_ID));
Member consumer = memberRepository.findByNickname(auction.getNickname()).orElseThrow(()->new CustomException(INVALID_MEMBER));
Produce produce = auction.getProduce();
if (produce.getStatus() == 1 && !auction.isClosed() && LocalDateTime.now().isAfter(auction.getLastBidding().plusMinutes(4))) {
auction.setClosed(true);
produce.setEndDate(auction.getUpdatedAt());
// produce.setEa(produce.getEa() - 1);
DealCreateRequest dealCreateRequest = DealCreateRequest.builder()
.endPrice(auction.getPrice())
.produce(produce)
.seller(produce.getSeller())
.consumer(consumer)
.build();
dealService.createDeal(dealCreateRequest);
produce.setStatus(2);
if(!produce.getStartDate().equals(auction.getLastBidding())) {
Member consumer = memberRepository.findByNickname(auction.getNickname()).orElseThrow(() -> new CustomException(INVALID_MEMBER));
DealCreateRequest dealCreateRequest = DealCreateRequest.builder()
.endPrice(auction.getPrice())
.produce(produce)
.seller(produce.getSeller())
.consumer(consumer)
.build();
dealService.createDeal(dealCreateRequest);
}
produce.setStatus(2);
for (Auction a : produce.getAuctionList()) {
if (!a.isClosed()) {
produce.setStatus(1);
Expand Down

0 comments on commit 7d0004a

Please sign in to comment.