프로젝트 주제
OMC(One More Chance)는 그래픽카드, 게이밍 기기, 한정판 IT 디바이스 등 높은 수요를 가진 테크 상품을 대상으로 하는 한정판 드롭·래플 이커머스 플랫폼입니다.
사용자는 특정 시간에 오픈되는 상품에 대해 선착순 구매(Drop) 또는 추첨 응모(Raffle) 방식으로 참여할 수 있으며, 플랫폼은 드롭 오픈 순간 발생하는 대규모 트래픽과 치열한 구매 경쟁 상황을 안정적으로 처리하는 것을 목표로 합니다.
프로젝트 목표
| Drop (선착순) | Raffle (추첨) | |
|---|---|---|
| 방식 | 오픈 순간 선착순 즉시 구매 | 응모 기간 → 추첨 → 당첨자만 자동 결제 |
| 결제 시점 | 구매 즉시 선결제 | 응모 시 빌링키 등록(가승인) ➔ 당첨 확정 후 빌링키로 실결제 |
| 동시성 제어 | Redis 재고 차감 (원자적) | Redis Set 중복 방지 |
| 레퍼런스 | 나이키 Line | 나이키 Draw / SNKRS |
flowchart LR
%% 노드 정의
A([사용자 로그인])
B[드롭 상품 조회]
C[드롭 시작 대기]
D[드롭 시작]
E[상품 구매 요청]
F{"Redis 재고<br/>선점 가능한가?"}
N([품절 안내])
G["주문 생성"]
G2[가용 쿠폰 조회]
G3{"쿠폰 사용<br/>여부"}
G4{"쿠폰 유효성<br/>검증"}
G5([주문 취소<br/>선점 해제])
G6["쿠폰 사용 처리<br/>할인 금액 계산"]
H["결제 진행"]
I{"결제 성공<br/>여부"}
M([결제 실패<br/>선점 해제<br/>쿠폰 복구])
TTL([TTL 만료<br/>선점 자동 해제])
J["DB 재고 차감"]
K{"재고 차감<br/>성공 여부"}
L([환불 처리<br/>쿠폰 복구])
O["주문 확정"]
P([구매 완료])
%% 연결 관계
A --> B --> C --> D --> E --> F
F -- "재고 없음" --> N
F -- "선점 성공" --> G
G --> G2 --> G3
G3 -- "미사용" --> H
G3 -- "쿠폰 사용" --> G4
G4 -- "유효" --> G6 --> H
G4 -- "유효하지 않음" --> G5
H --> I
I -- "실패" --> M
I -- "TTL 만료" --> TTL
I -- "성공" --> J
J --> K
K -- "실패" --> L
K -- "성공" --> O --> P
%% 노드 스타일링 (래플과 통일된 테마)
style A fill:#f1f3f5,stroke:#adb5bd,stroke-width:2px
style P fill:#e8fadc,stroke:#b2f2bb,stroke-width:2px
%% 결정 노드 (노란색)
style F fill:#fff3bf,stroke:#fcc419,stroke-width:2px
style G3 fill:#fff3bf,stroke:#fcc419,stroke-width:2px
style G4 fill:#fff3bf,stroke:#fcc419,stroke-width:2px
style I fill:#fff3bf,stroke:#fcc419,stroke-width:2px
style K fill:#fff3bf,stroke:#fcc419,stroke-width:2px
%% 실패/종료 노드 (빨간색/분홍색)
style N fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px
style G5 fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px
style M fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px
style TTL fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px
style L fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px
flowchart LR
%% 시작 노드
Start([래플 응모 시작]) --> CheckCond[응모 조건 확인]
%% 분기 1: 조건 충족 여부
CheckCond --> IsMet{조건 충족 여부}
IsMet -- "조건 미달" --> FailNotify([응모 불가 알림])
%% 분기 2: 중복 응모 방지 (Redis Set)
IsMet -- "조건 충족" --> CheckDup{"Redis 중복 체크<br/>SADD raffle:{dropId}"}
CheckDup -- "중복 (0 반환)" --> FailNotifyDup([응모 불가<br/>이미 참여한 유저])
%% 쿠폰 적용 및 빌링키 동기 검증
CheckDup -- "신규 (1 반환)" --> ApplyCoupon[쿠폰 적용 및 할인 계산]
ApplyCoupon --> VerifyCard[카드 및 빌링키 동기 검증<br/>OpenFeign 가승인 100원]
%% 분기 3: 가승인 성공 여부 (누락되었던 5번째 분기)
VerifyCard --> IsPreAuthSuccess{가승인 성공 여부}
IsPreAuthSuccess -- "실패 (한도초과/정지 등)" --> FailCardNotify([응모 불가<br/>유효하지 않은 카드])
IsPreAuthSuccess -- "성공 (빌링키 발급)" --> EntryComplete[응모 완료 및 빌링키 저장<br/>DB 기록]
%% 추첨 진행
EntryComplete --> RaffleRun[마감 및 추첨 진행]
RaffleRun --> SelectWinner[당첨자 선정<br/>당첨 인원 ≤ 할당 재고 수량]
%% 분기 4: 당첨 여부
SelectWinner --> IsWinner{당첨 여부}
%% 낙첨 프로세스
IsWinner -- "낙첨" --> LoseProcess[낙첨 알림 발송<br/>및 쿠폰 영구 소멸]
LoseProcess --> LoseDone([낙첨 처리 완료])
%% 당첨자 비동기 실결제 청구
IsWinner -- "당첨<br/>(raffle.winner.selected)" --> ChargePayment[빌링키 자동 실결제 청구<br/>Payment 비동기 워커 구동]
%% 분기 5: 최종 실결제 성공 여부
ChargePayment --> IsPaySuccess{결제 성공 여부}
%% 결제 실패 (Fail-Fast)
IsPaySuccess -- "실패 (잔액 부족 등)" --> CancelWinner[당첨 즉시 취소<br/>CANCELED 전이]
CancelWinner --> WinFailNotify([당첨 자동 취소 알림톡])
%% 결제 성공 (주문 확정)
IsPaySuccess -- "성공 (payment.completed)" --> CreateOrder[order-service: PENDING_PAYMENT 생성<br/>→ PAID → CONFIRMED]
CreateOrder --> DeductStock[DB 재고 확정 차감]
DeductStock --> StartShip[배송 시작]
StartShip --> WinDone([당첨자 프로세스 완료])
%% 스타일링
style Start fill:#f1f3f5,stroke:#adb5bd,stroke-width:2px
style FailNotify fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px
style FailNotifyDup fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px
style FailCardNotify fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px
style WinDone fill:#e8fadc,stroke:#b2f2bb,stroke-width:2px
style LoseDone fill:#f1f3f5,stroke:#adb5bd,stroke-width:2px
style WinFailNotify fill:#ffe3e3,stroke:#ffa8a8,stroke-width:2px
%% 결정 노드(마름모) 5개 노란색 강조
style IsMet fill:#fff3bf,stroke:#fcc419,stroke-width:2px
style CheckDup fill:#fff3bf,stroke:#fcc419,stroke-width:2px
style IsPreAuthSuccess fill:#fff3bf,stroke:#fcc419,stroke-width:2px
style IsWinner fill:#fff3bf,stroke:#fcc419,stroke-width:2px
style IsPaySuccess fill:#fff3bf,stroke:#fcc419,stroke-width:2px