Skip to content

feat: 내 주문 목록에 할인율·매장 지역 추가 - #551

Merged
chanwoo7 merged 2 commits into
developfrom
feat/my-orders-discount-region
Nov 2, 2026
Merged

chanwoo7 merged 2 commits into
developfrom
feat/my-orders-discount-region

Conversation

@chanwoo7

@chanwoo7 chanwoo7 commented Nov 2, 2026

Copy link
Copy Markdown
Member

개요

마이페이지 주문상황 화면(/mypage/orders) 카드의 "매장명 · 지역"과 "할인율 % 금액" 자리에 쓸 값을 myOrders 응답에 추가합니다.

  • FE가 두 값이 오지 않는다고 알려 왔습니다(급하지 않은 값).
  • 필드를 추가만 하므로 FE 파괴적 변경은 없습니다.

변경 사항

  • SDL: MyOrderSummary에 discountRate: Int!와 regionLabel: String을 추가했습니다.
  • 할인율: 주문 기준으로 discount_price ÷ subtotal_price를 반올림한 0~100 정수이고, 할인이 없으면 0입니다.
    • 옆에 붙는 금액이 주문 총액이라 두 숫자가 서로 맞습니다.
    • 옵션 추가금은 할인 대상이 아니라서, 옵션이 붙은 주문은 상품 카드의 할인율보다 낮게 나옵니다.
    • 계산 함수 calcDiscountRate를 product feature에서 src/common/utils/discount-rate.ts로 옮겨 함께 씁니다(별도 커밋).
  • 지역: order_item.store_region_label_snapshot(nullable) 컬럼을 추가하고, 주문 생성 때 buildRegionLabel로 저장합니다.
    • 매장을 실시간으로 조인하면 read-boundary 허용 목록이 늘어나므로 스냅샷으로 처리했습니다.
    • 기존 주문은 마이그레이션 백필로 채웁니다. 현재 매장 값에 같은 규칙을 적용하고, 빈 값 판정은 CHAR_LENGTH로 합니다.
    • findProductDetailById의 매장 select에 주소·지역을 더했습니다. Product·Store·Region이 모두 catalog 소유라 경계 항목은 늘지 않습니다.
  • 팩토리·시드
    • createOrderItem은 값을 지정하지 않으면 생성 경로 규칙으로 지역 스냅샷을 채웁니다.
    • 시드 o1·o4는 할인 상품인데 할인 0원으로 들어가 있어서, 생성 경로 규칙(정가 40,000·할인 5,000)으로 맞췄습니다.

테스트

  • 할인율: 할인 없음 0, 일반 5, 옵션 포함 11(상품 카드 13과 다름), subtotal 0일 때 0을 확인합니다.
  • 지역 표기
    • 목록은 스냅샷을 그대로 돌려줍니다. 반증으로 주문 뒤 매장 주소를 바꿔도 값이 유지되는지 확인합니다.
    • 주문 생성은 시·동, 지역명, null 세 경우를 저장하는지 확인합니다.
  • 백필 SQL은 8개 매장 상태에서 buildRegionLabel과 결과가 같은지 비교합니다.
    • 반증: 백필을 NULLIF 버전으로 바꾸면 공백값 케이스 1건이 실패합니다.
  • 로컬 검증
    • 로컬 DB에 마이그레이션을 적용해 order_item 6건이 모두 채워진 것을 확인했습니다.
    • 시드를 다시 넣고 로컬 BE(4100)에서 myOrders를 호출해 o1·o4 13%, o3 12%, 나머지 0%와 지역 표기를 확인했습니다.
  • yarn validate:push(전체 jest 포함)를 통과했습니다.

플랜 대조

플랜 항목 상태
SDL discountRate: Int!·regionLabel: String 추가 한 것
order_item.store_region_label_snapshot String? VarChar(200) 한 것
마이그레이션 + 백필(CASE+CHAR_LENGTH, 지역 soft-delete 미필터) 한 것
calcDiscountRate → common/utils/discount-rate.ts, product import 3곳, spec 이동 한 것
주문 생성: 상품 조회 store select 확장 → checkout → insertSubmittedOrder 저장 한 것
목록 조회: regionLabel·discountRate 매핑(쿼리 변경 없음) 한 것
출력 타입 + codegen 한 것
팩토리 createOrderItem 지역 스냅샷 기본값 한 것
시드: 지역 스냅샷 + o1·o4 가격 보정 한 것
테스트: discount-rate·order-my·order-checkout·migration·resolver 한 것(migration은 공백값 반증 1건 추가)
일회성 검증: 로컬 마이그레이션 전후 수, 로컬 BE myOrders 한 것
커밋 2개(refactor·feat) 한 것

- calcDiscountRate를 product-storefront-mappers.helper에서 common/utils/discount-rate로 옮김.
  주문 목록도 같은 규칙을 쓰게 돼 buildRegionLabel처럼 공용 표시 규칙으로 둠.
- product 쪽 import 3곳 변경, spec은 it.each 표로 옮김(7케이스).
FE 마이페이지 주문상황 카드("매장명 · 지역", "할인율 % 금액")에 쓸 값이 MyOrderSummary에 없었음.

- 할인율: 주문 기준 discount_price ÷ subtotal_price 반올림(0~100, 할인 없으면 0).
  옆에 붙는 금액이 주문 총액이라 숫자를 맞춤. 옵션 추가금은 할인 대상이 아니라 옵션 주문은 상품 카드 할인율보다 낮게 나옴.
- 지역: order_item.store_region_label_snapshot(nullable) 추가, 주문 생성 때 buildRegionLabel로 저장.
  매장 실시간 조인은 read-boundary 허용 목록(Order.items.store.region)을 늘려 스냅샷으로 감.
  - 마이그레이션 백필은 현재 매장 기준 같은 규칙. 빈 값 판정은 CHAR_LENGTH(NULLIF는 PAD SPACE로 공백값까지 비움).
  - ProductRepository.findProductDetailById의 store select에 주소·지역 추가(Product·Store·Region 모두 catalog라 경계 항목 증가 없음).
- SDL: MyOrderSummary.discountRate: Int!, regionLabel: String (필드 추가만, FE 파괴적 변경 없음).
- 팩토리 createOrderItem은 미지정 시 생성 경로 규칙으로 지역 스냅샷을 채움.
- 시드 o1·o4: p1(정가 40,000·판매가 35,000)인데 subtotal 35,000/discount 0이던 것을 생성 경로 규칙(40,000/5,000)으로 맞춤.

테스트 17건 추가
- order-my.service: discountRate 4(옵션 포함·subtotal 0 반증), regionLabel 2(주문 뒤 매장 주소 변경 반증)
- order-checkout.service: 지역 스냅샷 3(시·동 / 지역명 / null)
- 백필 migration spec 8: buildRegionLabel과 결과 비교, 공백값 케이스는 NULLIF 버전에서 실패하는 것 확인
- order-my.resolver: 전체 경로 단언에 두 필드
@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T14:58:08.316550Z 0bdc9be PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🧹 knip — dead-code 리포트

요약 항목 없음
전체 리포트
(knip 출력 없음 — 이슈 0이거나 실행 실패)

청소 후보(오탐 가능) · 기준 docs/guide/architecture-conventions.md

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🩺 NestJS Doctor — 90/100 (Excellent)

진단 493건 (error 13).

Category error warning info
architecture 1 1 44
correctness 0 269 0
performance 0 41 28
schema 0 0 76
security 12 21 0
architecture / security 상위 항목
  • error security/security/no-hardcoded-secrets: Variable 'SEED_PASSWORD' appears to contain a hardcoded secret.
  • error architecture/architecture/no-manual-instantiation: Manual instantiation of 'OutboxRepository' detected. Use dependency injection instead.
  • info architecture/architecture/no-barrel-export-internals: Barrel file re-exports internal type 'IAuditLogRepository'.
  • warning security/security/no-exposed-env-vars: Direct 'process.env.NODE_ENV' access in 'AuthController'. Use ConfigService instead.
  • warning security/security/require-guards-on-endpoints: Endpoint 'start' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'callback' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'refresh' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'logout' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'sellerLogin' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'sellerRefresh' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'sellerLogout' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'devIssueToken' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'adminLogin' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'adminRefresh' has no @UseGuards() at class or method level.
  • warning security/security/require-guards-on-endpoints: Endpoint 'adminLogout' has no @UseGuards() at class or method level.

오탐 포함 가능 · 기준 docs/guide/architecture-conventions.md

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Coverage report

St.❔
Category Percentage Covered / Total
🟢 Statements
98.02% (+0% 🔼)
10814/11032
🟢 Branches
92.97% (+0% 🔼)
4126/4438
🟢 Functions 97.56% 2157/2211
🟢 Lines
98.6% (+0% 🔼)
9837/9977
Show new covered files 🐣
St.❔
File Statements Branches Functions Lines
🟢
... / discount-rate.ts
100% 100% 100% 100%

Test suite run success

4352 tests passing in 391 suites.

Report generated by 🧪jest coverage report action from 0bdc9be

@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chanwoo7
chanwoo7 merged commit 87f1e70 into develop Nov 2, 2026
18 checks passed
@chanwoo7
chanwoo7 deleted the feat/my-orders-discount-region branch November 2, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant