[feat] negodata: 알림함 — 견적 마감 결과(낙찰/재생성/결렬) 자동 통지
- company.notifications 테이블 + NotificationType(SUCCESS/REGENERATED/FAILURE) - 백엔드 알림 조회/읽음 API + close_and_decide 결과 분기마다 알림 생성 - 헤더 알림 벨(안읽음 배지) + 알림 페이지(읽음·딥링크) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b42cc41b5e
commit
1d111a031e
30 files changed
+995
-3
No files matched your search
@@ -7,7 +7,7 @@ from fastapi import Depends
|
||||
|
||||
from common.database.db_session_manager import DB_SESSION_MNG
|
||||
from common.database.model.models import quotations, sessions, chats, versions, version_nego_cards, version_wild_cards
|
||||
from common.enums import CloseOutcome, DBWRType, ErrorType, QuotationStatus, QuotationType, SessionStatus
|
||||
from common.enums import CloseOutcome, DBWRType, ErrorType, NotificationType, QuotationStatus, QuotationType, SessionStatus
|
||||
from common.logger import LOG
|
||||
from common.models.gmodel import PageParams
|
||||
from common.utils.gtime import GTime
|
||||
@@ -34,6 +34,7 @@ from router.v1.quotation.protocol import (
|
||||
TargetCandidate,
|
||||
)
|
||||
from services.email import EmailUnavailable, build_invite_email, send_email
|
||||
from services.notification import create_notification
|
||||
|
||||
|
||||
class QuotationService:
|
||||
@@ -620,6 +621,13 @@ class QuotationService:
|
||||
# 1) 단독 낙찰 → 확정
|
||||
if winner is not None:
|
||||
await self._award_and_close(qt_uuid, winner)
|
||||
winner_price = min((int(bp) for _, bp, _ in done if bp is not None), default=None)
|
||||
await create_notification(
|
||||
original.user_id, NotificationType.SUCCESS,
|
||||
{"qt_name": original.name, "qt_number": original.number,
|
||||
"winner_name": winner["name"], "winner_price": winner_price},
|
||||
ref_qt_id=qt_uuid,
|
||||
)
|
||||
return CloseOutcome.AWARDED
|
||||
|
||||
# 동가/미참여 재생성은 사유별 한도(각 1번, 순서 무관) 확인 후
|
||||
@@ -637,10 +645,21 @@ class QuotationService:
|
||||
f"code={regen.result.code}({regen.result.desc})"
|
||||
)
|
||||
return CloseOutcome.REGEN_FAILED
|
||||
await create_notification(
|
||||
original.user_id, NotificationType.REGENERATED,
|
||||
{"qt_name": original.name, "qt_number": original.number, "reason": "equal",
|
||||
"next_round": original.round + 1, "tied_price": equal["price"], "tied_count": len(equal["suppliers"])},
|
||||
ref_qt_id=regen.qt_id,
|
||||
)
|
||||
return CloseOutcome.REGENERATED
|
||||
# 3) 협상거부 있음 → 마감만 (재생성 안 함)
|
||||
if has_rejected:
|
||||
await self._just_close(qt_uuid)
|
||||
await create_notification(
|
||||
original.user_id, NotificationType.FAILURE,
|
||||
{"qt_name": original.name, "qt_number": original.number, "reason": "rejected"},
|
||||
ref_qt_id=qt_uuid,
|
||||
)
|
||||
return CloseOutcome.CLOSED
|
||||
# 4) 전원 미참여 → 공급사 전체로 다음 라운드 (체인에 미참여 재생성 이력 없을 때만)
|
||||
if not done and rows and no_part_used < self.MAX_REGEN_PER_CAUSE:
|
||||
@@ -654,9 +673,19 @@ class QuotationService:
|
||||
f"code={regen.result.code}({regen.result.desc})"
|
||||
)
|
||||
return CloseOutcome.REGEN_FAILED
|
||||
await create_notification(
|
||||
original.user_id, NotificationType.REGENERATED,
|
||||
{"qt_name": original.name, "qt_number": original.number, "reason": "no_show", "next_round": original.round + 1},
|
||||
ref_qt_id=regen.qt_id,
|
||||
)
|
||||
return CloseOutcome.REGENERATED
|
||||
# 5) 그 외 / 한도 도달 → 마감만
|
||||
await self._just_close(qt_uuid)
|
||||
await create_notification(
|
||||
original.user_id, NotificationType.FAILURE,
|
||||
{"qt_name": original.name, "qt_number": original.number, "reason": "closed"},
|
||||
ref_qt_id=qt_uuid,
|
||||
)
|
||||
return CloseOutcome.CLOSED
|
||||
|
||||
async def _chain_regen_counts(self, number: str, current_round: int) -> tuple[int, int]:
|
||||
|
||||
Reference in new issue
Block a user