2025. 4. 1. 23:57ㆍ향해99 8기
시퀀스 다이어그램
1. 잔액 충전 요청 및 이력 저장
요구사항 1번 잔액 충전 (식별자는 요청 본문에 포함)

2. [GET] /api/v1/points?userId={userId} : 잔액 조회 요청 및 결과 반환
요구사항 1번 잔액 조회

3. [GET] /api/v1/products : 상품 조회 요청 및 결과 반환
요구사항 2번 상품 조회 (ID, 이름, 가격, 잔여수량)

4. [POST] /api/v1/coupons/issue : 선착순 쿠폰 발급 처리 및 결과 반환
요구사항 3번 선착순 쿠폰 기능

5. [GET] /api/v1/coupons?userId={userId} : 보유 쿠폰 목록 조회
요구사항 3번 ㅡ> 선착순 쿠폰 발급 후 사용자가 발급받은 쿠폰 목록 조회 기능

6. [POST] /api/v1/orders : 주문 생성 및 재고/쿠폰 처리
요구사항 4번 주문 (사용자 식별자, 상품 ID, 수량)
재고가 충분할때 Order에서 Product로
재고 차감을 요청해야하는 것이 아닌가???
ㅡ> 주문 시에 재고 차감

7. [POST] /api/v1/points/use : 포인트 결제 처리 및 주문 상태 업데이트
요구사항 4번 결제 (결제 성공시 -> 실시간으로 주문 정보를 데이터 플랫폼에 전송)

8. 결제 실패 후 주문 상태 EXPIRED 처리 및 쿠폰 사용 취소
요구사항 4번 ㅡ> 결제 취소시 처리

9. 주문 완료된 상품 조회 및 일별 주문량 저장
요구사항 5번 ㅡ> 판매량 상위 5개 상품을 계산하는 데 필요한 통계 정보를 준비

10. [GET] /api/v1/products/best : 판매량 상위 5개 상품 조회
요구사항 5번 상위 상품 조회 API (통계 정보)

ERD
ERD 초기 시안
플랫폼 : https://excalidraw.com/

플랫폼 : https://dbdiagram.io/d

Table user {
id integer [primary key]
created_at timestamp [not null]
updated_at timestamp [not null]
}
Table orders {
id integer [primary key]
user_id integer [not null] //유저ID
user_coupon_id integer [ref: - user_coupon.id, unique] //유저쿠폰 ID - 사용 안하면 null
is_coupon_applied boolean [not null] //쿠폰 사용 여부
total_amount integer [not null] //총 주문금액
status varchar [not null] //주문상태(NOT_PAID, CANCEL, PAID)
created_at timestamp [not null]
updated_at timestamp [not null]
}
Table order_product {
id integer [primary key]
product_id integer [not null] //상품ID
orders_id integer [not null] //주문ID
amount integer [not null] //주문금액
quantity integer [not null] //주문수량
created_at timestamp [not null]
updated_at timestamp [not null]
}
Table product {
id integer [primary key]
product_name varchar [not null] //상품명
description blob //상품 상세정보
price integer [not null] // 상품 가격
stock integer [not null] //상품 재고
created_at timestamp [not null]
updated_at timestamp [not null]
}
Table point {
id integer [primary key]
user_id integer [not null] //유저ID
balance integer [not null] //잔고
created_at timestamp [not null]
updated_at timestamp [not null]
}
Table point_history {
id integer [primary key]
point_id integer [not null]
amount integer [not null] //충전/사용액
balance integer [not null] //충전/사용 당시 잔고
type varchar [not null] //충전 or 사용
created_at timestamp [not null]
updated_at timestamp [not null]
}
Table coupon {
id integer [primary key]
coupon_name varchar [not null] //쿠폰 이름
discount_value decimal [not null]// 퍼센트 or 값
discount_type varchar [not null] // 할인 정책(정률/정액)
start_date date [not null] //유효기간 시작일
end_date date [not null] //유효기간 종료일
stock integer [not null] // 쿠폰 재고
created_at timestamp [not null]
updated_at timestamp [not null]
}
Table user_coupon {
id integer [primary key]
user_id integer [not null] //유저ID
coupon_id integer [not null] //쿠폰ID
is_used boolean [not null] //쿠폰 사용 여부
coupon_name varchar [not null] //쿠폰 이름
issued_at date [not null] //유효기간 시작일
expried_at date [not null] //유효기간 종료일
created_at timestamp [not null]
updated_at timestamp [not null]
}
Table best_seller {
id integer [primary key]
product_id integer [not null] //상품ID
product_name varchar [not null] //상품명
description blob [not null] //상품 상세정보
stock integer [not null] //재고
sales integer [not null] //판매량
created_at timestamp [not null]
updated_at timestamp [not null]
}
Ref product_order_item : order_product.product_id > product.id
Ref orders_order_item : order_product.orders_id > orders.id
Ref users_orders : orders.user_id > user.id
Ref point_point_history : point_history.point_id > point.id
Ref coupon_user_coupon : user_coupon.coupon_id > coupon.id
Ref user_user_coupon : user_coupon.user_id > user.id
Ref: "user"."id" - "point"."user_id"
'향해99 8기' 카테고리의 다른 글
| [ 3주차 과제 ] 이커머스 Clean + Layered Architecture 설계 (0) | 2025.04.05 |
|---|---|
| [ 2주차 과제 ] API명세, API에러 상황 정리, API에러 상황 정의 (0) | 2025.04.03 |
| [ 2주차 과제 ] 스프린트 계획, 이커머스 요구사항 분석 (0) | 2025.03.29 |
| [ 1주차 과제 ] 포인트 충전/사용에 대한 정책 (0) | 2025.03.25 |
| [ 1주차 과제 ] TDD 로 개발하기 Q&A (0) | 2025.03.24 |