[feat] negodata/backend: 견적 협상대화에 사용 협상카드 내용 노출
QuotationCardData 에 number/edit_script/condition/memo 추가, card 카탈로그(nego/wild) 라이브 조인으로 채움. DB 컬럼 변경 없음(기존 카드 테이블 조인만 확장). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3280cab088
commit
df68609c49
5 files changed
+59
-7
No files matched your search
@@ -57,6 +57,21 @@ class QuotationService:
|
||||
if err_type != ErrorType.SUCCESS:
|
||||
res.result.SetResult(err_type)
|
||||
return res
|
||||
|
||||
# 참여 협력사 수(세션 distinct supplier)를 이 페이지 견적들에 대해 한 방으로 세서 합친다(메인 쿼리 비건드림).
|
||||
qt_ids = [r.qt_id for r in rows]
|
||||
counts = {}
|
||||
if qt_ids:
|
||||
cnt_err, got = await DB_SESSION_MNG.execute_lambda(
|
||||
quotations.DBType(),
|
||||
DBWRType.DB_READ.value,
|
||||
lambda s: self.quotation_crud.session_counts(s, qt_ids),
|
||||
)
|
||||
if cnt_err == ErrorType.SUCCESS:
|
||||
counts = got
|
||||
for r in rows:
|
||||
r.participation_count = counts.get(r.qt_id, 0)
|
||||
|
||||
res.quotations = [QuotationData.model_validate(r) for r in rows]
|
||||
res.total = total
|
||||
return res
|
||||
@@ -247,9 +262,10 @@ class QuotationService:
|
||||
return res
|
||||
|
||||
res.qt_id = quotation.qt_id
|
||||
# rows = [(chat_row, nego_card_id, name, script), ...]. nego/wild 구분은 chats.card_type.
|
||||
# rows = [(chat_row, card_id, number, name, script, edit_script, condition, memo), ...].
|
||||
# nego/wild 구분은 chats.card_type. condition/memo 는 와일드카드에만 존재.
|
||||
cards = []
|
||||
for chat_row, nc_id, nc_name, nc_script in rows:
|
||||
for chat_row, nc_id, nc_number, nc_name, nc_script, nc_edit, wc_condition, wc_memo in rows:
|
||||
is_wild = chat_row.card_type == 2
|
||||
cards.append(
|
||||
QuotationCardData(
|
||||
@@ -258,8 +274,12 @@ class QuotationService:
|
||||
nego_card_id=None if is_wild else nc_id,
|
||||
wild_card_id=nc_id if is_wild else None,
|
||||
type=chat_row.card_type if chat_row.card_type is not None else 1,
|
||||
number=nc_number,
|
||||
name=nc_name,
|
||||
script=nc_script,
|
||||
edit_script=nc_edit,
|
||||
condition=wc_condition if is_wild else None,
|
||||
memo=wc_memo if is_wild else None,
|
||||
)
|
||||
)
|
||||
res.cards = cards
|
||||
|
||||
Reference in new issue
Block a user