-
Notifications
You must be signed in to change notification settings - Fork 4
Feature/정산기능구현 #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Feature/정산기능구현 #67
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
547376c
chore: payment build 에 reservation 추가
soohoioa 60c1249
chore: payment build 에 reservation 추가
soohoioa 1a6da55
chore: payment build 에 reservation 추가
soohoioa cf2428f
chore: payment build 에 reservation 추가
soohoioa fff4dc7
feat : 정산 기능 구현
soohoioa 81aa006
hotfix: conflict branch
soohoioa 10e96d0
Merge remote-tracking branch 'origin/feature/39-payment-ing' into fea…
soohoioa c0b0a83
refactor: payment service 추가
soohoioa 6a2a429
refactor: payment service 추가
soohoioa 16ff474
refactor: import 수정, 어노테이션 변경
soohoioa e10ee58
test: payment, settlement 테스트코드추가
soohoioa 00a6088
Merge branch 'dev' into feature/39-payment-ing
soohoioa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
admin/src/main/java/com/homeaid/serviceoption/controller/AdminSettlementController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.homeaid.serviceoption.controller; | ||
|
|
||
| import com.homeaid.service.SettlementService; | ||
| import java.time.LocalDate; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.format.annotation.DateTimeFormat; | ||
| import org.springframework.format.annotation.DateTimeFormat.ISO; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RequestParam; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| //@RequestMapping("/api/admin/settlement") | ||
| @RequestMapping("/api/admin") | ||
| public class AdminSettlementController { | ||
| private final SettlementService settlementService; | ||
|
|
||
| // 매니저별 정산 요청 API | ||
| @PostMapping("/manager") | ||
| public ResponseEntity<Void> createManagerSettlement( | ||
| @RequestParam Long managerId, | ||
| @RequestParam @DateTimeFormat(iso = ISO.DATE) LocalDate weekStart, | ||
| @RequestParam @DateTimeFormat(iso = ISO.DATE) LocalDate weekEnd | ||
| ) { | ||
| settlementService.createWeeklySettlementForManager(managerId, weekStart, weekEnd); | ||
| return ResponseEntity.ok().build(); | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
global/src/main/java/com/homeaid/config/web/WebConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.homeaid.config.web; | ||
|
|
||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
|
||
| @Configuration | ||
| public class WebConfig { | ||
| @Bean | ||
| public WebMvcConfigurer corsConfigurer() { | ||
| return new WebMvcConfigurer() { | ||
| @Override | ||
| public void addCorsMappings(CorsRegistry registry) { | ||
| registry.addMapping("/api/**") | ||
| .allowedOrigins("http://localhost:3000") | ||
| .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") | ||
| .allowCredentials(true); | ||
| } | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
payment/src/main/java/com/homeaid/controller/PaymentController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.homeaid.controller; | ||
|
|
||
| import com.homeaid.common.response.CommonApiResponse; | ||
| import com.homeaid.dto.request.PaymentRequestDto; | ||
| import com.homeaid.dto.response.PaymentResponseDto; | ||
| import com.homeaid.service.PaymentService; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.parameters.RequestBody; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v1/payments") | ||
| @RequiredArgsConstructor | ||
| public class PaymentController { | ||
|
|
||
| private final PaymentService paymentService; | ||
|
|
||
| @PostMapping | ||
| @Operation(summary = "결제 성공", responses = { | ||
| @ApiResponse(responseCode = "201", description = "결제 성공", | ||
| content = @Content(schema = @Schema(implementation = PaymentResponseDto.class))), | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 실패 했을 경우도 있으면 좋을 것 같아요! |
||
| @ApiResponse(responseCode = "404", description = "결제 실패", | ||
| content = @Content(schema = @Schema(implementation = CommonApiResponse.class))) | ||
| }) | ||
| public ResponseEntity<PaymentResponseDto> pay(@Valid @RequestBody PaymentRequestDto requestDto) { | ||
| PaymentResponseDto response = paymentService.pay(requestDto); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body(response); | ||
| } | ||
|
|
||
| } | ||
81 changes: 81 additions & 0 deletions
81
payment/src/main/java/com/homeaid/controller/SettlementController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package com.homeaid.controller; | ||
|
|
||
| import com.homeaid.common.response.CommonApiResponse; | ||
| import com.homeaid.domain.Settlement; | ||
| import com.homeaid.dto.request.SettlementRequestDto; | ||
| import com.homeaid.dto.response.SettlementResponseDto; | ||
| import com.homeaid.service.SettlementService; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.media.Content; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
| import jakarta.validation.Valid; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v1/settlements") | ||
| @RequiredArgsConstructor | ||
| public class SettlementController { | ||
|
|
||
| private final SettlementService settlementService; | ||
|
|
||
| @PostMapping("/manager/{managerId}") | ||
| @Operation(summary = "정산 ", responses = { | ||
| @ApiResponse(responseCode = "201", description = "정산", | ||
| content = @Content(schema = @Schema(implementation = SettlementResponseDto.class))), | ||
| @ApiResponse(responseCode = "404", description = "정산 실패", | ||
| content = @Content(schema = @Schema(implementation = CommonApiResponse.class))) | ||
| }) | ||
| public ResponseEntity<SettlementResponseDto> calcAndSaveForManager( | ||
| @Valid @RequestBody SettlementRequestDto dto | ||
| ) { | ||
| SettlementResponseDto response = settlementService.createWeeklySettlementForManager(dto.getManagerId(), dto.getFrom(), dto.getTo()); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body(response); | ||
| } | ||
|
|
||
| @GetMapping("/list") | ||
| @Operation(summary = "정산 전체 내역 조회", responses = { | ||
| @ApiResponse(responseCode = "200", description = "정산 전체 내역 조회 성공", | ||
| content = @Content(schema = @Schema(implementation = SettlementResponseDto.class))) | ||
| }) | ||
| public ResponseEntity<List<SettlementResponseDto>> getAllSettlements() { | ||
| List<Settlement> settlements = settlementService.findAll(); | ||
| List<SettlementResponseDto> response = settlements.stream() | ||
| .map(SettlementResponseDto::from) | ||
| .toList(); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @GetMapping("/{settlementId}") | ||
| @Operation(summary = "정산 단건 조회", responses = { | ||
| @ApiResponse(responseCode = "200", description = "정산 단건 조회 성공", | ||
| content = @Content(schema = @Schema(implementation = SettlementResponseDto.class))) | ||
| }) | ||
| public ResponseEntity<SettlementResponseDto> getSettlementById(@PathVariable Long settlementId) { | ||
| Settlement settlement = settlementService.findById(settlementId); | ||
| return ResponseEntity.ok(SettlementResponseDto.from(settlement)); | ||
| } | ||
|
|
||
| @GetMapping("/manager/{managerId}/list") | ||
| @Operation(summary = "매니저 정산내역 전체 조회", responses = { | ||
| @ApiResponse(responseCode = "200", description = "매니저 정산내역 전체 조회 성공", | ||
| content = @Content(schema = @Schema(implementation = SettlementResponseDto.class))) | ||
| }) | ||
| public ResponseEntity<List<SettlementResponseDto>> getSettlementsByManager(@PathVariable Long managerId) { | ||
| List<Settlement> settlements = settlementService.findByManagerId(managerId); | ||
| List<SettlementResponseDto> response = settlements.stream() | ||
| .map(SettlementResponseDto::from) | ||
| .toList(); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package com.homeaid.domain; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EntityListeners; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.Table; | ||
| import java.time.LocalDateTime; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| @Entity | ||
| @Table(name = "payment") | ||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| public class Payment { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| private Integer amount; // 결제 금액 | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private PaymentMethod paymentMethod; | ||
|
|
||
| @Enumerated(EnumType.STRING) | ||
| private PaymentStatus status; | ||
|
|
||
| @CreatedDate | ||
| @Column(updatable = false, nullable = false) | ||
| private LocalDateTime paidAt; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "reservation_id") | ||
| private Reservation reservation; | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.homeaid.domain; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public enum PaymentMethod { | ||
| CARD, TRANSFER, CASH; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.homeaid.domain; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public enum PaymentStatus { | ||
| PAID, CANCELED, REFUNDED | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package com.homeaid.domain; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EntityListeners; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Table; | ||
| import java.time.LocalDate; | ||
| import java.time.LocalDateTime; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| @Table(name = "settlement") | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| public class Settlement { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false) | ||
| private Integer totalAmount; | ||
|
|
||
| @Column(nullable = false) | ||
| private Integer managerSettlementPrice; | ||
|
|
||
| @Column(nullable = false) | ||
| private LocalDate settlementWeekStart; | ||
|
|
||
| @Column(nullable = false) | ||
| private LocalDate settlementWeekEnd; | ||
|
|
||
| @CreatedDate | ||
| @Column(updatable = false, nullable = false) | ||
| private LocalDateTime settledAt; | ||
|
|
||
| @Column(nullable = false) | ||
| private Long managerId; | ||
|
|
||
| } |
27 changes: 27 additions & 0 deletions
27
payment/src/main/java/com/homeaid/dto/request/PaymentRequestDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.homeaid.dto.request; | ||
|
|
||
| import com.homeaid.domain.PaymentMethod; | ||
| import com.homeaid.domain.PaymentStatus; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class PaymentRequestDto { | ||
|
|
||
| @NotNull(message = "예약ID는 null이면 안됩니다!") | ||
| private Long reservationId; | ||
|
|
||
| @NotNull(message = "금액은 null이면 안됩니다!") | ||
| private Integer amount; | ||
|
|
||
| @NotNull(message = "결제수단은 null이면 안됩니다!") | ||
| private PaymentMethod paymentMethod; | ||
|
|
||
| private PaymentStatus status; | ||
| } |
15 changes: 15 additions & 0 deletions
15
payment/src/main/java/com/homeaid/dto/request/SettlementRequestDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.homeaid.dto.request; | ||
|
|
||
| import java.time.LocalDate; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @Builder | ||
| public class SettlementRequestDto { | ||
|
|
||
| private Long managerId; | ||
| private LocalDate from; // 시작일 (예: 월요일) | ||
| private LocalDate to; // 종료일 (예: 수요일, 일요일 등) | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PaymentService 코드는 Service 패키지에 없는데 누락된 것 같습니다