Skip to content

feat: 판매자 픽업 일시 변경과 변경 시트 달력·슬롯 - #585

Merged
chanwoo7 merged 3 commits into
developfrom
feat/order-pickup-reschedule
Nov 18, 2026
Merged

chanwoo7 merged 3 commits into
developfrom
feat/order-pickup-reschedule

Conversation

@chanwoo7

@chanwoo7 chanwoo7 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

개요

판매자가 접수·확정·제작 완료 주문의 픽업 일시를 바꿀 수 있게 합니다. 변경 시트가 쓸 달력·슬롯 조회도 함께 넣습니다.

변경 사항

  • sellerRescheduleOrderPickup(input: { orderId, pickupAt, note }) → SellerOrderSummary

    • 접수·확정·제작 완료만 됩니다(그 밖은 PICKUP_RESCHEDULE_NOT_ALLOWED). 같은 일시면 PICKUP_UNCHANGED, 둘 다 400 신설입니다.
    • 슬롯 판정은 isPickupSlotAvailable({ leadTime: 'SKIP', storeActiveOnly: false })이고, 맞지 않으면 PICKUP_NOT_AVAILABLE입니다.
    • OrderPickupChangeRepository.reschedule가 한 READ COMMITTED tx에서 처리합니다. 잠금을 기다린 뒤의 점유 재집계가 그사이 커밋된 주문 생성·픽업 변경을 봐야 해서, 주문 생성처럼 격리 수준을 명시합니다.
      • 주문을 잠그고(판매자에게 보이는 자기 매장 주문) 상태·같은 일시를 다시 판정합니다.
      • 새 날짜의 order_store_daily_limit 행을 FOR UPDATE로 잠그고, 이 주문을 뺀 점유(excludeOrderId)에 내 수량을 더해 capacity를 다시 셉니다.
      • 접수 상태면 확정 마감을 min(접수 + 24시간, 새 픽업)으로 다시 재고 미리 알림 표시를 지웁니다. 결제 도입 전 접수(마감 없음)는 마감을 만들지 않습니다.
      • 변경 이력(order_pickup_change), 감사 ORDER/UPDATE(판매자 감사 로그에 보임), outbox order.pickup_rescheduled를 남깁니다.
    • 커밋 뒤 판매자 구독을 kind: PICKUP_RESCHEDULED로 발행합니다.
  • 변경 시트 달력·슬롯: sellerOrderPickupCalendar(orderId, yearMonth)·sellerOrderPickupTimeSlots(orderId, date)

    • store의 rescheduleCalendar·rescheduleTimeSlots를 씁니다. 리드타임 없이 지난 시각만 막고, 숨긴 매장도 계산하며, 이 주문이 지금 점유한 수량을 현재 픽업일에서 뺍니다(bookedAdjustment).
    • 옮길 수 없는 상태면 PICKUP_RESCHEDULE_NOT_ALLOWED입니다.
  • store

    • isPickupSlotAvailable에 leadTime: 'APPLY' | 'SKIP'(기본 APPLY)·storeActiveOnly(기본 true)를 더했습니다.
    • 달력·슬롯 계산을 공통 함수로 나눠 일반 달력과 변경 시트가 같은 판정을 씁니다. store 배럴이 BookedAdjustment·PickupCalendar·PickupTimeSlots 타입을 내보냅니다.
  • order 공통

    • capacity 재집계를 order-capacity.helper로 옮기고 excludeOrderId를 더했습니다. 주문 생성도 같은 함수를 씁니다. forUpdate는 READ COMMITTED tx에서만 직렬화된다고 주석에 적었습니다.
    • 확정 마감 계산을 confirmDeadlineFor 하나로 모아 입금 확인과 픽업 변경이 같이 씁니다.
    • 판매자 주문 요약 매퍼를 order-seller-mappers.helper로 옮겨 두 서비스가 함께 씁니다.
  • SDL

    • type OrderPickupChange { id fromPickupAt toPickupAt changedAt note }
    • SellerOrderDetail.pickupChanges·AdminOrderDetail.pickupChanges·MyOrderDetail.pickupChanges(오래된 순, 없으면 빈 배열)
    • 새 파일 order-seller-pickup.graphql(mutation 1·query 2·input 1)
  • 구매자 알림 ORDER_PICKUP_RESCHEDULED: '{주문번호} 픽업 일시가 {M/d HH:mm}로 변경되었어요.'(KST)

  • 게이트: roles-coverage의 seller 접두 루트 필드 60 → 63

    • 합친 SDL을 buildSchema로 빌드해 셌습니다. admin 75·ADMIN_QUERY_COUNT 20은 develop 값 그대로입니다.
  • 스키마·마이그레이션: order_pickup_change 테이블은 BE-01에 있어 마이그레이션이 없습니다.

  • 크기·커밋: +1,923/−113줄(spec +974줄). 커밋은 둘입니다: 픽업 변경 / 리뷰 반영(픽업 변경 tx READ COMMITTED)

  • 리뷰 반영: 공용 픽업 판정 입력에 required(이 날짜에 더 들어가야 하는 수량, 기본 1)를 더했습니다. 기본값은 기존 booked >= capacity와 같고, 변경 시트 달력·슬롯만 옮길 주문의 수량을 넘깁니다.

테스트

  • 픽업 변경 서비스(ClockService 고정, 실 DB)
    • 접수·확정·제작 완료 각각: 리드타임 안쪽 슬롯으로 이동, 이력·감사·이벤트·판매자 구독
    • 픽업 완료·노쇼·취소는 PICKUP_RESCHEDULE_NOT_ALLOWED, 입금 대기·다른 매장 주문은 NOT_FOUND, 같은 일시 PICKUP_UNCHANGED
    • 검사 5종(지난 시각·슬롯 정렬·영업시간 밖·특별휴무·예약 가능 기간 밖)은 PICKUP_NOT_AVAILABLE, 오늘 남은 슬롯은 허용
    • 자기 수량 차감(같은 날 다른 슬롯), 다른 주문 점유 + 내 수량 초과 거절과 수량 1이면 허용
    • 동시성: capacity 2·점유 1에서 다른 tx가 새 날짜의 capacity 행을 잡고 주문 하나를 그 날로 옮긴 채(미커밋) 이 변경이 잠금을 기다리게 한 뒤 커밋하면 PICKUP_NOT_AVAILABLE, 픽업·이력 불변
    • 숨긴 매장 주문 허용, 접수 주문 마감 재계산(이른 픽업·늦은 픽업 두 경우)과 미리 알림 초기화, 확정 주문·결제 도입 전 접수는 마감 불변
    • 사전 확인 뒤 주문 삭제 경합은 NOT_FOUND, 판매자 상세 변경 이력 순서
    • 변경 시트 달력·슬롯: 리드타임 안쪽 날 선택 가능, 자기 점유 차감, 불가 상태·남의 주문
    • 변경 시트 달력·슬롯은 옮길 주문의 수량 전체로 capacity를 판정(수량 2 주문에서 capacity 2·예약 1 날짜는 소진), 리뷰 반영
  • store 판정: SKIP이 지난 시각만 막음(반증: APPLY면 불가), 숨긴 매장은 storeActiveOnly: false에서만, 변경 시트 달력의 점유 차감(반증: 차감이 없으면 소진), 형식·없는 매장 거절
  • 전이 정책: 픽업 변경 가능 상태 7종 표, 같은 일시
  • 알림·이벤트: order.pickup_rescheduled 파서·소비자(재전달 멱등), 알림 문구, 관리자·구매자 상세 pickupChanges
  • 리졸버: 달력·슬롯 query와 변경 mutation 1건씩
  • 가드 반증: excludeOrderId, leadTime: 'SKIP', storeActiveOnly: false를 되돌리면 해당 테스트가 실패하는 것을 확인했습니다. 격리 수준(READ COMMITTED)을 빼면 동시성 테스트에서 변경이 성공해 3/2로 초과 예약되고 테스트가 실패합니다.
  • 경로 지정 실행: order·notification·store feature, 게이트(module-wiring·read-boundary·model-ownership·audit-write-path·enum-sdl-sync·roles-coverage·role-routes·admin-query-null-inputs·seed-reset-scope), 에러 카탈로그 138 스위트 2,891건 통과
  • 정적 검사: lint·tsc·dto:check·docs:check·arch:check 통과. 전체 jest는 pre-push에서 돕니다.

플랜 대조

플랜 항목 BE-07 불릿 상태
7절 판매자 픽업 변경 sellerRescheduleOrderPickup(orderId, pickupAt, note?): SUBMITTED·CONFIRMED·MADE만(PICKUP_RESCHEDULE_NOT_ALLOWED), 같은 일시 PICKUP_UNCHANGED 한 것
검사: 영업일·특별휴무·슬롯 시각·과거 금지·예약 가능 기간·제작 수량, 리드타임·제작 시간 미적용, isPickupSlotAvailable에 leadTime·storeActiveOnly 한 것
자기 수량 차감: order capacity 재집계 excludeOrderId + order_store_daily_limit FOR UPDATE 한 것(READ COMMITTED tx로 동시 변경까지 직렬화)
기록: 이력 행, SUBMITTED면 마감 재계산·미리 알림 표시 초기화, 감사 ORDER/UPDATE, outbox order.pickup_rescheduled, 판매자 구독 PICKUP_RESCHEDULED 한 것
변경 시트용 sellerOrderPickupCalendar(orderId, yearMonth)·sellerOrderPickupTimeSlots(orderId, date): bookedAdjustment·비활성 허용 별도 메서드 한 것
7절 표 BE-07 행: SellerOrderDetail.pickupChanges, AdminOrderDetail 픽업 변경, OrderPickupChange { id fromPickupAt toPickupAt changedAt note } 한 것
5절 SDL MyOrderDetail.pickupChanges(앞 PR에서 넘어온 항목) 한 것
9절 order.pickup_rescheduled → 구매자 알림 ORDER_PICKUP_RESCHEDULED 한 것
13절 에러 코드 PICKUP_RESCHEDULE_NOT_ALLOWED·PICKUP_UNCHANGED 한 것
테스트: 픽업 변경 상태·검사·자기 수량·비활성 매장·마감 재계산 한 것
전이 정책·노쇼·크론·나머지 7절 표 필드·(g) 분할 1/2 PR(#583)에서 함
분할 경계: 픽업 변경(feat/order-pickup-reschedule) 한 것(이 PR이 분할 2/2)
결정 이 PR에서 한 일 상태
D26 구매자 인앱 픽업 변경 알림 한 것
D31 판매자만 픽업 일시 변경, 제작 수량 재검사·변경 이력·구매자 알림, 커스텀 내용 불변 한 것
D75 허용 상태(접수·확정·제작 완료)와 검사 항목, 리드타임·상품 제작 시간 미적용 한 것
D9·D10·D14·D22·D23·D28·D78·D84①② 분할 1/2 PR에서 함 1/2

- 무엇·왜
  - 판매자가 접수·확정·제작 완료 주문의 픽업 일시를 바꾼다(커스텀 내용은 그대로). 검사는 영업일·특별휴무·슬롯 시각·
    지난 시각·예약 가능 기간·일일 제작 수량이고, 리드타임·상품 제작 시간은 보지 않는다. 숨긴 매장의 진행 주문도 옮길 수 있다.
  - 변경 이력을 남기고 구매자에게 '픽업 일시가 {M/d HH:mm}로 변경되었어요.' 알림을 보낸다. 접수 상태면 확정 마감을
    min(접수 + 24시간, 새 픽업)으로 다시 재고 미리 알림 표시를 지운다.
- 변경점
  - SDL: sellerRescheduleOrderPickup(input), sellerOrderPickupCalendar(orderId, yearMonth)·sellerOrderPickupTimeSlots(orderId, date),
    type OrderPickupChange { id fromPickupAt toPickupAt changedAt note }, Seller·Admin·MyOrderDetail.pickupChanges(오래된 순)
  - PICKUP_RESCHEDULE_NOT_ALLOWED·PICKUP_UNCHANGED(400) 신설, 수량·슬롯이 맞지 않으면 PICKUP_NOT_AVAILABLE
  - store: isPickupSlotAvailable에 leadTime 'APPLY'|'SKIP'·storeActiveOnly, 변경 시트용 rescheduleCalendar·rescheduleTimeSlots
    (리드타임 없음·숨긴 매장 허용·옮길 주문 점유 차감 bookedAdjustment)
  - order: capacity 재집계를 order-capacity.helper로 빼고 excludeOrderId 추가, OrderPickupChangeRepository(주문 → capacity 행
    FOR UPDATE, 이력·감사 ORDER/UPDATE·outbox order.pickup_rescheduled 같은 tx), 커밋 뒤 판매자 구독 kind PICKUP_RESCHEDULED
  - 확정 마감 계산을 confirmDeadlineFor 하나로 모아 입금 확인과 픽업 변경이 같이 쓴다
- 테스트
  - 상태 표(옮길 수 있음 3·불가 3·입금 대기/남의 주문 404), 같은 일시, 검사 5종(지난 시각·슬롯 정렬·영업시간·특별휴무·기간),
    오늘 남은 슬롯, 자기 수량 차감(같은 날)·다른 주문 점유 초과, 숨긴 매장, 마감 재계산·미리 알림 초기화·도입 전 주문 불변,
    잠금 전 삭제 경합, 변경 시트 달력·슬롯, store 판정(SKIP·숨긴 매장·차감 반증), 구매자 알림·이벤트 파서, 상세 3곳 이력
  - 반증: excludeOrderId·leadTime SKIP·storeActiveOnly를 되돌리면 해당 테스트가 실패함을 확인
기본 격리(REPEATABLE READ)에서는 잠금 SQL의 품목 서브쿼리·품목 조회가 스냅샷을 먼저 잡는다.
그래서 order_store_daily_limit 잠금을 기다렸다 받은 뒤의 점유 재집계가 그사이 커밋된 주문 생성·픽업 변경을 보지 못하고 일일 제작 수량을 넘겨 통과했다.
주문 생성(createPendingPaymentOrder)처럼 READ COMMITTED를 명시한다.

- OrderPickupChangeRepository.reschedule: $transaction에 isolationLevel ReadCommitted(본문은 들여쓰기만 바뀜)
- order-capacity.helper: forUpdate가 READ COMMITTED tx에서만 직렬화한다고 주석 정정
- 회귀 테스트 1건: capacity 2·점유 1에서 다른 tx가 9/17 capacity 행을 잡고 주문 하나를 옮긴 채(미커밋) 픽업 변경이 잠금을 기다리게 한 뒤 커밋하면 PICKUP_NOT_AVAILABLE, 픽업·이력 불변
- 반증: 격리 수준을 빼면 픽업 변경이 성공해(3/2 점유) 테스트가 실패한다.
- 잠금 대기 관측은 innodb_trx 캐시(직전 읽기 뒤 100ms 안에는 갱신 안 함) 때문에 150ms 간격으로 읽는다.
- src/features/order 57 스위트 1,410건 통과.
@coderabbitai

coderabbitai Bot commented Nov 18, 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 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T22:40:20.870583Z c196ef3 New commits
ℹ️ 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

Copy link
Copy Markdown

🧹 knip — dead-code 리포트

Unused exports (1)
Unused exported types (4)
전체 리포트
Unused exports (1)
effectiveLeadTimeMinutes  src/features/store/index.ts:20:10
Unused exported types (4)
OrderPickupRescheduledPayload  type  src/features/order/index.ts:44:8  
ProductCustomIssue             type  src/features/product/index.ts:11:8
ThreeDDesignSource             type  src/features/product/index.ts:16:8
ThreeDDesignV1                 type  src/features/product/index.ts:17:8

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

@github-actions

Copy link
Copy Markdown

🩺 NestJS Doctor — 90/100 (Excellent)

진단 533건 (error 14).

Category error warning info
architecture 2 2 46
correctness 0 289 0
performance 0 44 29
schema 0 0 87
security 12 22 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 'AccountNumberReencryptRepository' detected. Use dependency injection instead.
  • warning security/security/no-weak-crypto: Weak hashing algorithm 'md5' used in createHash().
  • 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.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de2921916c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +295 to +300
const { adjustment } = options;
const adjusted = adjustment && bookedByDate.get(adjustment.date);
if (adjustment && adjusted !== undefined) {
bookedByDate.set(
adjustment.date,
Math.max(0, adjusted - adjustment.quantity),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include the moving order's quantity in calendar availability

For an order containing two cakes, a destination date with capacity 2 and one cake already booked is returned as selectable, with available time slots, even though rescheduling to it always fails with PICKUP_NOT_AVAILABLE. The adjustment only removes the order's existing occupancy; the shared evaluatePickupDay still checks booked >= capacity, which only determines whether one more cake fits. Since these queries are specific to an existing order with a known quantity, carry that quantity into the availability calculation and mark dates full when the remaining capacity cannot accommodate the whole order, while retaining the self-occupancy subtraction.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영: 공용 판정에 이 날짜에 들어가야 하는 수량(required, 기본 1 = 기존 booked >= capacity와 동일)을 더하고, 픽업 변경 달력·슬롯은 자기 점유를 뺀 뒤 옮길 주문의 수량 전체로 판정함. 수량 2 주문이 capacity 2·예약 1 날짜를 소진으로, capacity 3·예약 1 날짜를 선택 가능으로 보는 테스트 추가(이전 코드에서 실패 확인).

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Coverage report

St.❔
Category Percentage Covered / Total
🟢 Statements
98.41% (+0.01% 🔼)
13113/13325
🟢 Branches
93.83% (-0.07% 🔻)
5158/5497
🟢 Functions
98.03% (+0.02% 🔼)
2644/2697
🟢 Lines
98.89% (+0.02% 🔼)
11937/12071
Show new covered files 🐣
St.❔
File Statements Branches Functions Lines
🟢
... / order-capacity.helper.ts
100% 87.5% 100% 100%
🟢
... / order-pickup-change.repository.ts
100% 78.57% 100% 100%
🟢
... / order-pickup-rescheduled.event.ts
100% 88.89% 100% 100%
🟢
... / order-seller-mappers.helper.ts
100% 100% 100% 100%
🟢
... / order-seller-pickup-mutation.resolver.ts
100% 100% 100% 100%
🟢
... / seller-reschedule-order-pickup.input.ts
100% 100% 100% 100%
🟢
... / order-seller-pickup.service.ts
100% 100% 100% 100%
🟢
... / order-seller-pickup-query.resolver.ts
100% 100% 100% 100%
Show files with reduced coverage 🔻
St.❔
File Statements Branches Functions Lines
🟢
... / order-transition.repository.ts
98.92% (-0.01% 🔻)
90.79% 100% 100%
🟢
... / review-engagement.repository.ts
98.08% (-1.92% 🔻)
90.91% (-4.55% 🔻)
100% 100%
🟢
... / notification-outbox.consumer.ts
100%
87.1% (-5.21% 🔻)
100% 100%
🟢
... / order-seller.service.ts
98.53%
91.67% (-1.19% 🔻)
100% 100%

Test suite run success

6558 tests passing in 439 suites.

Report generated by 🧪jest coverage report action from c196ef3

판매자 픽업 변경 달력은 자기 점유만 빼고 공용 판정(booked >= capacity, 한 건 더 들어가는지)을 써서, 수량 2 주문을 남은 자리 1인 날짜로 옮길 수 있다고 보여 주고 실제 변경은 PICKUP_NOT_AVAILABLE로 실패했다.

- 공용 판정 입력에 required(이 날짜에 더 들어가야 하는 수량, 기본 1)를 더해 booked + required > capacity로 판정. 기본 1은 기존과 같다
- 픽업 변경 달력·슬롯은 required = 옮길 주문의 수량
- 테스트: 수량 2 주문에서 capacity 2·예약 1 날짜는 소진(슬롯 전부 마감), capacity 3·예약 1 날짜는 선택 가능. 이전 코드에서 실패 확인
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

@chanwoo7
chanwoo7 merged commit a115c68 into develop Nov 18, 2026
17 checks passed
@chanwoo7
chanwoo7 deleted the feat/order-pickup-reschedule branch November 18, 2026 22:43
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