Skip to content

Commit

Permalink
Merge pull request #110 from kakao-tech-campus-2nd-step3/feature/ISSU…
Browse files Browse the repository at this point in the history
…E-86

결제 order entity 수정 및 결제 구현
  • Loading branch information
amm0124 authored Nov 11, 2024
2 parents 4e8322e + 74a05a8 commit c57c2d7
Show file tree
Hide file tree
Showing 55 changed files with 1,052 additions and 387 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.3.1'
id 'io.spring.dependency-management' version '1.1.5'
id 'com.apollographql.apollo3' version '4.0.0-beta.7'

}

group = 'camp.nextstep.edu'
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/poomasi/domain/auth/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class SecurityConfig {
private final CustomSuccessHandler customSuccessHandler;
private final UserDetailsServiceImpl userDetailsService;


@Autowired
private OAuth2UserDetailServiceImpl oAuth2UserDetailServiceImpl;

Expand Down Expand Up @@ -74,7 +73,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti

// 기본 경로 및 테스트 경로
http.authorizeHttpRequests((authorize) -> authorize
.requestMatchers(HttpMethod.GET, "/api/farm/**").permitAll()
.requestMatchers(HttpMethod.POST, "/api/farm/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/product/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/review/**").permitAll()
.requestMatchers(HttpMethod.GET, "/health").permitAll()
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/poomasi/domain/farm/entity/Farm.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.time.LocalDateTime;

import poomasi.domain.order.entity._farm.OrderedFarm;
import poomasi.domain.review.entity.Review;

@Entity
Expand Down Expand Up @@ -77,7 +78,11 @@ public class Farm {

@OneToMany(cascade = CascadeType.REMOVE, orphanRemoval = true)
@JoinColumn(name = "entityId")
List<Review> reviewList = new ArrayList<>();
private List<Review> reviewList = new ArrayList<>();

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ordered_farm_id")
private OrderedFarm orderedFarm;

@Builder
public Farm(Long id, String name, Long ownerId, String address, String addressDetail, Double latitude, Double longitude, String description, int experiencePrice, Integer maxCapacity, Integer maxReservation) {
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/poomasi/domain/member/entity/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.SQLDelete;
import poomasi.domain.order.entity.Order;
import poomasi.domain.store.entity.Store;
import poomasi.domain.member._profile.entity.MemberProfile;
import poomasi.domain.store.entity.Store;
import poomasi.domain.order.entity._product.ProductOrder;
import poomasi.domain.store.entity.Store;
import poomasi.domain.member._profile.entity.MemberProfile;
import poomasi.domain.store.entity.Store;
Expand Down Expand Up @@ -59,7 +62,7 @@ public class Member {
private LocalDateTime deletedAt;

@OneToMany(mappedBy = "member", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Order> orderLists;
private List<ProductOrder> productOrderLists;

@Setter
@Column(nullable = true)
Expand All @@ -77,6 +80,11 @@ public Member(String name, String email, String password, LoginType loginType, R
this.role = role;
}

public Member(String email, Role role) {
this.email = email;
this.role = role;
}

public void setMemberProfile(MemberProfile memberProfile) {
this.memberProfile = memberProfile;
if (memberProfile != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package poomasi.domain.order._aftersales.controller;


import org.springframework.web.bind.annotation.RestController;

@RestController
public class CancelController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package poomasi.domain.order._aftersales.controller;


import org.springframework.web.bind.annotation.RestController;

@RestController
public class ExchangeController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package poomasi.domain.order._aftersales.controller;


import lombok.RequiredArgsConstructor;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.*;
import poomasi.domain.order._aftersales.dto.FullRefundRequest;
import poomasi.domain.order._aftersales.dto.PartialRefundRequest;
import poomasi.domain.order._aftersales.service.RefundService;

@RestController
@RequestMapping("/api/refund")
@RequiredArgsConstructor
public class RefundController {

private final RefundService refundService;


@Secured({"ROLE_CUSTOMER", "ROLE_FARMER"})
@GetMapping("/{refundId}")
public void getRefund(@PathVariable("refundId") Long refundId) {

}

@Secured({"ROLE_CUSTOMER", "ROLE_FARMER"})
@PostMapping("/{orderProductDetailsId}")
public void processFullRefund (@PathVariable("orderProductDetailsId") Long orderProductDetailsId,
@RequestBody FullRefundRequest fullRefundRequest) {
//TODO : order product details 내부 메서드 보고
//TODO : 환불 가능하지 받아 와야 함
}


@Secured({"ROLE_CUSTOMER", "ROLE_FARMER"})
@PostMapping("/api/refund/{orderProductDetailsId}")
public void processPartialRefund (@PathVariable("orderProductDetailsId") Long orderProductDetailsId,
@RequestBody PartialRefundRequest partialRefundRequest) {



}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package poomasi.domain.order._aftersales.dto;

public record FullRefundRequest(
String refundReason
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package poomasi.domain.order._aftersales.dto;

import java.math.BigDecimal;

public record PartialRefundRequest(
BigDecimal refundAmount, // type check 필요
String refundReason
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package poomasi.domain.order._aftersales.entity._abstract;

import jakarta.persistence.*;
import jdk.jfr.Timestamp;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

@MappedSuperclass
public abstract class AbstractAfterSales {

@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;

}

/*
* package poomasi.domain.order._aftersales.entity;
import jakarta.persistence.*;
import jdk.jfr.Description;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import poomasi.domain.order._payment.entity.Payment;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Entity
@Table(name="refund_history")
public class Refund {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@CreationTimestamp
@Column(name = "created_at")
private LocalDateTime createdAt = LocalDateTime.now();
@Column(name = "updated_at")
@UpdateTimestamp
private LocalDateTime updatedAt = LocalDateTime.now();
@Description("삭제 시간")
private LocalDateTime deletedAt;
@ManyToOne(fetch = FetchType.LAZY)
private Payment payment;
private BigDecimal refundAmount;
@OneToOne(fetch = FetchType.LAZY)
private OrderedProduct orderProductDetails;
private String refundReason;
}
*
* */

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

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

public class FarmAfterSales extends AbstractAfterSales {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package poomasi.domain.order._aftersales.entity._product;

import jakarta.persistence.*;
import poomasi.domain.order._aftersales.entity._abstract.AbstractAfterSales;
import poomasi.domain.order.entity._product.ProductOrder;

import java.util.List;

@Entity
@Table(name="product_after_sales")
public class ProductAfterSales extends AbstractAfterSales {

@OneToOne
@JoinColumn(name = "product_order_id")
private ProductOrder productOrder;

@OneToMany
private List<ProductAfterSalesDetail> productAfterSalesDetail;

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package poomasi.domain.order._aftersales.entity._product;

import jakarta.persistence.*;
import jdk.jfr.Description;
import poomasi.domain.order.entity._product.OrderedProduct;

import java.math.BigDecimal;

@Description("상품 판매 후 교환/환불/추소 history")
@Entity
@Table(name="product_after_sales_detail")
public class ProductAfterSalesDetail {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne
private ProductAfterSales productAfterSales;

@OneToOne
private OrderedProduct orderedProduct;


@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name = "refund_exchange_detail_id", nullable = true) // 외래 키 설정
private RefundExchangeDetail refundExchangeDetail;

@Description("ordered products의 환불/교환/취소 금액")
private BigDecimal amount;

@Description("환불/교환/취소 사유")
private String reason;

@Description("환불 받을 계좌번호")
private String refundAccount;

@Enumerated(EnumType.STRING)
private ProductAfterSalesType productAfterSalesType;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package poomasi.domain.order._aftersales.entity._product;

public enum ProductAfterSalesType {
EXCHANGE,
CANCEL,
REFUND
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package poomasi.domain.order._aftersales.entity._product;


import jakarta.persistence.*;
import jdk.jfr.Description;

@Entity
@Table(name= "refund_exchange_detail")
public class RefundExchangeDetail {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToOne(mappedBy = "refundExchangeDetail") // 주인이 아닌 쪽에 mappedBy 설정
private ProductAfterSalesDetail productAfterSalesDetail;

@Description("반품 회수지. 기본 값은 보낸 주소")
private String pickupLocation;

@Description("반송지. 기본 값은 받은 주소")
private String returnAddress;

@Description("반품/교환 시 운송장 번호")
private String invoiceNumber;

@Description("반품/교환 시 요청 사항")
private String request;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package poomasi.domain.order._aftersales.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import poomasi.domain.order._aftersales.entity._product.ProductAfterSales;

public interface ProductAfterSalesRepository extends JpaRepository<ProductAfterSales, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package poomasi.domain.order._aftersales.service;


import com.siot.IamportRestClient.IamportClient;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import poomasi.domain.order._aftersales.repository.ProductAfterSalesRepository;

@Service
@RequiredArgsConstructor
public class RefundService {

private final ProductAfterSalesRepository productAfterSalesRepository;
private final IamportClient iamportClient;


/* public void refundFull(){
iamportClient.
}*/


}
Loading

0 comments on commit c57c2d7

Please sign in to comment.