Skip to content

Commit

Permalink
Refactor: 펀딩 reward 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
gunGeongun committed Dec 1, 2024
1 parent fa47e43 commit ce3e72f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void participateInPost(Long memberId, Long postId) {
Funding funding = Funding.builder()
.post(post)
.participant(member)
.amount(post.getReward()) //Post의 보상금만큼 펀딩
.amount(post.getBaseReward()) //Post의 보상금만큼 펀딩
.status(ParticipationStatus.IN_PROGRESS)
.build();

Expand All @@ -46,7 +46,7 @@ public void participateInPost(Long memberId, Long postId) {
fundingWriterService.save(funding);

//TODO 펀딩 후 유저 포인트 감소 로직
member.decreasePoint(post.getReward());
member.decreasePoint(funding.getAmount());

}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/soft/campushelper/post/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class Post extends BaseTimeEntity {
@Enumerated(EnumType.STRING)
private ProcessStatus processStatus = ProcessStatus.NOT_STARTED;

private int baseReward;

@Column(nullable = false)
@Builder.Default
private int reward = 0;
Expand Down Expand Up @@ -126,4 +128,8 @@ public void removeParticipant(int fundingAmount) {
this.reward -= fundingAmount;
}

public void initBaseReward(){
this.baseReward = this.reward;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public void addPost(Long memberId, PostRequest.Add request) {

fundingWriterService.save(funding);

post.initBaseReward(); // baseReward 설정

//TODO 유저 포인트 감소 로직
member.decreasePoint(request.reward());
}
Expand Down

0 comments on commit ce3e72f

Please sign in to comment.