Skip to content

Commit 5bfcb2f

Browse files
committed
FIX: update focus logic
1 parent 906b1de commit 5bfcb2f

7 files changed

Lines changed: 13 additions & 37 deletions

File tree

src/main/java/com/studioedge/focus_to_levelup_server/domain/attendance/service/AttendanceService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ private int calculateReward(int dayOfCycle, Member member) {
131131
int reward = cycleReward.getReward();
132132

133133
// VIP 2배 적용
134-
if (isVipMember(member)) {
135-
reward *= 2;
134+
if (isVipMember(member) && cycleReward.equals(AttendanceCycleReward.DAY_7)) {
135+
reward += 200;
136136
}
137137
return reward;
138138
}

src/main/java/com/studioedge/focus_to_levelup_server/domain/focus/dao/DailyGoalRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface MonthlyFocusStat {
1616
Integer getTotalSeconds();
1717
}
1818

19+
Optional<DailyGoal> findFirstByMemberIdOrderByDailyGoalDateDesc(Long memberId);
20+
1921
/**
2022
* 특정 유저의 특정 날짜 DailyGoal 조회
2123
*/

src/main/java/com/studioedge/focus_to_levelup_server/domain/focus/dto/request/CreateDailyGoalRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static DailyGoal from(Member member, CreateDailyGoalRequest request,
1919
return DailyGoal.builder()
2020
.member(member)
2121
.targetMinutes(request.targetMinutes())
22-
.serviceDate(serviceDate)
22+
.dailyGoalDate(serviceDate)
2323
.build();
2424
}
2525
}

src/main/java/com/studioedge/focus_to_levelup_server/domain/focus/dto/request/SaveFocusRequestV2.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public record SaveFocusRequestV2 (
1919
Integer maxConsecutiveSeconds,
2020
@NotNull(message = "집중 시작 시각은 필수입니다.")
2121
@Schema(description = "집중 시작 시각 (ISO 8601, UTC 또는 로컬 시간)", example = "2025-11-19T14:30:00")
22-
LocalDateTime startTime,
22+
LocalDateTime startTime, // x
2323
@NotNull(message = "일일 목표 pk는 필수입니다..")
2424
@Schema(description = "일일 목표 pk", example = "3")
25-
Long dailyGoalId
26-
){
25+
Long dailyGoalId // x
26+
) {
2727
}

src/main/java/com/studioedge/focus_to_levelup_server/domain/focus/dto/response/GetDailyGoalResponse.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,6 @@ public record GetDailyGoalResponse (
2121
@Schema(description = "일일 목표 수령 여부", example = "false")
2222
Boolean isReceived
2323
) {
24-
// public static GetDailyGoalResponse of(DailyGoal dailyGoal) {
25-
// float rewardMultiplier = dailyGoal.getRewardMultiplier();
26-
// int currentMinutes = dailyGoal.getCurrentSeconds() / 60;
27-
//
28-
// if (currentMinutes < dailyGoal.getTargetMinutes()) {
29-
// float exponent = (float) ((currentMinutes / 60.0) - 2.0);
30-
// rewardMultiplier = (float) Math.pow(1.1, Math.max(0.0, exponent));
31-
// // 소수점 2째자리까지
32-
// rewardMultiplier = (float) (Math.round(rewardMultiplier * 100) / 100.0);
33-
// }
34-
//
35-
// int bonusExp = (int) (currentMinutes * rewardMultiplier);
36-
//
37-
// return GetDailyGoalResponse.builder()
38-
// .dailyGoalId(dailyGoal.getId())
39-
// .currentSeconds(dailyGoal.getCurrentSeconds())
40-
// .targetMinutes(dailyGoal.getTargetMinutes())
41-
// .rewardMultiplier(rewardMultiplier)
42-
// .bonusExp(bonusExp)
43-
// .levelUp(bonusExp / 600)
44-
// .build();
45-
// }
46-
4724
public static GetDailyGoalResponse of(DailyGoal dailyGoal) {
4825
int currentMinutes = dailyGoal.getCurrentSeconds() / 60;
4926
int targetMinutes = dailyGoal.getTargetMinutes();

src/main/java/com/studioedge/focus_to_levelup_server/domain/focus/entity/DailyGoal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ public class DailyGoal extends BaseEntity {
7171
private LocalTime latestEndTime; // 가장 늦은 종료 시간(아이템 확인용)
7272

7373
@Builder
74-
public DailyGoal(Member member, Integer targetMinutes, LocalDate serviceDate) {
74+
public DailyGoal(Member member, Integer targetMinutes, LocalDate dailyGoalDate) {
7575
this.member = member;
7676
this.targetMinutes = targetMinutes;
77-
this.dailyGoalDate = serviceDate;
77+
this.dailyGoalDate = dailyGoalDate;
7878

7979
float exponent = (float) ((targetMinutes / 60.0) - 2.0);
8080
float rewardMultiplier = (float) Math.pow(1.1, Math.max(0.0, exponent));

src/main/java/com/studioedge/focus_to_levelup_server/domain/focus/service/FocusServiceV2.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
import java.time.LocalTime;
3939
import java.util.List;
4040

41-
import static com.studioedge.focus_to_levelup_server.global.common.AppConstants.getServiceDate;
42-
4341
@Service
4442
@RequiredArgsConstructor
4543
public class FocusServiceV2 {
@@ -87,16 +85,15 @@ public void saveFocus(Member m, Long subjectId, SaveFocusRequestV2 request) {
8785

8886
int focusMinutes = savedFocusSeconds / 60;
8987
int remainSeconds = savedFocusSeconds % 60;
90-
LocalDate serviceDate = getServiceDate(startTime);
9188

9289
Member member = memberRepository.findById(m.getId())
9390
.orElseThrow(MemberNotFoundException::new);
9491
MemberInfo memberInfo = memberInfoRepository.findByMemberId(m.getId())
9592
.orElseThrow(InvalidMemberException::new);
96-
97-
DailyGoal dailyGoal = dailyGoalRepository.findByMemberIdAndDailyGoalDate(member.getId(), serviceDate)
93+
DailyGoal dailyGoal = dailyGoalRepository.findFirstByMemberIdOrderByDailyGoalDateDesc(member.getId())
9894
.orElseThrow(DailyGoalNotFoundException::new);
99-
Subject subject = this.subjectRepository.findByIdAndDeleteAtIsNull(subjectId)
95+
LocalDate serviceDate = dailyGoal.getDailyGoalDate();
96+
Subject subject = subjectRepository.findByIdAndDeleteAtIsNull(subjectId)
10097
.orElseThrow(SubjectNotFoundException::new);
10198
MemberCharacter memberCharacter = memberCharacterRepository.findByMemberIdAndIsDefault(m.getId(), true)
10299
.orElseThrow(CharacterDefaultNotFoundException::new);

0 commit comments

Comments
 (0)