-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 견적 확정 및 리뷰 작성 알림 연동 #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import { AppError } from "../../lib/app-error"; | ||
| import { buildPagination } from "../../utils/pagination.util"; | ||
| import { runTransaction } from "../../utils/transaction"; | ||
| import { notificationService } from "../notification/notification.service"; | ||
| import { moverEstimateRequestRepository, receivedEstimateRepository } from "./estimate.repository"; | ||
| import type { | ||
| ConfirmReceivedEstimateParams, | ||
|
|
@@ -24,17 +25,35 @@ import type { | |
| -DB 결과 API 응답 형태로 가공 | ||
| */ | ||
|
|
||
| /* | ||
| /* | ||
| 2026.07.23 add 김성현 | ||
| - 받은 견적 목록 비즈니스 로직 | ||
| - 받은 견적 상세 비즈니스 로직 | ||
| - 받은 견적 확정 비즈니스 로직 | ||
| */ | ||
|
|
||
| const KST_OFFSET_MS = 9 * 60 * 60 * 1000; | ||
|
|
||
| // ============================================================================= | ||
| // 기사: 고객의 견적 요청 목록 조회 | ||
| // ============================================================================= | ||
|
|
||
| function getKstEndOfDay(date: Date): Date { | ||
| const kstDate = new Date(date.getTime() + KST_OFFSET_MS); | ||
|
|
||
| return new Date( | ||
| Date.UTC( | ||
| kstDate.getUTCFullYear(), | ||
| kstDate.getUTCMonth(), | ||
| kstDate.getUTCDate(), | ||
| 14, | ||
| 59, | ||
| 59, | ||
| 999, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| function getCursorId(cursor: string | undefined) { | ||
| if (!cursor) { | ||
| return undefined; | ||
|
|
@@ -601,7 +620,7 @@ export const receivedEstimateService = { | |
| estimateId, | ||
| customerId, | ||
| }: ConfirmReceivedEstimateParams) { | ||
| return runTransaction(async (tx) => { | ||
| const result = await runTransaction(async (tx) => { | ||
| //확정 대상 견적 조회 | ||
| const estimate = await receivedEstimateRepository.findReceivedEstimateForConfirm( | ||
| estimateRequestId, | ||
|
|
@@ -702,6 +721,7 @@ export const receivedEstimateService = { | |
| //확정 응답 형태 가공 | ||
| return { | ||
| estimateRequest: confirmedEstimateRequest, | ||
| moveDate: estimate.estimateRequest.moveDate, | ||
| estimate: { | ||
| id: confirmedEstimate.id, | ||
| price: confirmedEstimate.price, | ||
|
|
@@ -717,5 +737,16 @@ export const receivedEstimateService = { | |
| expiredEstimateCount: expiredEstimates.count, | ||
| }; | ||
| }); | ||
|
|
||
| await notificationService.createNotification({ | ||
| userId: result.estimate.mover.id, | ||
| type: "ESTIMATE_CONFIRMED", | ||
| title: "견적 확정", | ||
| content: "고객님이 회원님의 견적을 확정했습니다.", | ||
| linkUrl: "/estimate/received-requests", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 수신자가 기사인거는 확인했습니다. 맞다면 그냥 넘기셔도됩니다. :) |
||
| expiresAt: getKstEndOfDay(result.moveDate), | ||
| }); | ||
|
Comment on lines
+741
to
+748
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift 트랜잭션 후 알림 실패를 도메인 작업 실패로 전파하지 않도록 통합 처리해 주세요. 두 서비스 모두 도메인 트랜잭션이 커밋된 뒤 알림 생성 오류를 그대로 전파하므로, 성공한 견적 확정/리뷰 작성이 API 실패로 보이고 재시도 시 충돌이 발생합니다.
📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Path instructions |
||
|
|
||
| return result; | ||
| }, | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
알림 문구가
"고객님이 견적을 확정"으로 끝나 문장이 다소 어색한것 같아서 수정이 필요해 보입니다!예:
"고객님이 회원님의 견적을 확정했습니다."