Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/week10' into week10
Browse files Browse the repository at this point in the history
  • Loading branch information
amm0124 committed Nov 11, 2024
2 parents 80b61a6 + 0362e8c commit abfa51a
Show file tree
Hide file tree
Showing 60 changed files with 1,584 additions and 920 deletions.
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 받아서 해야 함---------//





}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

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) {
}
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) {
}
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) {
}
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) {
}
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) {
}
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) {
}
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 필드
) {
}
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) {
}
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) {
}
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
) {
}
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) {
}
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
) {
}


This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package poomasi.domain.order._aftersales.entity._farm;

import poomasi.domain.order._aftersales.entity._abstract.AbstractAfterSales;

public class FarmAfterSales extends AbstractAfterSales {

public class FarmAfterSales {
}

This file was deleted.

Loading

0 comments on commit abfa51a

Please sign in to comment.