Skip to content

feat: 주문 취소 기능 구현#304

Merged
Jjiggu merged 13 commits intodevelopfrom
refactor/#300-menu-image-replace
Sep 3, 2025
Merged

feat: 주문 취소 기능 구현#304
Jjiggu merged 13 commits intodevelopfrom
refactor/#300-menu-image-replace

Conversation

@Jjiggu
Copy link
Contributor

@Jjiggu Jjiggu commented Sep 3, 2025

작업 요약

  • 주문 취소 기능 구현
  • 주문 취소 내역 저장하는 Cancel Order 엔티티 생성
  • 주문 취소 시 내역 저장하는 이벤트 구현

Issue Link

#303

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 신기능
    • 관리자에서 주문 취소 지원: 주문에 대해 취소 사유를 선택해 제출할 수 있습니다.
    • 주문 상태에 ‘취소됨’이 추가되어 화면과 API 응답에서 명확히 확인됩니다.
    • 취소 시각과 사유가 기록되어 감사/이력 관리가 가능합니다.
    • 동시 취소 시 중복 저장을 방지해 안정적으로 처리됩니다.

@Jjiggu Jjiggu self-assigned this Sep 3, 2025
@Jjiggu Jjiggu added the enhancement New feature or request label Sep 3, 2025
@coderabbitai
Copy link

coderabbitai bot commented Sep 3, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

관리자 주문 취소 기능을 추가. 주문 상태에 CANCELLED를 도입하고, 서비스/컨트롤러에 취소 API를 구현. 취소 사유 DTO/이벤트/엔티티/리포지토리 추가. 주문 취소 이벤트 발행 후 커밋 시 리스너가 별도 트랜잭션으로 취소 이력 저장. 이벤트 모듈 의존성 갱신.

Changes

Cohort / File(s) Change Summary
Admin API DTOs
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/cancelOrder/dto/CancelOrderRequest.java, .../cancelOrder/dto/CancelOrderResponse.java
신규 DTO 추가: 요청 레코드 CancelOrderRequest(CancelReason reason)와 응답 CancelOrderResponse(+@builder, fromEntity).
Admin API Listener
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/cancelOrder/listener/OrderCancelledEventListener.java
트랜잭션 커밋 후(OrderCancelledEvent) 취소 이력 저장. 중복시 DataIntegrityViolationException 무시(디버그 로그). REQUIRES_NEW 트랜잭션.
Admin API Controller/Service
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/order/controller/OrderController.java, .../order/service/OrderService.java
DELETE /admin/orders/{orderId} 추가. 서비스에 cancelOrder(...) 추가: 권한 검사, userOrder.cancelOrder(), OrderCancelledEvent 발행, 응답 매핑.
Admin RDB Entity/Repo/Enum
nowait-domain/domain-admin-rdb/src/main/java/com/nowait/domainadminrdb/cancelOrder/entity/CancelOrder.java, .../entity/CancelReason.java, .../repository/CancelOrderRepository.java
취소 이력 엔티티/리포지토리/사유 enum 추가. CancelOrdercancel_orders 매핑, @PrePersistcancelAt 기본값.
Core RDB Order updates
nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/order/entity/OrderStatus.java, .../order/entity/UserOrder.java
상태값 CANCELLED 추가. UserOrder.cancelOrder() 메서드 추가(중복 취소 방지).
Event module
nowait-event/build.gradle, nowait-event/src/main/java/com/nowait/nowaitevent/order/event/OrderCancelledEvent.java
이벤트 클래스 OrderCancelledEvent 추가(불변 데이터). 이벤트 모듈에 domain-admin-rdb 의존성 추가.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Admin as Admin
  participant C as OrderController
  participant S as OrderService
  participant CoreDB as Core RDB
  participant Pub as AppEventPublisher
  participant L as OrderCancelledEventListener
  participant AdminDB as Admin RDB

  Admin->>C: DELETE /admin/orders/{orderId}\nBody: CancelOrderRequest(reason)
  C->>S: cancelOrder(orderId, request, member)
  S->>CoreDB: load UserOrder, auth check
  S->>CoreDB: userOrder.cancelOrder() -> set status=CANCELLED
  S-->>Pub: publish OrderCancelledEvent(orderId, storeId, signature, reason, now)
  S-->>C: OrderStatusUpdateResponseDto

  rect rgba(200,230,255,0.2)
    note over Pub,L: After transaction commit
    Pub-->>L: on(OrderCancelledEvent)
    L->>AdminDB: save CancelOrder(orderId, storeId, signature, reason, cancelAt)
    alt duplicate
      L-->>L: catch DataIntegrityViolationException\n(ignore)
    end
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Suggested reviewers

  • HyemIin

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f3ac196 and 5732090.

📒 Files selected for processing (12)
  • nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/cancelOrder/dto/CancelOrderRequest.java (1 hunks)
  • nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/cancelOrder/dto/CancelOrderResponse.java (1 hunks)
  • nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/cancelOrder/listener/OrderCancelledEventListener.java (1 hunks)
  • nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/order/controller/OrderController.java (2 hunks)
  • nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/order/service/OrderService.java (4 hunks)
  • nowait-domain/domain-admin-rdb/src/main/java/com/nowait/domainadminrdb/cancelOrder/entity/CancelOrder.java (1 hunks)
  • nowait-domain/domain-admin-rdb/src/main/java/com/nowait/domainadminrdb/cancelOrder/entity/CancelReason.java (1 hunks)
  • nowait-domain/domain-admin-rdb/src/main/java/com/nowait/domainadminrdb/cancelOrder/repository/CancelOrderRepository.java (1 hunks)
  • nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/order/entity/OrderStatus.java (1 hunks)
  • nowait-domain/domain-core-rdb/src/main/java/com/nowait/domaincorerdb/order/entity/UserOrder.java (3 hunks)
  • nowait-event/build.gradle (1 hunks)
  • nowait-event/src/main/java/com/nowait/nowaitevent/order/event/OrderCancelledEvent.java (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/#300-menu-image-replace

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot requested a review from HyemIin September 3, 2025 10:54
@Jjiggu Jjiggu merged commit ba10a58 into develop Sep 3, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant