diff --git a/.gradle/8.4/executionHistory/executionHistory.bin b/.gradle/8.4/executionHistory/executionHistory.bin
index b8cd9a3..6e47f42 100644
Binary files a/.gradle/8.4/executionHistory/executionHistory.bin and b/.gradle/8.4/executionHistory/executionHistory.bin differ
diff --git a/.gradle/8.4/executionHistory/executionHistory.lock b/.gradle/8.4/executionHistory/executionHistory.lock
index cf937e9..d40711f 100644
Binary files a/.gradle/8.4/executionHistory/executionHistory.lock and b/.gradle/8.4/executionHistory/executionHistory.lock differ
diff --git a/.gradle/8.4/fileHashes/fileHashes.bin b/.gradle/8.4/fileHashes/fileHashes.bin
index 7d662a8..9783e5c 100644
Binary files a/.gradle/8.4/fileHashes/fileHashes.bin and b/.gradle/8.4/fileHashes/fileHashes.bin differ
diff --git a/.gradle/8.4/fileHashes/fileHashes.lock b/.gradle/8.4/fileHashes/fileHashes.lock
index 97efdf0..ba41909 100644
Binary files a/.gradle/8.4/fileHashes/fileHashes.lock and b/.gradle/8.4/fileHashes/fileHashes.lock differ
diff --git a/.gradle/8.4/fileHashes/resourceHashesCache.bin b/.gradle/8.4/fileHashes/resourceHashesCache.bin
index 5097f45..7f0770e 100644
Binary files a/.gradle/8.4/fileHashes/resourceHashesCache.bin and b/.gradle/8.4/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 72639da..230fb75 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe
index 51b1e38..09ab3f9 100644
Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ
diff --git a/.idea/dataSources/f08ed712-aeaf-46f7-899a-5e3c9985035a.xml b/.idea/dataSources/f08ed712-aeaf-46f7-899a-5e3c9985035a.xml
index b079efe..8cb5928 100644
--- a/.idea/dataSources/f08ed712-aeaf-46f7-899a-5e3c9985035a.xml
+++ b/.idea/dataSources/f08ed712-aeaf-46f7-899a-5e3c9985035a.xml
@@ -1089,7 +1089,7 @@ sys|schema||mysql.sys|localhost|TRIGGER|G
utf8mb4_0900_ai_ci
- 2025-05-27.15:09:32
+ 2025-05-28.14:43:23
utf8mb4_0900_ai_ci
@@ -1384,7 +1384,7 @@ sys|schema||mysql.sys|localhost|TRIGGER|G
PRIMARY
- 9
+ 1
1
1
bigint|0s
@@ -1404,7 +1404,7 @@ sys|schema||mysql.sys|localhost|TRIGGER|G
5
- enum('DELIVERY_ARRIVED', 'DELIVERY_STARTED', 'ORDER_PLACED', 'PARTICIPATION_APPROVED', 'PARTICIPATION_REJECTED', 'PARTICIPATION_REQUEST', 'PAYMENT_REQUEST', 'POLICY_VIOLATION', 'RECRUITMENT_DONE', 'REVIEW_REQUEST')|0e
+ enum('ADD_TRACKING_NUM', 'DELIVERY_ARRIVED', 'DELIVERY_STARTED', 'ORDER_PLACED', 'PARTICIPATION_APPROVED', 'PARTICIPATION_REJECTED', 'PARTICIPATION_REQUEST', 'PAYMENT_COMPLETED', 'PAYMENT_REQUEST', 'RECRUITMENT_DONE', 'REVIEW_REQUEST')|0e
6
@@ -1650,355 +1650,372 @@ sys|schema||mysql.sys|localhost|TRIGGER|G
17
bigint|0s
-
+
+ 18
+ varchar(255)|0s
+
+
+ 19
+ varchar(255)|0s
+
+
+ 20
+ varchar(255)|0s
+
+
address_id
address_id
address
-
+
pod_id
btree
1
-
+
address_id
btree
-
+
1
1
PRIMARY
-
+
25
1
1
bigint|0s
-
+
2
enum('ACCEPTED', 'PENDING', 'REJECTED')|0e
-
+
3
bigint|0s
-
+
4
datetime(6)|0s
-
+
5
datetime(6)|0s
-
+
6
enum('POD_LEADER', 'POD_MEMBER')|0e
-
+
7
bigint|0s
-
+
8
bigint|0s
-
+
9
int|0s
-
+
+ 1
+ 10
+ enum('DEPOSIT_COMPLETED', 'DEPOSIT_PENDING')|0e
+
+
user_id
user_id
user
-
+
pod_id
pod_id
pod
-
+
order_form_id
order_form_id
orderform
-
+
id
btree
1
-
+
user_id
btree
-
+
pod_id
btree
-
+
order_form_id
btree
-
+
1
1
PRIMARY
-
+
9
1
1
bigint|0s
-
+
2
datetime(6)|0s
-
+
3
datetime(6)|0s
-
+
1
4
bigint|0s
-
+
5
bigint|0s
-
+
6
bigint|0s
-
+
pod_id
pod_id
pod
-
+
recipient_id
user_id
user
-
+
writer_id
user_id
user
-
+
review_id
btree
1
-
+
pod_id
btree
-
+
recipient_id
btree
-
+
writer_id
btree
-
+
1
1
PRIMARY
-
+
6
1
1
bigint|0s
-
+
1
2
enum('BAD', 'EXACT_TRANSACTION', 'KIND', 'ON_TIME', 'QUICK_RESPONSE')|0e
-
+
review_option_id
btree
1
-
+
1
1
PRIMARY
-
+
8
1
1
bigint|0s
-
+
2
bigint|0s
-
+
3
bigint|0s
-
+
review_id
review_id
review
-
+
review_option_id
review_option_id
review_option
-
+
review_mapping_id
btree
1
-
+
review_id
btree
-
+
review_option_id
btree
-
+
1
1
PRIMARY
-
+
1
1
1
bigint|0s
-
+
2
datetime(6)|0s
-
+
3
datetime(6)|0s
-
+
4
datetime(6)|0s
-
+
5
varchar(255)|0s
-
+
1
6
bigint|0s
-
+
user_id
user_id
user
-
+
token_id
btree
1
-
+
user_id
btree
1
-
+
1
1
PRIMARY
-
+
UKg7im3j7f0g31yhl6qco2iboy5
-
+
3
1
1
bigint|0s
-
+
2
datetime(6)|0s
-
+
3
datetime(6)|0s
-
+
4
varchar(255)|0s
-
+
1
5
varchar(255)|0s
-
+
6
double|0s
-
+
1
7
varchar(255)|0s
-
+
1
8
varchar(255)|0s
-
+
9
enum('ADMIN', 'USER')|0e
-
+
10
enum('GOOGLE', 'KAKAO', 'NAVER')|0e
-
+
11
enum('ACTIVE', 'BANNED', 'INACTIVE')|0e
-
+
12
bigint|0s
-
+
address_id
address_id
address
-
+
user_id
btree
1
-
+
email
btree
1
-
+
address_id
btree
-
+
1
1
PRIMARY
-
+
UKob8kqyqqgmefl0aco34akdtpe
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e3329f5..0c7804a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,13 +5,25 @@
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
@@ -65,11 +77,11 @@
@@ -106,38 +118,38 @@
- {
+ "keyToString": {
+ "Gradle.Build PodMate.executor": "Run",
+ "Gradle.C:/Users/pwyic/desktop/PodMate/be [clean].executor": "Run",
+ "Gradle.PodMate:be [build].executor": "Run",
+ "RequestMappingsPanelOrder0": "0",
+ "RequestMappingsPanelOrder1": "1",
+ "RequestMappingsPanelWidth0": "75",
+ "RequestMappingsPanelWidth1": "75",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "Spring Boot.PodMateApplication.executor": "Run",
+ "git-widget-placeholder": "feat/#114-payment-request-notification",
+ "kotlin-language-version-configured": "true",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "project.structure.last.edited": "Modules",
+ "project.structure.proportion": "0.0",
+ "project.structure.side.proportion": "0.0",
+ "settings.editor.selected.configurable": "reference.settingsdialog.project.gradle",
+ "vue.rearranger.settings.migration": "true"
},
- "keyToStringList": {
- "DatabaseDriversLRU": [
- "mysql_aurora",
- "mysql"
+ "keyToStringList": {
+ "DatabaseDriversLRU": [
+ "mysql_aurora",
+ "mysql"
]
}
-}]]>
+}
@@ -248,7 +260,9 @@
-
+
+
+
diff --git a/be/src/main/java/com/podmate/domain/mypage/api/MyPageController.java b/be/src/main/java/com/podmate/domain/mypage/api/MyPageController.java
index c390480..74723ee 100644
--- a/be/src/main/java/com/podmate/domain/mypage/api/MyPageController.java
+++ b/be/src/main/java/com/podmate/domain/mypage/api/MyPageController.java
@@ -5,6 +5,7 @@
import com.podmate.domain.mypage.application.MyPageService;
import com.podmate.domain.mypage.dto.MyPageRequestDto;
import com.podmate.domain.orderForm.dto.OrderFormResponseDto;
+import com.podmate.domain.pod.dto.PodRequestDto;
import com.podmate.domain.pod.dto.PodResponse;
import com.podmate.domain.pod.dto.PodResponseDto;
import com.podmate.domain.review.dto.ReviewResponseDto;
@@ -77,6 +78,19 @@ public BaseResponse addTrackingNumber(@RequestBody MyPageRequestDto.Trac
return BaseResponse.onSuccess(SuccessStatus._OK, "successfully saved tracking number!");
}
+ //입금 계좌 입력
+ @PatchMapping("/inprogress/mypods/{podId}/deposit-account")
+ public BaseResponse addDepositAccount(@RequestBody MyPageRequestDto.DepositAccountRequestDto request, @PathVariable("podId") Long podId, @AuthenticationPrincipal CustomOAuth2User customOAuth2User) {
+ myPageService.addDepositAccount(request, podId, customOAuth2User.getUserId());
+ return BaseResponse.onSuccess(SuccessStatus._OK, "successfully saved deposit account!");
+ }
+ // 입금 상태 변경하기
+ @PatchMapping("/{podId}/deposit-status")
+ public BaseResponse updatePodStatus(@PathVariable Long podId, @AuthenticationPrincipal CustomOAuth2User customOAuth2User) {
+ myPageService.updateDepositStatus(podId, customOAuth2User.getUserId());
+ return BaseResponse.onSuccess(SuccessStatus._OK,"입금 상태가 성공적으로 변경되었습니다.");
+ }
+
//완료된 나의 팟 리스트 조회
@GetMapping("/completed/mypods")
public BaseResponse> getCompletedMyPodList(@AuthenticationPrincipal CustomOAuth2User customOAuth2User) {
diff --git a/be/src/main/java/com/podmate/domain/mypage/application/MyPageService.java b/be/src/main/java/com/podmate/domain/mypage/application/MyPageService.java
index bd6e3c3..27acc11 100644
--- a/be/src/main/java/com/podmate/domain/mypage/application/MyPageService.java
+++ b/be/src/main/java/com/podmate/domain/mypage/application/MyPageService.java
@@ -19,12 +19,14 @@
import com.podmate.domain.pod.domain.enums.PodStatus;
import com.podmate.domain.pod.domain.enums.PodType;
import com.podmate.domain.pod.domain.repository.PodRepository;
+import com.podmate.domain.pod.dto.PodRequestDto;
import com.podmate.domain.pod.dto.PodResponse;
import com.podmate.domain.pod.dto.PodResponseDto;
import com.podmate.domain.pod.exception.PodStatusMismatchException;
import com.podmate.domain.pod.exception.PodNotFoundException;
import com.podmate.domain.pod.exception.PodTypeNotFoundException;
import com.podmate.domain.podUserMapping.domain.entity.PodUserMapping;
+import com.podmate.domain.podUserMapping.domain.enums.DepositStatus;
import com.podmate.domain.podUserMapping.domain.enums.IsApproved;
import com.podmate.domain.podUserMapping.domain.enums.PodRole;
import com.podmate.domain.podUserMapping.domain.repository.PodUserMappingRepository;
@@ -38,7 +40,9 @@
import com.podmate.domain.user.domain.entity.User;
import com.podmate.domain.user.domain.repository.UserRepository;
import com.podmate.domain.user.exception.UserNotFoundException;
+import jakarta.persistence.EntityManager;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -49,14 +53,14 @@
import java.util.stream.Collectors;
import static com.podmate.domain.pod.converter.PodConverter.*;
-import static com.podmate.domain.pod.domain.enums.InprogressStatus.ORDER_COMPLETED;
-import static com.podmate.domain.pod.domain.enums.InprogressStatus.RECRUITING;
+import static com.podmate.domain.pod.domain.enums.InprogressStatus.*;
import static com.podmate.domain.podUserMapping.domain.enums.PodRole.POD_LEADER;
import static com.podmate.domain.podUserMapping.domain.enums.PodRole.POD_MEMBER;
@Service
@Transactional
@RequiredArgsConstructor
+@Slf4j
public class MyPageService {
private final UserRepository userRepository;
@@ -209,6 +213,38 @@ public void addTrackingNum(MyPageRequestDto.TrackingNumRequestDto request, Long
notificationService.notifyDeliveryStarted(userId, pod);
}
+ public void addDepositAccount(MyPageRequestDto.DepositAccountRequestDto request, Long podId, Long userId){
+ userRepository.findById(userId).orElseThrow(() -> new UserNotFoundException());
+ Pod pod = podRepository.findById(podId).orElseThrow(() -> new PodNotFoundException());
+ pod.updateDepositAccount(request.getDepositAccountBank(), request.getDepositAccountNumber(), request.getDepositAccountHolder());
+
+ //팟원에게 입금 요청 알림 전송
+ List receivers = podUserMappingRepository.findMembersByPodId(pod.getId());
+ for (User receiver : receivers) {
+ notificationService.notifyPaymentRequest(receiver.getId(), pod, request);
+ }
+ }
+
+ public void updateDepositStatus(Long podId, Long userId) {
+ User user = userRepository.findById(userId)
+ .orElseThrow(() -> new UserNotFoundException());
+ Pod pod = podRepository.findById(podId).orElseThrow(() -> new PodNotFoundException());
+ PodUserMapping podUserMapping = podUserMappingRepository.findByPod_IdAndUser_IdAndPodRole(podId, user.getId(), POD_MEMBER)
+ .orElseThrow(() -> new PodUserMappingNotFoundException());
+ podUserMapping.updatePodUserMappingDepositStatus(DepositStatus.DEPOSIT_COMPLETED);
+
+ Long receiverId = podUserMappingRepository.findLeaderUserIdByPodId(podId)
+ .orElseThrow(() -> new UserNotFoundException());
+ List list = podUserMappingRepository.findAllByPod_Id(podId);
+ boolean allDeposited = list.stream()
+ .allMatch(mapping -> mapping.getDepositStatus() == DepositStatus.DEPOSIT_COMPLETED);
+
+ if (allDeposited) {
+ // 모든 팟원이 입금을 완료했다면 팟장에게 알림 전송
+ notificationService.notifyDepositCompleted(receiverId, pod);
+ }
+ }
+
public List getCompletedMyPods(Long userId) {
List pods = getPodList(userId, POD_LEADER, PodStatus.COMPLETED);
diff --git a/be/src/main/java/com/podmate/domain/mypage/dto/MyPageRequestDto.java b/be/src/main/java/com/podmate/domain/mypage/dto/MyPageRequestDto.java
index 81eec63..7741b44 100644
--- a/be/src/main/java/com/podmate/domain/mypage/dto/MyPageRequestDto.java
+++ b/be/src/main/java/com/podmate/domain/mypage/dto/MyPageRequestDto.java
@@ -26,4 +26,13 @@ public static class TrackingNumRequestDto{
public static class IsApprovedStatusRequestDto{
private String isApprovedStatus; //팟장의 팟원 수락 상태
}
+
+ @Getter
+ @Builder
+ @AllArgsConstructor
+ public static class DepositAccountRequestDto{
+ private String depositAccountBank; // 은행명
+ private String depositAccountNumber; // 계좌번호
+ private String depositAccountHolder; // 예금주
+ }
}
\ No newline at end of file
diff --git a/be/src/main/java/com/podmate/domain/notification/application/NotificationService.java b/be/src/main/java/com/podmate/domain/notification/application/NotificationService.java
index e4d5c02..de23ea2 100644
--- a/be/src/main/java/com/podmate/domain/notification/application/NotificationService.java
+++ b/be/src/main/java/com/podmate/domain/notification/application/NotificationService.java
@@ -1,5 +1,6 @@
package com.podmate.domain.notification.application;
+import com.podmate.domain.mypage.dto.MyPageRequestDto;
import com.podmate.domain.notification.api.NotificationController;
import com.podmate.domain.notification.converter.NotificationConverter;
import com.podmate.domain.notification.domain.NotificationRepository;
@@ -8,14 +9,19 @@
import com.podmate.domain.notification.domain.enums.NotificationType;
import com.podmate.domain.notification.exception.NotificationNotFoundException;
import com.podmate.domain.pod.domain.entity.Pod;
+import com.podmate.domain.pod.domain.enums.PodType;
import com.podmate.domain.pod.domain.repository.PodRepository;
import com.podmate.domain.pod.exception.PodNotFoundException;
+import com.podmate.domain.podUserMapping.domain.entity.PodUserMapping;
+import com.podmate.domain.podUserMapping.domain.enums.PodRole;
import com.podmate.domain.podUserMapping.domain.repository.PodUserMappingRepository;
import com.podmate.domain.podUserMapping.exception.PodLeaderNotFoundException;
+import com.podmate.domain.podUserMapping.exception.PodUserMappingNotFoundException;
import com.podmate.domain.user.domain.entity.User;
import com.podmate.domain.user.domain.repository.UserRepository;
import com.podmate.domain.user.exception.UserNotFoundException;
import lombok.RequiredArgsConstructor;
+import org.springframework.expression.ExpressionException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
@@ -102,8 +108,8 @@ public void notifyRecruitmentDone(Long receiverId, Pod pod) {
User receiver = userRepository.findById(receiverId)
.orElseThrow(() -> new UserNotFoundException());
- String content = pod.getPodName() + " 팟의 모집이 완료되었습니다.";
- String relatedUrl = "/api/mypage/inprogress/mypods";
+ String content = pod.getPodName() + " 팟의 모집이 완료되었습니다. 입금 계좌를 입력해주세요";
+ String relatedUrl = "/api/mypage/inprogress/mypods/"+pod.getId()+"/deposit-account";
sendNotification(receiver, content, RECRUITMENT_DONE, "recruitmentDone", relatedUrl);
}
@@ -139,7 +145,17 @@ public void notifyReviewRequest(Long userId, Pod pod) {
sendNotification(receiver, content, REVIEW_REQUEST, "reviewRequest", relatedUrl);
}
- // 팟장이 주문 완료 상태로 변경
+ public void notifyAddTrackingNum(Long userId, Pod pod) {
+ User receiver = userRepository.findById(userId)
+ .orElseThrow(() -> new UserNotFoundException());
+
+ String content = pod.getPodName() + " 팟의 운송장 번호를 입력해주세요.";
+ String relatedUrl = "/api/mypage/inprogress/mypods/"+pod.getId();
+
+ sendNotification(receiver, content, ADD_TRACKING_NUM, "addTrackingNum", relatedUrl);
+ }
+
+ // 팟장이 주문 완료 상태로 변경 -> 팟원들에게 알림
public void notifyOrderPlaced(Long userId, Pod pod) {
User receiver = userRepository.findById(userId)
.orElseThrow(() -> new UserNotFoundException());
@@ -171,6 +187,44 @@ public void notifyDeliveryArrived(Long userId, Pod pod) {
sendNotification(receiver, content, DELIVERY_ARRIVED, "deliveryArrived", relatedUrl);
}
+
+ // 팟원들에게 입금 요청
+ public void notifyPaymentRequest(Long userId, Pod pod, MyPageRequestDto.DepositAccountRequestDto request) {
+ User receiver = userRepository.findById(userId)
+ .orElseThrow(() -> new UserNotFoundException());
+
+ //예외 만들어야됨!!
+ PodUserMapping podUserMapping = podUserMappingRepository.findByPod_IdAndUser_IdAndPodRole(pod.getId(), userId, PodRole.POD_MEMBER)
+ .orElseThrow(() -> new ExpressionException("podId=%d에 대해 userId=%d와의 매핑(POD_MEMBER)이 존재하지 않습니다.".formatted(pod.getId(), userId)));
+
+
+ int totalPrice= 0 ;
+ if (pod.getPodType() == PodType.MINIMUM){
+ totalPrice = podUserMapping.getOrderForm().getTotalAmount();
+ }else{
+ totalPrice = pod.getUnitPrice() * pod.getUnitQuantity() * podUserMapping.getGroupBuyQuantity();
+ }
+
+
+ String content = pod.getPodName() + " 팟 모집이 완료되었습니다. 아래 계좌로 지금 입금해주세요." +
+ " 은행명 : "+request.getDepositAccountBank()+
+ " 계좌번호 :"+request.getDepositAccountNumber()+
+ " 예금주 : "+request.getDepositAccountHolder()+
+ " 총금액 :"+totalPrice;
+ String relatedUrl = "/api/mypage/"+pod.getId()+"/deposit-status";
+
+ sendNotification(receiver, content, PAYMENT_REQUEST, "paymentRequest", relatedUrl);
+ }
+
+ public void notifyDepositCompleted(Long receiverId, Pod pod){
+ User receiver = userRepository.findById(receiverId)
+ .orElseThrow(() -> new UserNotFoundException());
+
+ String content = pod.getPodName() + " 팟의 모든 팟원들의 입금이 완료되었습니다. 이제 주문해주세요";
+
+ sendNotification(receiver, content, PAYMENT_COMPLETED, "deliveryArrived", null);
+ }
+
// 주요 알림 기능
public void sendNotification(User receiver, String content, NotificationType type, String eventName, String relatedUrl) {
if (!NotificationController.sseEmitters.containsKey(receiver.getId())) return;
diff --git a/be/src/main/java/com/podmate/domain/notification/domain/enums/NotificationType.java b/be/src/main/java/com/podmate/domain/notification/domain/enums/NotificationType.java
index 3d82af8..e1a54ae 100644
--- a/be/src/main/java/com/podmate/domain/notification/domain/enums/NotificationType.java
+++ b/be/src/main/java/com/podmate/domain/notification/domain/enums/NotificationType.java
@@ -2,12 +2,13 @@
public enum NotificationType {
// 공통
- POLICY_VIOLATION, // 서비스 정지 알림
REVIEW_REQUEST, // 거래 후기 요청
// 팟장 관련
PARTICIPATION_REQUEST, // 참여 요청 도착
RECRUITMENT_DONE, // 모집 완료
+ PAYMENT_COMPLETED, // 팟장들의 입금 완료
+ ADD_TRACKING_NUM, // 운송장 입력 요청
// 팟원 관련
PARTICIPATION_APPROVED, // 팟 참여 승인
diff --git a/be/src/main/java/com/podmate/domain/pod/application/PodService.java b/be/src/main/java/com/podmate/domain/pod/application/PodService.java
index 3f7b475..db737e4 100644
--- a/be/src/main/java/com/podmate/domain/pod/application/PodService.java
+++ b/be/src/main/java/com/podmate/domain/pod/application/PodService.java
@@ -22,6 +22,7 @@
import com.podmate.domain.pod.exception.PendingOrderMismatchException;
import com.podmate.domain.pod.exception.PodNotFoundException;
import com.podmate.domain.podUserMapping.domain.entity.PodUserMapping;
+import com.podmate.domain.podUserMapping.domain.enums.DepositStatus;
import com.podmate.domain.podUserMapping.domain.enums.IsApproved;
import com.podmate.domain.podUserMapping.domain.enums.PodRole;
import com.podmate.domain.podUserMapping.domain.repository.PodUserMappingRepository;
@@ -221,6 +222,7 @@ public Long createMinimum(PodRequestDto.MininumRequestDto request, Long userId){
.user(user)
.isApproved(IsApproved.ACCEPTED)
.podRole(PodRole.POD_LEADER)
+ .depositStatus(DepositStatus.DEPOSIT_COMPLETED)
.build();
podUserMappingRepository.save(mapping);
@@ -290,8 +292,6 @@ public void updatePodStatus(Long podId, PodRequestDto.ChangingInprogressStatus r
.orElseThrow(() -> new UserNotFoundException());
Pod pod = podRepository.findById(podId)
.orElseThrow(() -> new PodNotFoundException());
- Delivery delivery = deliveryRepository.findByPod_Id(pod.getId())
- .orElseThrow(() -> new DeliveryNotFoundException());
if (!podUserMappingRepository.existsByPod_IdAndUser_IdAndPodRole(pod.getId(), user.getId(), PodRole.POD_LEADER)) {
throw new PodUserMappingNotFoundException();
@@ -306,9 +306,18 @@ public void updatePodStatus(Long podId, PodRequestDto.ChangingInprogressStatus r
throw new PendingOrderMismatchException();
}
pod.updateInprogressStatus(InprogressStatus.ORDER_COMPLETED);
- notificationService.notifyOrderPlaced(user.getId(), pod);
+
+ notificationService.notifyAddTrackingNum(user.getId(), pod);
+ //팟원에게 주문 완료 알림 전송
+ List receivers = podUserMappingRepository.findMembersByPodId(pod.getId());
+ for (User receiver : receivers) {
+ notificationService.notifyOrderPlaced(receiver.getId(), pod);
+ }
}
else if("DELIVERED".equals(nextStatus)) {
+ Delivery delivery = deliveryRepository.findByPod_Id(pod.getId())
+ .orElseThrow(() -> new DeliveryNotFoundException());
+
if (delivery.getDeliveryStatus() != DeliveryStatus.SHIPPING){
throw new ShippingMismatchException();
}
diff --git a/be/src/main/java/com/podmate/domain/pod/domain/entity/Pod.java b/be/src/main/java/com/podmate/domain/pod/domain/entity/Pod.java
index 3f16448..c3547ae 100644
--- a/be/src/main/java/com/podmate/domain/pod/domain/entity/Pod.java
+++ b/be/src/main/java/com/podmate/domain/pod/domain/entity/Pod.java
@@ -68,6 +68,12 @@ public class Pod extends BaseEntity {
private Integer unitPrice; //단위 가격
+ private String depositAccountBank; // 은행명
+
+ private String depositAccountNumber; // 계좌번호
+
+ private String depositAccountHolder; // 예금주
+
@Builder
private Pod(String podName, PodType podType, PodStatus podStatus, InprogressStatus inprogressStatus, LocalDate deadline, Platform platform,
int currentAmount, int goalAmount, String description, Address address, String itemUrl, int totalAmount, int unitQuantity, int unitPrice) {
@@ -132,4 +138,10 @@ public void increaseCurrentAmount(int currentAmount) {
public void updatePodStatus(PodStatus status) {
this.podStatus = status;
}
+
+ public void updateDepositAccount (String depositAccountBank, String depositAccountHolder, String depositAccountNumber) {
+ this.depositAccountBank = depositAccountBank;
+ this.depositAccountNumber = depositAccountNumber;
+ this.depositAccountHolder = depositAccountHolder;
+ }
}
diff --git a/be/src/main/java/com/podmate/domain/pod/domain/repository/PodRepository.java b/be/src/main/java/com/podmate/domain/pod/domain/repository/PodRepository.java
index b0d942f..beedc77 100644
--- a/be/src/main/java/com/podmate/domain/pod/domain/repository/PodRepository.java
+++ b/be/src/main/java/com/podmate/domain/pod/domain/repository/PodRepository.java
@@ -1,10 +1,13 @@
package com.podmate.domain.pod.domain.repository;
import com.podmate.domain.pod.domain.entity.Pod;
+import com.podmate.domain.pod.domain.enums.InprogressStatus;
import com.podmate.domain.pod.domain.enums.PodStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
+import java.util.Optional;
+
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
@@ -28,4 +31,10 @@ List findByAddressInBounds(
@Param("minLng") double minLng,
@Param("maxLng") double maxLng
);
+
+ @Query(value = "SELECT * FROM pod WHERE pod_id = :id", nativeQuery = true)
+ Optional findByIdNative(@Param("id") Long id);
+
+ Optional findByIdAndInprogressStatus(Long podId, InprogressStatus inprogressStatus);
+
}
diff --git a/be/src/main/java/com/podmate/domain/podUserMapping/domain/entity/PodUserMapping.java b/be/src/main/java/com/podmate/domain/podUserMapping/domain/entity/PodUserMapping.java
index 2d26bcf..19e1b24 100644
--- a/be/src/main/java/com/podmate/domain/podUserMapping/domain/entity/PodUserMapping.java
+++ b/be/src/main/java/com/podmate/domain/podUserMapping/domain/entity/PodUserMapping.java
@@ -8,6 +8,7 @@
import com.podmate.domain.pod.domain.enums.Platform;
import com.podmate.domain.pod.domain.enums.PodStatus;
import com.podmate.domain.pod.domain.enums.PodType;
+import com.podmate.domain.podUserMapping.domain.enums.DepositStatus;
import com.podmate.domain.podUserMapping.domain.enums.IsApproved;
import com.podmate.domain.podUserMapping.domain.enums.PodRole;
import com.podmate.domain.user.domain.entity.User;
@@ -52,13 +53,18 @@ public class PodUserMapping extends BaseEntity {
@Column(nullable = true)
private Integer groupBuyQuantity;
+ @Enumerated(EnumType.STRING)
+ @Column(nullable = false)
+ private DepositStatus depositStatus;
+
@Builder
- private PodUserMapping(Pod pod, User user, IsApproved isApproved, PodRole podRole, Integer groupBuyQuantity) {
+ private PodUserMapping(Pod pod, User user, IsApproved isApproved, PodRole podRole, Integer groupBuyQuantity, DepositStatus depositStatus) {
this.pod = pod;
this.user = user;
this.isApproved = isApproved;
this.podRole = podRole;
this.groupBuyQuantity = groupBuyQuantity;
+ this.depositStatus = depositStatus;
}
@@ -70,11 +76,15 @@ public static PodUserMapping updatePodUserMappingForOrderForm(Pod pod, User user
mapping.orderForm = orderForm;
mapping.isApproved = isApproved;
mapping.podRole = podRole;
-
+ mapping.depositStatus = DepositStatus.DEPOSIT_PENDING;
return mapping;
}
public void updatePodUserMappingIsApproved(IsApproved isApproved) {
this.isApproved = isApproved;
}
+
+ public void updatePodUserMappingDepositStatus(DepositStatus depositStatus){
+ this.depositStatus = depositStatus;
+ }
}
diff --git a/be/src/main/java/com/podmate/domain/podUserMapping/domain/enums/DepositStatus.java b/be/src/main/java/com/podmate/domain/podUserMapping/domain/enums/DepositStatus.java
new file mode 100644
index 0000000..412e14a
--- /dev/null
+++ b/be/src/main/java/com/podmate/domain/podUserMapping/domain/enums/DepositStatus.java
@@ -0,0 +1,5 @@
+package com.podmate.domain.podUserMapping.domain.enums;
+
+public enum DepositStatus {
+ DEPOSIT_PENDING, DEPOSIT_COMPLETED
+}