-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from kakao-tech-campus-2nd-step3/feature/ISSU…
…E-111 111번 다시 merge
- Loading branch information
Showing
72 changed files
with
2,069 additions
and
740 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
80 changes: 80 additions & 0 deletions
80
src/main/java/poomasi/domain/order/_aftersales/controller/AfterSalesController.java
This file contains 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,80 @@ | ||
package poomasi.domain.order._aftersales.controller; | ||
|
||
|
||
import com.siot.IamportRestClient.exception.IamportResponseException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.access.annotation.Secured; | ||
import org.springframework.web.bind.annotation.*; | ||
import poomasi.domain.order._aftersales.dto.cancel.request.FarmCancelRequest; | ||
import poomasi.domain.order._aftersales.dto.cancel.request.ProductCancelRequest; | ||
import poomasi.domain.order._aftersales.dto.refund.request.ProductRefundRequest; | ||
import poomasi.domain.order._aftersales.dto.refund.request.ProductRefundRequestApprovalRequest; | ||
import poomasi.domain.order._aftersales.dto.refund.request.ProductRefundRequestDeniedRequest; | ||
import poomasi.domain.order._aftersales.service.FarmAfterSalesService; | ||
import poomasi.domain.order._aftersales.service.ProductAfterSalesService; | ||
|
||
import java.io.IOException; | ||
|
||
@RestController | ||
@RequestMapping("/api/aftersales") | ||
@RequiredArgsConstructor | ||
public class AfterSalesController { | ||
|
||
private final ProductAfterSalesService productAfterSalesService; | ||
private final FarmAfterSalesService farmAfterSalesService; | ||
|
||
//-------------------------product cancel---------------------// | ||
@Secured({"ROLE_CUSTOMER", "ROLE_FARMER"}) | ||
@PostMapping("/product/cancel") | ||
public ResponseEntity<?> productCancel(@RequestBody ProductCancelRequest productCancelRequest) throws IOException, IamportResponseException { | ||
return ResponseEntity.ok( | ||
productAfterSalesService.cancel(productCancelRequest) | ||
); | ||
} | ||
|
||
//-------------------------product refund---------------------// | ||
@Secured({"ROLE_CUSTOMER", "ROLE_FARMER"}) | ||
@PostMapping("/refund-request") | ||
public ResponseEntity<?> requestRefund(@RequestBody ProductRefundRequest productRefundRequest) { | ||
return ResponseEntity.ok( | ||
productAfterSalesService. | ||
createRefundRequest(productRefundRequest) | ||
); | ||
} | ||
|
||
@Secured({"ROLE_FARMER"}) | ||
@PostMapping("/approve-refund-request") | ||
public ResponseEntity<?> approveRefundRequest(@RequestBody ProductRefundRequestApprovalRequest productRefundRequestApprovalRequest) throws IOException, IamportResponseException { | ||
return ResponseEntity.ok( | ||
productAfterSalesService.processRefundApproval(productRefundRequestApprovalRequest) | ||
); | ||
} | ||
|
||
|
||
@Secured({"ROLE_FARMER"}) | ||
@PostMapping("/deniedrefund-request") | ||
public ResponseEntity<?> deniedRefundRequest(@RequestBody ProductRefundRequestDeniedRequest productRefundRequestDeniedRequest) { | ||
return ResponseEntity.ok( | ||
productAfterSalesService.processRefundDenied(productRefundRequestDeniedRequest) | ||
); | ||
} | ||
|
||
|
||
//-------------------------farm cancel---------------------// | ||
@Secured({"ROLE_CUSTOMER", "ROLE_FARMER"}) | ||
@PostMapping("/farm/cancel") | ||
public ResponseEntity<?> farmCancel(@RequestBody FarmCancelRequest farmCancelRequest) throws IOException, IamportResponseException { | ||
return ResponseEntity.ok( | ||
farmAfterSalesService.farmCancel(farmCancelRequest) | ||
); | ||
} | ||
|
||
|
||
//------------웹훅 api 받아서 해야 함---------// | ||
|
||
|
||
|
||
|
||
|
||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/poomasi/domain/order/_aftersales/dto/cancel/request/FarmCancelRequest.java
This file contains 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,4 @@ | ||
package poomasi.domain.order._aftersales.dto.cancel.request; | ||
|
||
public record FarmCancelRequest(Long reservationId) { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/poomasi/domain/order/_aftersales/dto/cancel/request/ProductCancelRequest.java
This file contains 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,4 @@ | ||
package poomasi.domain.order._aftersales.dto.cancel.request; | ||
|
||
public record ProductCancelRequest(Long orderedProductId, Integer cancelRequestQuantity, String cancelReason) { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/poomasi/domain/order/_aftersales/dto/cancel/response/FarmCancelResponse.java
This file contains 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,4 @@ | ||
package poomasi.domain.order._aftersales.dto.cancel.response; | ||
|
||
public record FarmCancelResponse(Long reservationId, String status) { | ||
} |
16 changes: 16 additions & 0 deletions
16
...main/java/poomasi/domain/order/_aftersales/dto/cancel/response/ProductCancelResponse.java
This file contains 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,16 @@ | ||
package poomasi.domain.order._aftersales.dto.cancel.response; | ||
|
||
import poomasi.domain.order._aftersales.entity._product.ProductAfterSalesStatus; | ||
import poomasi.domain.order.entity._product.OrderedProductStatus; | ||
|
||
import java.math.BigDecimal; | ||
|
||
public record ProductCancelResponse( | ||
Long orderedProductId, | ||
OrderedProductStatus orderedProductStatus, | ||
|
||
Long productAfterSalesDetailId, | ||
Integer cancelQuantity, | ||
ProductAfterSalesStatus productAfterSalesStatus, | ||
BigDecimal finalCancelAmount) { | ||
} |
4 changes: 4 additions & 0 deletions
4
...in/java/poomasi/domain/order/_aftersales/dto/exchange/request/ProductExchangeRequest.java
This file contains 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,4 @@ | ||
package poomasi.domain.order._aftersales.dto.exchange.request; | ||
|
||
public record ProductExchangeRequest(Long orderedProductId, String exchangeReason) { | ||
} |
4 changes: 4 additions & 0 deletions
4
.../java/poomasi/domain/order/_aftersales/dto/exchange/response/ProductExchangeResponse.java
This file contains 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,4 @@ | ||
package poomasi.domain.order._aftersales.dto.exchange.response; | ||
|
||
public record ProductExchangeResponse(Long orderedProductId, String message) { | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/poomasi/domain/order/_aftersales/dto/refund/request/ProductRefundRequest.java
This file contains 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,13 @@ | ||
package poomasi.domain.order._aftersales.dto.refund.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record ProductRefundRequest( | ||
@NotNull Long orderedProductId, // 필수 필드 | ||
@Positive Integer refundRequestQuantity, //필수 | ||
@Size(max = 500) String refundReason, // 필수 필드 | ||
@Size(max = 20) String request // nullable 필드 | ||
) { | ||
} |
5 changes: 5 additions & 0 deletions
5
...masi/domain/order/_aftersales/dto/refund/request/ProductRefundRequestApprovalRequest.java
This file contains 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,5 @@ | ||
package poomasi.domain.order._aftersales.dto.refund.request; | ||
|
||
public record ProductRefundRequestApprovalRequest(Long productAfterSalesDetailId, | ||
String invoiceNumber) { | ||
} |
5 changes: 5 additions & 0 deletions
5
...oomasi/domain/order/_aftersales/dto/refund/request/ProductRefundRequestDeniedRequest.java
This file contains 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,5 @@ | ||
package poomasi.domain.order._aftersales.dto.refund.request; | ||
|
||
public record ProductRefundRequestDeniedRequest(Long productAfterSalesDetailId, | ||
String refundDeinedReason) { | ||
} |
12 changes: 12 additions & 0 deletions
12
...si/domain/order/_aftersales/dto/refund/response/ProductRefundRequestApprovalResponse.java
This file contains 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,12 @@ | ||
package poomasi.domain.order._aftersales.dto.refund.response; | ||
|
||
import java.math.BigDecimal; | ||
|
||
public record ProductRefundRequestApprovalResponse( | ||
Long orderedProductId, | ||
Integer count, | ||
BigDecimal refundAmount, | ||
Long productAfterSalesDetailId, | ||
String invoiceNumber | ||
) { | ||
} |
8 changes: 8 additions & 0 deletions
8
...masi/domain/order/_aftersales/dto/refund/response/ProductRefundRequestDeniedResponse.java
This file contains 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 poomasi.domain.order._aftersales.dto.refund.response; | ||
|
||
import poomasi.domain.order._aftersales.entity._product.ProductAfterSalesStatus; | ||
|
||
public record ProductRefundRequestDeniedResponse(Long productAfterSalesDetailId, | ||
ProductAfterSalesStatus productAfterSalesStatus, | ||
String productRefundDeniedReason) { | ||
} |
19 changes: 19 additions & 0 deletions
19
...va/poomasi/domain/order/_aftersales/dto/refund/response/ProductRefundRequestResponse.java
This file contains 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,19 @@ | ||
package poomasi.domain.order._aftersales.dto.refund.response; | ||
|
||
import poomasi.domain.order._aftersales.entity._product.ProductAfterSalesStatus; | ||
import poomasi.domain.order.entity._product.OrderedProductStatus; | ||
|
||
import java.math.BigDecimal; | ||
|
||
public record ProductRefundRequestResponse( | ||
Long orderedProductId, | ||
OrderedProductStatus orderedProductStatus, | ||
|
||
Long productAfterSalesDetailId, | ||
Integer refundQuantity, | ||
ProductAfterSalesStatus productAfterSalesTypem, | ||
BigDecimal finalRefundAmount | ||
) { | ||
} | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
src/main/java/poomasi/domain/order/_aftersales/entity/_farm/FarmAfterSales.java
This file contains 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,6 @@ | ||
package poomasi.domain.order._aftersales.entity._farm; | ||
|
||
|
||
|
||
public class FarmAfterSales { | ||
} |
101 changes: 101 additions & 0 deletions
101
src/main/java/poomasi/domain/order/_aftersales/entity/_product/ProductAfterSalesDetail.java
This file contains 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,101 @@ | ||
package poomasi.domain.order._aftersales.entity._product; | ||
|
||
import jakarta.persistence.*; | ||
import jdk.jfr.Description; | ||
import jdk.jfr.Timestamp; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
import org.hibernate.annotations.UpdateTimestamp; | ||
import poomasi.domain.order.entity._product.OrderedProduct; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDateTime; | ||
|
||
@Description("상품 판매 후 교환/환불/추소 history") | ||
@Entity | ||
@Getter | ||
@Table(name="product_after_sales_detail") | ||
@NoArgsConstructor | ||
public class ProductAfterSalesDetail { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(name = "created_at") | ||
@CreationTimestamp | ||
private LocalDateTime createdAt = LocalDateTime.now(); | ||
|
||
@Column(name = "updated_at") | ||
@UpdateTimestamp | ||
private LocalDateTime updateAt = LocalDateTime.now(); | ||
|
||
@Column(name = "deleted_at") | ||
@Timestamp | ||
private LocalDateTime deletedAt; | ||
|
||
@ManyToOne | ||
private OrderedProduct orderedProduct; | ||
|
||
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) | ||
@JoinColumn(name = "product_refund_detail_id", nullable = true) // 외래 키 설정 | ||
private ProductRefundDetail productRefundDetail; | ||
|
||
//TODO : payment에 있는 것을 변경해야 함 | ||
private String impUid; | ||
|
||
@Description("환불/교환/취소 금액") | ||
private BigDecimal adjustAmount; | ||
|
||
@Description("취소/교환/환불 수량") | ||
private Integer adjustmentQuantity; | ||
|
||
@Description("환불/교환/취소 요청 사유") | ||
private String reason; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private ProductAfterSalesStatus productAfterSalesStatus; | ||
|
||
@Builder | ||
public ProductAfterSalesDetail(OrderedProduct orderedProduct, | ||
BigDecimal adjustAmount, | ||
String reason, | ||
Integer adjustmentQuantity, | ||
ProductAfterSalesStatus productAfterSalesStatus) { | ||
this.orderedProduct = orderedProduct; | ||
this.adjustAmount = adjustAmount; | ||
this.reason = reason; | ||
this.adjustmentQuantity = adjustmentQuantity; | ||
this.productAfterSalesStatus = productAfterSalesStatus; | ||
} | ||
|
||
public void setOrderedProduct(OrderedProduct orderedProduct) { | ||
this.orderedProduct = orderedProduct; | ||
} | ||
|
||
public void setProductAfterSalesStatus(ProductAfterSalesStatus productAfterSalesStatus){ | ||
this.productAfterSalesStatus = productAfterSalesStatus; | ||
} | ||
|
||
public String getProductRefundDeniedReason(){ | ||
return this.productRefundDetail.getProductRefundDeniedReason(); | ||
} | ||
|
||
public void setProductRefundDeniedReason(String productRefundDeniedReason){ | ||
this.productRefundDetail.setProductRefundDeniedReason(productRefundDeniedReason); | ||
} | ||
|
||
public void setProductRefundDetail(ProductRefundDetail productRefundDetail) { | ||
this.productRefundDetail = productRefundDetail; | ||
productRefundDetail.setProductAfterSalesDetail(this); | ||
} | ||
|
||
public void changeRefundApproveStatus(String invoiceNumber){ | ||
this.productAfterSalesStatus = ProductAfterSalesStatus.REFUND_APPROVED; | ||
this.productRefundDetail.setInvoiceNumber(invoiceNumber); | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.