Skip to content

Commit

Permalink
Merge pull request #179 from 9oormthon-univ/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
HyunWoo9930 authored Nov 28, 2024
2 parents 0638733 + 567e3a8 commit 86dbea0
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.jangburich.domain.store.service;

<<<<<<< Updated upstream
import java.time.LocalDate;
=======
>>>>>>> Stashed changes
import java.util.Optional;

import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -47,6 +50,7 @@ public Message prepay(String userId, PrepayRequest prepayRequest) {
Store store = storeRepository.findById(prepayRequest.storeId())
.orElseThrow(() -> new IllegalArgumentException("μœ νš¨ν•˜μ§€ μ•Šμ€ κ°€κ²Œ id μž…λ‹ˆλ‹€."));

<<<<<<< Updated upstream
team.validateIsTeamLeader(team.getTeamLeader().getUser_id(), user.getUserId());

user.validateHasPointWithPrepayAmount(prepayRequest.prepayAmount(), user.getPoint());
Expand Down Expand Up @@ -92,8 +96,52 @@ public Message prepay(String userId, PrepayRequest prepayRequest) {
}

StoreTeam storeTeam = storeAndTeam.get();
storeTeam.setPersonalAllocatedPoint(prepayRequest.personalAllocatedAmount());
storeTeam.recharge(prepayRequest.prepayAmount());

=======
if (!team.getTeamLeader().getUser_id().equals(user.getUserId())) {
return Message.builder()
.message("νŒ€μ˜ 리더가 μ•„λ‹Œ μ‚¬λžŒμ€ μ„ κ²°μ œλ₯Ό ν•  수 μ—†μŠ΅λ‹ˆλ‹€.")
.build();
}

if (prepayRequest.prepayAmount() > user.getPoint()) {
return Message.builder()
.message("λ³΄μœ ν•˜κ³  μžˆλŠ” κΈˆμ•‘μ΄ μ„ κ²°μ œ ν•˜λ €λŠ” κΈˆμ•‘λ³΄λ‹€ μ μŠ΅λ‹ˆλ‹€.")
.build();
}

user.usePoint(prepayRequest.prepayAmount());
PointTransaction pointTransaction = PointTransaction
.builder()
.transactionType(TransactionType.PREPAY)
.transactionedPoint(prepayRequest.prepayAmount())
.user(user)
.store(store)
.build();

pointTransactionRepository.save(pointTransaction);

StoreTeam buildedStoreTeam = StoreTeam
.builder()
.team(team)
.store(store)
.point(prepayRequest.prepayAmount())
.personalAllocatedPoint(prepayRequest.personalAllocatedAmount())
.remainPoint(prepayRequest.prepayAmount())
.build();

Optional<StoreTeam> storeAndTeam = storeTeamRepository.findByStoreAndTeam(store, team);

if (storeAndTeam.isEmpty()) {
storeAndTeam = Optional.of(storeTeamRepository.save(buildedStoreTeam));
}

StoreTeam storeTeam = storeAndTeam.get();
storeTeam.recharge(prepayRequest.prepayAmount());

>>>>>>> Stashed changes
return Message.builder()
.message("맀μž₯ μ„ κ²°μ œκ°€ μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€.")
.build();
Expand All @@ -104,6 +152,12 @@ public PrepaymentInfoResponse getPrepayInfo(String userId, Long storeId, Long te
User user = userRepository.findByProviderId(userId)
.orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));

<<<<<<< Updated upstream
=======
Team team = teamRepository.findById(teamId)
.orElseThrow(() -> new IllegalArgumentException("μœ νš¨ν•˜μ§€ μ•Šμ€ νŒ€ id μž…λ‹ˆλ‹€."));

>>>>>>> Stashed changes
StoreTeam storeTeam = storeTeamRepository.findByStoreIdAndTeamId(storeId, teamId)
.orElse(null);

Expand Down

0 comments on commit 86dbea0

Please sign in to comment.