Skip to content

시퀀스 다이어그램

Kim Hyunsu edited this page Aug 23, 2024 · 2 revisions

OrderCreationService

sequenceDiagram
    participant Client
    participant OrderCreationService
    participant CustomerRepository
    participant CartRepository
    participant Order
    participant OrderRepository
    participant OrderPaymentRepository

    Client->>OrderCreationService: create(OrderCreationCommand)
    activate OrderCreationService
    OrderCreationService->>CustomerRepository: findByIdOrThrow(requesterId)
    CustomerRepository-->>OrderCreationService: Customer
    OrderCreationService->>CartRepository: findByCustomerId(requesterId)
    CartRepository-->>OrderCreationService: Cart
    
    OrderCreationService->>Order: new Order(...)
    activate Order
    Order->>SingleStoreOrderValidator: validate
    Order->>StockRequester: request
    Order->>PriceChecker: check
    Order->>WithdrawPointService: withdraw
    deactivate Order
    
    OrderCreationService->>OrderRepository: save(order)
    OrderRepository-->>OrderCreationService: savedOrder
    
    OrderCreationService->>OrderPaymentRepository: save(new OrderPayment(...))
    OrderCreationService->>CartRepository: delete(cart)
    
    OrderCreationService-->>Client: orderId
    deactivate OrderCreationService
Loading
sequenceDiagram
    participant Client
    participant IssueCouponService
    participant DistributedLock
    participant CustomerRepository
    participant CouponRepository
    participant CouponIssuanceRepository
    participant Customer
    participant Coupon
    participant CouponIssuance

    Client->>IssueCouponService: issueCouponWithDistributionLock(cmd)
    IssueCouponService->>DistributedLock: Lock(cmd.couponId())
    IssueCouponService->>CustomerRepository: findById(cmd.customerId())
    CustomerRepository-->>IssueCouponService: Customer
    alt Customer not found
        IssueCouponService->>Client: throw InvalidICreationIssuanceException
    end
    IssueCouponService->>CouponRepository: findByIdWithPessimisticLock(cmd.couponId())
    CouponRepository-->>IssueCouponService: Coupon
    alt Coupon not found
        IssueCouponService->>Client: throw InvalidICreationIssuanceException
    end
    IssueCouponService->>Coupon: hasAvailableQuantity()
    Coupon-->>IssueCouponService: boolean
    alt Insufficient quantity
        IssueCouponService->>Client: throw InsufficientCouponQuantityException
    end
    IssueCouponService->>CouponIssuance: new CouponIssuance(Coupon, Customer)
    IssueCouponService->>CouponIssuanceRepository: save(CouponIssuance)
    CouponIssuanceRepository-->>IssueCouponService: saved CouponIssuance
    IssueCouponService->>DistributedLock: Unlock
    IssueCouponService-->>Client: CouponIssuance ID
Loading
Clone this wiki locally