From 20def78dc7f2b885386523272b8e999865c2f6db Mon Sep 17 00:00:00 2001 From: HyunWoo9930 Date: Tue, 19 Nov 2024 01:09:47 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat=20:=20=EA=B0=80=EA=B2=8C=20=EA=B2=B0?= =?UTF-8?q?=EC=A0=9C=20=EA=B7=B8=EB=A3=B9=20=EC=A1=B0=ED=9A=8C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/domain/StoreTeamResponseDTO.java | 23 ++++++++++++ .../domain/controller/StoreController.java | 36 +++++++++++-------- .../repository/StoreTeamRepository.java | 6 ++++ .../store/domain/service/StoreService.java | 23 ++++++++++-- 4 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java diff --git a/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java b/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java new file mode 100644 index 0000000..130b7bf --- /dev/null +++ b/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java @@ -0,0 +1,23 @@ +package com.jangburich.domain.store.domain; + +import com.querydsl.core.annotations.QueryProjection; + +import lombok.Builder; + +@Builder +public record StoreTeamResponseDTO( + Long id, + Integer point, + Long teamId, + Long storeId + +) { + + @QueryProjection + public StoreTeamResponseDTO(Long id, Integer point, Long teamId, Long storeId) { + this.id = id; + this.point = point; + this.teamId = teamId; + this.storeId = storeId; + } +} diff --git a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java index f588397..6fbc67d 100644 --- a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java +++ b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java @@ -1,5 +1,7 @@ package com.jangburich.domain.store.domain.controller; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PatchMapping; @@ -13,10 +15,12 @@ import com.jangburich.domain.store.domain.StoreAdditionalInfoCreateRequestDTO; import com.jangburich.domain.store.domain.StoreCreateRequestDTO; import com.jangburich.domain.store.domain.StoreGetResponseDTO; +import com.jangburich.domain.store.domain.StoreTeamResponseDTO; import com.jangburich.domain.store.domain.StoreUpdateRequestDTO; import com.jangburich.domain.store.domain.service.StoreService; import com.jangburich.global.payload.Message; import com.jangburich.global.payload.ResponseCustom; +import com.jangburich.utils.parser.AuthenticationParser; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -34,32 +38,26 @@ public class StoreController { public ResponseCustom createStore(Authentication authentication, @RequestBody StoreCreateRequestDTO storeCreateRequestDTO) { CustomOAuthUser customOAuth2User = (CustomOAuthUser)authentication.getPrincipal(); - storeService.CreateStore(customOAuth2User, storeCreateRequestDTO); - return ResponseCustom.OK(Message.builder() - .message("success") - .build()); + storeService.createStore(customOAuth2User, storeCreateRequestDTO); + return ResponseCustom.OK(Message.builder().message("success").build()); } @Operation(summary = "가게 추가정보 저장", description = "예약 가능 여부, 최소 선결제 금액, 선결제 사용 기간을 저장합니다.") @PostMapping("/create/additionalInfo") - public ResponseCustom createAdditionalInfo(Authentication authentication, @RequestBody - StoreAdditionalInfoCreateRequestDTO storeAdditionalInfoCreateRequestDTO) { + public ResponseCustom createAdditionalInfo(Authentication authentication, + @RequestBody StoreAdditionalInfoCreateRequestDTO storeAdditionalInfoCreateRequestDTO) { CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); - storeService.CreateAdditionalInfo(customOAuthUser, storeAdditionalInfoCreateRequestDTO); - return ResponseCustom.OK(Message.builder() - .message("success") - .build()); + storeService.createAdditionalInfo(customOAuthUser, storeAdditionalInfoCreateRequestDTO); + return ResponseCustom.OK(Message.builder().message("success").build()); } @Operation(summary = "가게 정보 수정", description = "가게 정보를 수정합니다.") @PatchMapping("/{storeId}/update") - public ResponseCustom updateStore(Authentication authentication, @PathVariable Long storeId, @RequestBody - StoreUpdateRequestDTO storeUpdateRequestDTO) { + public ResponseCustom updateStore(Authentication authentication, @PathVariable Long storeId, + @RequestBody StoreUpdateRequestDTO storeUpdateRequestDTO) { CustomOAuthUser principal = (CustomOAuthUser)authentication.getPrincipal(); storeService.updateStore(principal, storeId, storeUpdateRequestDTO); - return ResponseCustom.OK(Message.builder() - .message("success") - .build()); + return ResponseCustom.OK(Message.builder().message("success").build()); } @Operation(summary = "가게 정보 조회", description = "가게 상세 정보를 조회합니다.") @@ -68,4 +66,12 @@ public ResponseCustom getStoreInfo(Authentication authentic CustomOAuthUser customOAuth2User = (CustomOAuthUser)authentication.getPrincipal(); return ResponseCustom.OK(storeService.getStoreInfo(customOAuth2User)); } + + @Operation(summary = "결제 그룹 조회", description = "장부 결제 그룹을 조회합니다.") + @GetMapping("/payment_group") + public ResponseCustom> getPaymentGroup(Authentication authentication, + Pageable pageable) { + return ResponseCustom.OK( + storeService.getPaymentGroup(AuthenticationParser.parseUserId(authentication), pageable)); + } } \ No newline at end of file diff --git a/src/main/java/com/jangburich/domain/store/domain/repository/StoreTeamRepository.java b/src/main/java/com/jangburich/domain/store/domain/repository/StoreTeamRepository.java index d3add35..6e00e6d 100644 --- a/src/main/java/com/jangburich/domain/store/domain/repository/StoreTeamRepository.java +++ b/src/main/java/com/jangburich/domain/store/domain/repository/StoreTeamRepository.java @@ -2,10 +2,16 @@ import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; +import com.jangburich.domain.store.domain.Store; import com.jangburich.domain.store.domain.StoreTeam; +import com.jangburich.domain.store.domain.StoreTeamResponseDTO; public interface StoreTeamRepository extends JpaRepository { Optional findByStoreIdAndTeamId(Long store_id, Long team_id); + + Page findAllByStore(Store store, Pageable pageable); } diff --git a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java index b185b3b..40092fb 100644 --- a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java +++ b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java @@ -1,5 +1,7 @@ package com.jangburich.domain.store.domain.service; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -10,8 +12,10 @@ import com.jangburich.domain.store.domain.StoreAdditionalInfoCreateRequestDTO; import com.jangburich.domain.store.domain.StoreCreateRequestDTO; import com.jangburich.domain.store.domain.StoreGetResponseDTO; +import com.jangburich.domain.store.domain.StoreTeamResponseDTO; import com.jangburich.domain.store.domain.StoreUpdateRequestDTO; import com.jangburich.domain.store.domain.repository.StoreRepository; +import com.jangburich.domain.store.domain.repository.StoreTeamRepository; import com.jangburich.domain.user.domain.User; import com.jangburich.domain.user.domain.repository.UserRepository; import com.jangburich.global.error.DefaultNullPointerException; @@ -26,9 +30,10 @@ public class StoreService { private final StoreRepository storeRepository; private final OwnerRepository ownerRepository; private final UserRepository userRepository; + private final StoreTeamRepository storeTeamRepository; @Transactional - public void CreateStore(CustomOAuthUser customOAuth2User, StoreCreateRequestDTO storeCreateRequestDTO) { + public void createStore(CustomOAuthUser customOAuth2User, StoreCreateRequestDTO storeCreateRequestDTO) { User user = userRepository.findByProviderId(customOAuth2User.getUserId()) .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); @@ -39,7 +44,7 @@ public void CreateStore(CustomOAuthUser customOAuth2User, StoreCreateRequestDTO } @Transactional - public void CreateAdditionalInfo(CustomOAuthUser customOAuthUser, + public void createAdditionalInfo(CustomOAuthUser customOAuthUser, StoreAdditionalInfoCreateRequestDTO storeAdditionalInfoCreateRequestDTO) { User user = userRepository.findByProviderId(customOAuthUser.getUserId()) .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); @@ -133,4 +138,18 @@ public StoreGetResponseDTO getStoreInfo(CustomOAuthUser customOAuth2User) { return new StoreGetResponseDTO().of(store); } + + public Page getPaymentGroup(String userId, Pageable pageable) { + User user = userRepository.findByProviderId(userId) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Owner owner = ownerRepository.findByUser(user) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Store store = storeRepository.findByOwner(owner) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + return storeTeamRepository.findAllByStore(store, pageable); + + } } From 40bf044f6e4219f458bc0da9c0fe491750d18176 Mon Sep 17 00:00:00 2001 From: HyunWoo9930 Date: Tue, 19 Nov 2024 09:11:22 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat=20:=20=EA=B0=80=EA=B2=8C=20=EA=B2=B0?= =?UTF-8?q?=EC=A0=9C=20=EA=B7=B8=EB=A3=B9=20=EC=83=81=EC=84=B8=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/application/KakaopayService.java | 3 +- .../domain/TeamChargeHistoryResponse.java | 22 +++++++ .../TeamChargeHistoryRepository.java | 8 +++ .../domain/store/domain/StoreTeam.java | 14 +++- .../store/domain/StoreTeamResponseDTO.java | 6 +- .../domain/controller/StoreController.java | 44 ++++++++----- .../response/PaymentGroupDetailResponse.java | 34 ++++++++++ .../store/domain/service/StoreService.java | 65 ++++++++++++++----- 8 files changed, 158 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistoryResponse.java create mode 100644 src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java diff --git a/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java b/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java index a4d2ee1..24e3cc8 100644 --- a/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java +++ b/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java @@ -130,7 +130,8 @@ public ApproveResponse payApprove(String pgToken) { .orElse(null); if (storeTeam != null) { - storeTeam.updatePoint(teamChargeHistory.getPaymentAmount()); + storeTeam.addPoint(teamChargeHistory.getPaymentAmount()); + storeTeam.addRemainPoint(teamChargeHistory.getPaymentAmount()); } else { storeTeamRepository.save( StoreTeam.create(teamChargeHistory.getTeam(), store, teamChargeHistory.getPaymentAmount())); diff --git a/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistoryResponse.java b/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistoryResponse.java new file mode 100644 index 0000000..3f9f663 --- /dev/null +++ b/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistoryResponse.java @@ -0,0 +1,22 @@ +package com.jangburich.domain.payment.domain; + +import com.querydsl.core.annotations.QueryProjection; + +import lombok.Builder; + +@Builder +public record TeamChargeHistoryResponse( + Long id, + String transactionId, + Integer paymentAmount, + PaymentChargeStatus paymentChargeStatus +) { + @QueryProjection + public TeamChargeHistoryResponse(Long id, String transactionId, Integer paymentAmount, + PaymentChargeStatus paymentChargeStatus) { + this.id = id; + this.transactionId = transactionId; + this.paymentAmount = paymentAmount; + this.paymentChargeStatus = paymentChargeStatus; + } +} diff --git a/src/main/java/com/jangburich/domain/payment/domain/repository/TeamChargeHistoryRepository.java b/src/main/java/com/jangburich/domain/payment/domain/repository/TeamChargeHistoryRepository.java index 1a43279..1ce99ae 100644 --- a/src/main/java/com/jangburich/domain/payment/domain/repository/TeamChargeHistoryRepository.java +++ b/src/main/java/com/jangburich/domain/payment/domain/repository/TeamChargeHistoryRepository.java @@ -1,11 +1,19 @@ package com.jangburich.domain.payment.domain.repository; import com.jangburich.domain.payment.domain.TeamChargeHistory; +import com.jangburich.domain.payment.domain.TeamChargeHistoryResponse; +import com.jangburich.domain.team.domain.Team; + import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface TeamChargeHistoryRepository extends JpaRepository { Optional findByTransactionId(String tid); + + Page findAllByTeam(Team team, Pageable pageable); } diff --git a/src/main/java/com/jangburich/domain/store/domain/StoreTeam.java b/src/main/java/com/jangburich/domain/store/domain/StoreTeam.java index 73db450..313380c 100644 --- a/src/main/java/com/jangburich/domain/store/domain/StoreTeam.java +++ b/src/main/java/com/jangburich/domain/store/domain/StoreTeam.java @@ -37,15 +37,27 @@ public class StoreTeam extends BaseEntity { @Column(name = "point") private Integer point; - public void updatePoint(Integer point) { + @Column(name = "remain_point") + private Integer remainPoint; + + public void addPoint(Integer point) { this.point += point; } + public void addRemainPoint(Integer point) { + this.remainPoint += point; + } + + public void subRemainPoint(Integer point) { + this.remainPoint -= point; + } + public static StoreTeam create(Team team, Store store, Integer point) { StoreTeam storeTeam = new StoreTeam(); storeTeam.setTeam(team); storeTeam.setStore(store); storeTeam.setPoint(point); + storeTeam.setRemainPoint(point); return storeTeam; } } \ No newline at end of file diff --git a/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java b/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java index 130b7bf..b2be3af 100644 --- a/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java +++ b/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java @@ -1,5 +1,6 @@ package com.jangburich.domain.store.domain; +import com.jangburich.domain.team.domain.Team; import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; @@ -9,15 +10,16 @@ public record StoreTeamResponseDTO( Long id, Integer point, Long teamId, + String teamName, Long storeId ) { - @QueryProjection - public StoreTeamResponseDTO(Long id, Integer point, Long teamId, Long storeId) { + public StoreTeamResponseDTO(Long id, Integer point, Long teamId, String teamName, Long storeId) { this.id = id; this.point = point; this.teamId = teamId; + this.teamName = teamName; this.storeId = storeId; } } diff --git a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java index f9dc284..a60bd1e 100644 --- a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java +++ b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java @@ -1,11 +1,5 @@ package com.jangburich.domain.store.domain.controller; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import com.jangburich.domain.store.domain.Category; -import com.jangburich.domain.store.domain.dto.condition.StoreSearchCondition; -import com.jangburich.domain.store.domain.dto.condition.StoreSearchConditionWithType; -import com.jangburich.domain.store.domain.dto.response.SearchStoresResponse; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.security.core.Authentication; @@ -20,11 +14,16 @@ import org.springframework.web.bind.annotation.RestController; import com.jangburich.domain.oauth.domain.CustomOAuthUser; +import com.jangburich.domain.store.domain.Category; import com.jangburich.domain.store.domain.StoreAdditionalInfoCreateRequestDTO; import com.jangburich.domain.store.domain.StoreCreateRequestDTO; import com.jangburich.domain.store.domain.StoreGetResponseDTO; import com.jangburich.domain.store.domain.StoreTeamResponseDTO; import com.jangburich.domain.store.domain.StoreUpdateRequestDTO; +import com.jangburich.domain.store.domain.dto.condition.StoreSearchCondition; +import com.jangburich.domain.store.domain.dto.condition.StoreSearchConditionWithType; +import com.jangburich.domain.store.domain.dto.response.PaymentGroupDetailResponse; +import com.jangburich.domain.store.domain.dto.response.SearchStoresResponse; import com.jangburich.domain.store.domain.service.StoreService; import com.jangburich.global.payload.Message; import com.jangburich.global.payload.ResponseCustom; @@ -45,24 +44,26 @@ public class StoreController { @Operation(summary = "카테고리 별 가게 목록 조회", description = "카테고리 별로 가게 목록을 조회합니다.") @GetMapping public ResponseCustom> searchByCategory( - Authentication authentication, - @RequestParam(required = false, defaultValue = "3") Integer searchRadius, - @RequestParam(required = false, defaultValue = "ALL") Category category, - @ModelAttribute StoreSearchCondition storeSearchCondition, - Pageable pageable + Authentication authentication, + @RequestParam(required = false, defaultValue = "3") Integer searchRadius, + @RequestParam(required = false, defaultValue = "ALL") Category category, + @ModelAttribute StoreSearchCondition storeSearchCondition, + Pageable pageable ) { - return ResponseCustom.OK(storeService.searchByCategory(authentication, searchRadius, category, storeSearchCondition, pageable)); + return ResponseCustom.OK( + storeService.searchByCategory(authentication, searchRadius, category, storeSearchCondition, pageable)); } @Operation(summary = "매장 찾기(검색)", description = "검색어와 매장 유형에 맞는 매장을 검색합니다.") @GetMapping("/search") public ResponseCustom> searchStores( - Authentication authentication, - @RequestParam(required = false, defaultValue = "") String keyword, - @ModelAttribute StoreSearchConditionWithType storeSearchConditionWithType, - Pageable pageable + Authentication authentication, + @RequestParam(required = false, defaultValue = "") String keyword, + @ModelAttribute StoreSearchConditionWithType storeSearchConditionWithType, + Pageable pageable ) { - return ResponseCustom.OK(storeService.searchStores(authentication, keyword, storeSearchConditionWithType, pageable)); + return ResponseCustom.OK( + storeService.searchStores(authentication, keyword, storeSearchConditionWithType, pageable)); } @Operation(summary = "가게 등록", description = "신규 파트너 가게를 등록합니다.") @@ -106,4 +107,13 @@ public ResponseCustom> getPaymentGroup(Authentication return ResponseCustom.OK( storeService.getPaymentGroup(AuthenticationParser.parseUserId(authentication), pageable)); } + + @Operation(summary = "결제 그룹 상세 조회", description = "장부 결제 그룹을 상세 조회합니다.") + @GetMapping("/payment_group/{teamId}") + public ResponseCustom getPaymentGroupDetail(Authentication authentication, + @PathVariable Long teamId, + Pageable pageable) { + return ResponseCustom.OK( + storeService.getPaymentGroupDetail(AuthenticationParser.parseUserId(authentication), teamId, pageable)); + } } \ No newline at end of file diff --git a/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java b/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java new file mode 100644 index 0000000..4b3e0e2 --- /dev/null +++ b/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java @@ -0,0 +1,34 @@ +package com.jangburich.domain.store.domain.dto.response; + +import org.springframework.data.domain.Page; + +import com.jangburich.domain.payment.domain.TeamChargeHistoryResponse; +import com.jangburich.domain.user.domain.User; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@RequiredArgsConstructor +public class PaymentGroupDetailResponse { + private String teamName; + private Integer point; + private Integer remainPoint; + private String teamLeaderName; + private String teamLeaderPhoneNum; + private Page historyResponses; + + public static PaymentGroupDetailResponse create(String teamName, Integer point, Integer remainPoint, + User teamLeader, Page historyResponses) { + PaymentGroupDetailResponse paymentGroupDetailResponse = new PaymentGroupDetailResponse(); + paymentGroupDetailResponse.setTeamName(teamName); + paymentGroupDetailResponse.setPoint(point); + paymentGroupDetailResponse.setRemainPoint(remainPoint); + paymentGroupDetailResponse.setTeamLeaderName(teamLeader.getNickname()); + paymentGroupDetailResponse.setTeamLeaderPhoneNum(teamLeader.getPhoneNumber()); + paymentGroupDetailResponse.setHistoryResponses(historyResponses); + return paymentGroupDetailResponse; + } +} diff --git a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java index 936175d..324e12d 100644 --- a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java +++ b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java @@ -1,12 +1,5 @@ package com.jangburich.domain.store.domain.service; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import com.jangburich.domain.store.domain.Category; -import com.jangburich.domain.store.domain.dto.condition.StoreSearchCondition; -import com.jangburich.domain.store.domain.dto.condition.StoreSearchConditionWithType; -import com.jangburich.domain.store.domain.dto.response.SearchStoresResponse; -import com.jangburich.utils.parser.AuthenticationParser; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.security.core.Authentication; @@ -16,18 +9,29 @@ import com.jangburich.domain.oauth.domain.CustomOAuthUser; import com.jangburich.domain.owner.domain.Owner; import com.jangburich.domain.owner.domain.repository.OwnerRepository; +import com.jangburich.domain.payment.domain.TeamChargeHistoryResponse; +import com.jangburich.domain.payment.domain.repository.TeamChargeHistoryRepository; +import com.jangburich.domain.store.domain.Category; import com.jangburich.domain.store.domain.Store; import com.jangburich.domain.store.domain.StoreAdditionalInfoCreateRequestDTO; import com.jangburich.domain.store.domain.StoreCreateRequestDTO; import com.jangburich.domain.store.domain.StoreGetResponseDTO; +import com.jangburich.domain.store.domain.StoreTeam; import com.jangburich.domain.store.domain.StoreTeamResponseDTO; import com.jangburich.domain.store.domain.StoreUpdateRequestDTO; +import com.jangburich.domain.store.domain.dto.condition.StoreSearchCondition; +import com.jangburich.domain.store.domain.dto.condition.StoreSearchConditionWithType; +import com.jangburich.domain.store.domain.dto.response.PaymentGroupDetailResponse; +import com.jangburich.domain.store.domain.dto.response.SearchStoresResponse; import com.jangburich.domain.store.domain.repository.StoreRepository; import com.jangburich.domain.store.domain.repository.StoreTeamRepository; +import com.jangburich.domain.team.domain.Team; +import com.jangburich.domain.team.domain.repository.TeamRepository; import com.jangburich.domain.user.domain.User; import com.jangburich.domain.user.domain.repository.UserRepository; import com.jangburich.global.error.DefaultNullPointerException; import com.jangburich.global.payload.ErrorCode; +import com.jangburich.utils.parser.AuthenticationParser; import lombok.RequiredArgsConstructor; @@ -39,6 +43,8 @@ public class StoreService { private final OwnerRepository ownerRepository; private final UserRepository userRepository; private final StoreTeamRepository storeTeamRepository; + private final TeamRepository teamRepository; + private final TeamChargeHistoryRepository teamChargeHistoryRepository; @Transactional public void createStore(CustomOAuthUser customOAuth2User, StoreCreateRequestDTO storeCreateRequestDTO) { @@ -158,26 +164,51 @@ public Page getPaymentGroup(String userId, Pageable pageab .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); return storeTeamRepository.findAllByStore(store, pageable); - } public Page searchByCategory(final Authentication authentication, - final Integer searchRadius, - final Category category, - final StoreSearchCondition storeSearchCondition, - final Pageable pageable) { + final Integer searchRadius, + final Category category, + final StoreSearchCondition storeSearchCondition, + final Pageable pageable) { String parsed = AuthenticationParser.parseUserId(authentication); User user = userRepository.findByProviderId(parsed) - .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); - return storeRepository.findStoresByCategory(user.getUserId(), searchRadius, category, storeSearchCondition, pageable); + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + return storeRepository.findStoresByCategory(user.getUserId(), searchRadius, category, storeSearchCondition, + pageable); } public Page searchStores(final Authentication authentication, final String keyword, - final StoreSearchConditionWithType storeSearchConditionWithType, - final Pageable pageable) { + final StoreSearchConditionWithType storeSearchConditionWithType, + final Pageable pageable) { String parsed = AuthenticationParser.parseUserId(authentication); User user = userRepository.findByProviderId(parsed) - .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); return storeRepository.findStores(user.getUserId(), keyword, storeSearchConditionWithType, pageable); } + + public PaymentGroupDetailResponse getPaymentGroupDetail(String userId, Long teamId, Pageable pageable) { + User user = userRepository.findByProviderId(userId) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Owner owner = ownerRepository.findByUser(user) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Store store = storeRepository.findByOwner(owner) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Team team = teamRepository.findById(teamId) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_PARAMETER)); + + User teamLeader = userRepository.findById(team.getTeamLeader().getUser_id()) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_PARAMETER)); + + StoreTeam storeTeam = storeTeamRepository.findByStoreIdAndTeamId(store.getId(), team.getId()) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_PARAMETER)); + + Page chargeHistoryRepositoryAllByTeam = teamChargeHistoryRepository.findAllByTeam( + team, pageable); + + return PaymentGroupDetailResponse.create(team.getName(), storeTeam.getPoint(), storeTeam.getRemainPoint(), teamLeader, chargeHistoryRepositoryAllByTeam); + } } From 0e77e8694bc2f55ca5eaca06f7135c8b85aea829 Mon Sep 17 00:00:00 2001 From: HyunWoo9930 Date: Tue, 19 Nov 2024 09:48:18 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat=20:=20=EA=B2=B0=EC=A0=9C=20=EB=82=B4?= =?UTF-8?q?=EC=97=AD=20=EB=B0=98=ED=99=98=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/application/KakaopayService.java | 4 +- .../payment/domain/TeamChargeHistory.java | 70 ++++++++++--------- .../TeamChargeHistoryRepository.java | 16 +++-- .../domain/StoreChargeHistoryResponse.java | 21 ++++++ .../domain/controller/StoreController.java | 10 ++- .../store/domain/service/StoreService.java | 18 ++++- .../exception/StoreNotFoundException.java | 7 ++ 7 files changed, 104 insertions(+), 42 deletions(-) create mode 100644 src/main/java/com/jangburich/domain/store/domain/StoreChargeHistoryResponse.java create mode 100644 src/main/java/com/jangburich/domain/store/exception/StoreNotFoundException.java diff --git a/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java b/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java index 24e3cc8..4f47145 100644 --- a/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java +++ b/src/main/java/com/jangburich/domain/payment/application/KakaopayService.java @@ -22,6 +22,7 @@ import com.jangburich.domain.store.domain.StoreTeam; import com.jangburich.domain.store.domain.repository.StoreRepository; import com.jangburich.domain.store.domain.repository.StoreTeamRepository; +import com.jangburich.domain.store.exception.StoreNotFoundException; import com.jangburich.domain.team.domain.Team; import com.jangburich.domain.team.domain.repository.TeamRepository; import com.jangburich.global.error.DefaultNullPointerException; @@ -88,12 +89,13 @@ public ReadyResponse payReady(String userId, PayRequest payRequest) { readyResponseResponseEntity = template.postForEntity(url, requestEntity, ReadyResponse.class); Team team = teamRepository.findById(payRequest.teamId()).orElseThrow(() -> new TeamNotFoundException()); - + Store store = storeRepository.findById(payRequest.storeId()).orElseThrow(() -> new StoreNotFoundException()); TeamChargeHistory teamChargeHistory = TeamChargeHistory.builder() .transactionId(readyResponseResponseEntity.getBody().tid()) .paymentAmount(Integer.valueOf(payRequest.totalAmount())) .paymentChargeStatus(PaymentChargeStatus.PENDING) .team(team) + .store(store) .build(); teamChargeHistoryRepository.save(teamChargeHistory); diff --git a/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistory.java b/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistory.java index 0732f6f..49e6ae3 100644 --- a/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistory.java +++ b/src/main/java/com/jangburich/domain/payment/domain/TeamChargeHistory.java @@ -1,8 +1,9 @@ package com.jangburich.domain.payment.domain; import com.jangburich.domain.common.BaseEntity; +import com.jangburich.domain.store.domain.Store; import com.jangburich.domain.team.domain.Team; -import com.jangburich.domain.user.domain.User; + import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -23,35 +24,40 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) public class TeamChargeHistory extends BaseEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", updatable = false) - private Long id; - - @Column(name = "transaction_id") - private String transactionId; - - @Column(name = "payment_amount") - private Integer paymentAmount; - - @Enumerated(EnumType.STRING) - @Column(name = "payment_charge_status", length = 20) - private PaymentChargeStatus paymentChargeStatus; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "team_id") - private Team team; - - @Builder - public TeamChargeHistory(String transactionId, Integer paymentAmount, PaymentChargeStatus paymentChargeStatus, - Team team) { - this.transactionId = transactionId; - this.paymentAmount = paymentAmount; - this.paymentChargeStatus = paymentChargeStatus; - this.team = team; - } - - public void completePaymentChargeStatus() { - this.paymentChargeStatus = PaymentChargeStatus.COMPLETED; - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", updatable = false) + private Long id; + + @Column(name = "transaction_id") + private String transactionId; + + @Column(name = "payment_amount") + private Integer paymentAmount; + + @Enumerated(EnumType.STRING) + @Column(name = "payment_charge_status", length = 20) + private PaymentChargeStatus paymentChargeStatus; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "team_id") + private Team team; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "store_id") + private Store store; + + @Builder + public TeamChargeHistory(String transactionId, Integer paymentAmount, PaymentChargeStatus paymentChargeStatus, + Team team, Store store) { + this.transactionId = transactionId; + this.paymentAmount = paymentAmount; + this.paymentChargeStatus = paymentChargeStatus; + this.team = team; + this.store = store; + } + + public void completePaymentChargeStatus() { + this.paymentChargeStatus = PaymentChargeStatus.COMPLETED; + } } diff --git a/src/main/java/com/jangburich/domain/payment/domain/repository/TeamChargeHistoryRepository.java b/src/main/java/com/jangburich/domain/payment/domain/repository/TeamChargeHistoryRepository.java index 1ce99ae..883a176 100644 --- a/src/main/java/com/jangburich/domain/payment/domain/repository/TeamChargeHistoryRepository.java +++ b/src/main/java/com/jangburich/domain/payment/domain/repository/TeamChargeHistoryRepository.java @@ -1,9 +1,5 @@ package com.jangburich.domain.payment.domain.repository; -import com.jangburich.domain.payment.domain.TeamChargeHistory; -import com.jangburich.domain.payment.domain.TeamChargeHistoryResponse; -import com.jangburich.domain.team.domain.Team; - import java.util.Optional; import org.springframework.data.domain.Page; @@ -11,9 +7,17 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import com.jangburich.domain.payment.domain.TeamChargeHistory; +import com.jangburich.domain.payment.domain.TeamChargeHistoryResponse; +import com.jangburich.domain.store.domain.Store; +import com.jangburich.domain.store.domain.StoreChargeHistoryResponse; +import com.jangburich.domain.team.domain.Team; + @Repository public interface TeamChargeHistoryRepository extends JpaRepository { - Optional findByTransactionId(String tid); + Optional findByTransactionId(String tid); + + Page findAllByTeam(Team team, Pageable pageable); - Page findAllByTeam(Team team, Pageable pageable); + Page findAllByStore(Store store, Pageable pageable); } diff --git a/src/main/java/com/jangburich/domain/store/domain/StoreChargeHistoryResponse.java b/src/main/java/com/jangburich/domain/store/domain/StoreChargeHistoryResponse.java new file mode 100644 index 0000000..74235f8 --- /dev/null +++ b/src/main/java/com/jangburich/domain/store/domain/StoreChargeHistoryResponse.java @@ -0,0 +1,21 @@ +package com.jangburich.domain.store.domain; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +import com.querydsl.core.annotations.QueryProjection; + +public record StoreChargeHistoryResponse( + Long id, + LocalDateTime createdAt, + String teamName, + Integer paymentAmount +) { + @QueryProjection + public StoreChargeHistoryResponse(Long id, LocalDateTime createdAt, String teamName, Integer paymentAmount) { + this.id = id; + this.createdAt = createdAt; + this.teamName = teamName; + this.paymentAmount = paymentAmount; + } +} diff --git a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java index a60bd1e..f55caf1 100644 --- a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java +++ b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java @@ -42,7 +42,7 @@ public class StoreController { private final StoreService storeService; @Operation(summary = "카테고리 별 가게 목록 조회", description = "카테고리 별로 가게 목록을 조회합니다.") - @GetMapping + @GetMapping("/category") public ResponseCustom> searchByCategory( Authentication authentication, @RequestParam(required = false, defaultValue = "3") Integer searchRadius, @@ -94,7 +94,7 @@ public ResponseCustom updateStore(Authentication authentication, @PathV } @Operation(summary = "가게 정보 조회", description = "가게 상세 정보를 조회합니다.") - @GetMapping("/{storeId}") + @GetMapping("") public ResponseCustom getStoreInfo(Authentication authentication) { CustomOAuthUser customOAuth2User = (CustomOAuthUser)authentication.getPrincipal(); return ResponseCustom.OK(storeService.getStoreInfo(customOAuth2User)); @@ -116,4 +116,10 @@ public ResponseCustom getPaymentGroupDetail(Authenti return ResponseCustom.OK( storeService.getPaymentGroupDetail(AuthenticationParser.parseUserId(authentication), teamId, pageable)); } + + @Operation(summary = "결제 내역 조회", description = "가게에서 일어난 결제 내역을 조회합니다.") + @GetMapping("/payment_history") + public ResponseCustom getPaymentHistory(Authentication authentication, Pageable pageable) { + return ResponseCustom.OK(storeService.getPaymentHistory(AuthenticationParser.parseUserId(authentication), pageable)); + } } \ No newline at end of file diff --git a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java index 324e12d..961eaa0 100644 --- a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java +++ b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java @@ -14,6 +14,7 @@ import com.jangburich.domain.store.domain.Category; import com.jangburich.domain.store.domain.Store; import com.jangburich.domain.store.domain.StoreAdditionalInfoCreateRequestDTO; +import com.jangburich.domain.store.domain.StoreChargeHistoryResponse; import com.jangburich.domain.store.domain.StoreCreateRequestDTO; import com.jangburich.domain.store.domain.StoreGetResponseDTO; import com.jangburich.domain.store.domain.StoreTeam; @@ -209,6 +210,21 @@ public PaymentGroupDetailResponse getPaymentGroupDetail(String userId, Long team Page chargeHistoryRepositoryAllByTeam = teamChargeHistoryRepository.findAllByTeam( team, pageable); - return PaymentGroupDetailResponse.create(team.getName(), storeTeam.getPoint(), storeTeam.getRemainPoint(), teamLeader, chargeHistoryRepositoryAllByTeam); + return PaymentGroupDetailResponse.create(team.getName(), storeTeam.getPoint(), storeTeam.getRemainPoint(), + teamLeader, chargeHistoryRepositoryAllByTeam); + } + + public Page getPaymentHistory(String userId, Pageable pageable) { + User user = userRepository.findByProviderId(userId) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Owner owner = ownerRepository.findByUser(user) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Store store = storeRepository.findByOwner(owner) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Page historyResponses = teamChargeHistoryRepository.findAllByStore(store, pageable); + return historyResponses; } } diff --git a/src/main/java/com/jangburich/domain/store/exception/StoreNotFoundException.java b/src/main/java/com/jangburich/domain/store/exception/StoreNotFoundException.java new file mode 100644 index 0000000..f9f1380 --- /dev/null +++ b/src/main/java/com/jangburich/domain/store/exception/StoreNotFoundException.java @@ -0,0 +1,7 @@ +package com.jangburich.domain.store.exception; + +public class StoreNotFoundException extends RuntimeException{ + public StoreNotFoundException() { + super("해당 가게를 찾을 수 없습니다."); + } +} From 09334c0ff3f75c4097b3779c7c93774f50d81973 Mon Sep 17 00:00:00 2001 From: HyunWoo9930 Date: Tue, 19 Nov 2024 10:57:25 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix=20:=20menu=20=EA=B4=80=EB=A0=A8=20api?= =?UTF-8?q?=20=EB=B0=98=ED=99=98=20=EA=B0=92=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/controller/MenuController.java | 16 ++++++------ .../store/domain/StoreTeamResponseDTO.java | 10 ++++--- .../domain/controller/StoreController.java | 10 +++---- .../response/PaymentGroupDetailResponse.java | 1 + .../store/domain/service/StoreService.java | 26 ++++++++++--------- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/jangburich/domain/menu/domain/controller/MenuController.java b/src/main/java/com/jangburich/domain/menu/domain/controller/MenuController.java index e2caec3..8250686 100644 --- a/src/main/java/com/jangburich/domain/menu/domain/controller/MenuController.java +++ b/src/main/java/com/jangburich/domain/menu/domain/controller/MenuController.java @@ -2,7 +2,6 @@ import java.util.List; -import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -18,6 +17,7 @@ import com.jangburich.domain.menu.domain.MenuUpdateRequestDTO; import com.jangburich.domain.menu.domain.service.MenuService; import com.jangburich.domain.oauth.domain.CustomOAuthUser; +import com.jangburich.global.payload.Message; import com.jangburich.global.payload.ResponseCustom; import io.swagger.v3.oas.annotations.tags.Tag; @@ -32,31 +32,31 @@ public class MenuController { private final MenuService menuService; @PostMapping("/register") - public ResponseCustom registerMenu(Authentication authentication, + public ResponseCustom registerMenu(Authentication authentication, @RequestBody MenuCreateRequestDTO menuCreateRequestDTO) { CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); menuService.registerMenu(customOAuthUser, menuCreateRequestDTO); - return ResponseCustom.OK("success"); + return ResponseCustom.OK(Message.builder().message("success").build()); } @PatchMapping("/update/{id}") - public ResponseCustom updateMenu(Authentication authentication, @PathVariable Long id, + public ResponseCustom updateMenu(Authentication authentication, @PathVariable Long id, @RequestBody MenuUpdateRequestDTO menuUpdateRequestDTO) { CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); menuService.updateMenu(customOAuthUser, id, menuUpdateRequestDTO); - return ResponseCustom.OK("success"); + return ResponseCustom.OK(Message.builder().message("success").build()); } @DeleteMapping("/{id}") - public ResponseCustom deleteMenu(Authentication authentication, @PathVariable Long id) { + public ResponseCustom deleteMenu(Authentication authentication, @PathVariable Long id) { CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); menuService.deleteMenu(customOAuthUser, id); - return ResponseCustom.OK("success"); + return ResponseCustom.OK(Message.builder().message("success").build()); } @GetMapping("") public ResponseCustom> getMenu(Authentication authentication) { - CustomOAuthUser customOAuthUser = (CustomOAuthUser) authentication.getPrincipal(); + CustomOAuthUser customOAuthUser = (CustomOAuthUser)authentication.getPrincipal(); List menu = menuService.getMenu(customOAuthUser); return ResponseCustom.OK(menu); } diff --git a/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java b/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java index b2be3af..34ecc75 100644 --- a/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java +++ b/src/main/java/com/jangburich/domain/store/domain/StoreTeamResponseDTO.java @@ -1,6 +1,5 @@ package com.jangburich.domain.store.domain; -import com.jangburich.domain.team.domain.Team; import com.querydsl.core.annotations.QueryProjection; import lombok.Builder; @@ -8,18 +7,21 @@ @Builder public record StoreTeamResponseDTO( Long id, - Integer point, + Integer remainPoint, Long teamId, String teamName, + String teamDescription, Long storeId ) { @QueryProjection - public StoreTeamResponseDTO(Long id, Integer point, Long teamId, String teamName, Long storeId) { + public StoreTeamResponseDTO(Long id, Integer remainPoint, Long teamId, String teamName, String teamDescription, + Long storeId) { this.id = id; - this.point = point; + this.remainPoint = remainPoint; this.teamId = teamId; this.teamName = teamName; + this.teamDescription = teamDescription; this.storeId = storeId; } } diff --git a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java index f55caf1..67c21d3 100644 --- a/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java +++ b/src/main/java/com/jangburich/domain/store/domain/controller/StoreController.java @@ -85,11 +85,10 @@ public ResponseCustom createAdditionalInfo(Authentication authenticatio } @Operation(summary = "가게 정보 수정", description = "가게 정보를 수정합니다.") - @PatchMapping("/{storeId}/update") - public ResponseCustom updateStore(Authentication authentication, @PathVariable Long storeId, + @PatchMapping("/update") + public ResponseCustom updateStore(Authentication authentication, @RequestBody StoreUpdateRequestDTO storeUpdateRequestDTO) { - CustomOAuthUser principal = (CustomOAuthUser)authentication.getPrincipal(); - storeService.updateStore(principal, storeId, storeUpdateRequestDTO); + storeService.updateStore(AuthenticationParser.parseUserId(authentication), storeUpdateRequestDTO); return ResponseCustom.OK(Message.builder().message("success").build()); } @@ -120,6 +119,7 @@ public ResponseCustom getPaymentGroupDetail(Authenti @Operation(summary = "결제 내역 조회", description = "가게에서 일어난 결제 내역을 조회합니다.") @GetMapping("/payment_history") public ResponseCustom getPaymentHistory(Authentication authentication, Pageable pageable) { - return ResponseCustom.OK(storeService.getPaymentHistory(AuthenticationParser.parseUserId(authentication), pageable)); + return ResponseCustom.OK( + storeService.getPaymentHistory(AuthenticationParser.parseUserId(authentication), pageable)); } } \ No newline at end of file diff --git a/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java b/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java index 4b3e0e2..20bdd5d 100644 --- a/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java +++ b/src/main/java/com/jangburich/domain/store/domain/dto/response/PaymentGroupDetailResponse.java @@ -18,6 +18,7 @@ public class PaymentGroupDetailResponse { private Integer remainPoint; private String teamLeaderName; private String teamLeaderPhoneNum; + // TODO 이거 아니고, order 결제 내역으로 변경해야함. private Page historyResponses; public static PaymentGroupDetailResponse create(String teamName, Integer point, Integer remainPoint, diff --git a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java index 961eaa0..58b9b41 100644 --- a/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java +++ b/src/main/java/com/jangburich/domain/store/domain/service/StoreService.java @@ -79,11 +79,17 @@ public void createAdditionalInfo(CustomOAuthUser customOAuthUser, } @Transactional - public void updateStore(CustomOAuthUser customOAuth2User, Long storeId, - StoreUpdateRequestDTO storeUpdateRequestDTO) { - Store store = storeRepository.findById(storeId) - .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_STORE_ID)); - if (!store.getOwner().getUser().getProviderId().equals(customOAuth2User.getUserId())) { + public void updateStore(String userId, StoreUpdateRequestDTO storeUpdateRequestDTO) { + User user = userRepository.findByProviderId(userId) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Owner owner = ownerRepository.findByUser(user) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + Store store = storeRepository.findByOwner(owner) + .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); + + if (!store.getOwner().getUser().getProviderId().equals(userId)) { throw new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION); } @@ -167,11 +173,8 @@ public Page getPaymentGroup(String userId, Pageable pageab return storeTeamRepository.findAllByStore(store, pageable); } - public Page searchByCategory(final Authentication authentication, - final Integer searchRadius, - final Category category, - final StoreSearchCondition storeSearchCondition, - final Pageable pageable) { + public Page searchByCategory(final Authentication authentication, final Integer searchRadius, + final Category category, final StoreSearchCondition storeSearchCondition, final Pageable pageable) { String parsed = AuthenticationParser.parseUserId(authentication); User user = userRepository.findByProviderId(parsed) .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION)); @@ -180,8 +183,7 @@ public Page searchByCategory(final Authentication authenti } public Page searchStores(final Authentication authentication, final String keyword, - final StoreSearchConditionWithType storeSearchConditionWithType, - final Pageable pageable) { + final StoreSearchConditionWithType storeSearchConditionWithType, final Pageable pageable) { String parsed = AuthenticationParser.parseUserId(authentication); User user = userRepository.findByProviderId(parsed) .orElseThrow(() -> new DefaultNullPointerException(ErrorCode.INVALID_AUTHENTICATION));