diff options
Diffstat (limited to 'lib/bidding/detail/service.ts')
| -rw-r--r-- | lib/bidding/detail/service.ts | 135 |
1 files changed, 65 insertions, 70 deletions
diff --git a/lib/bidding/detail/service.ts b/lib/bidding/detail/service.ts index 39bf0c46..d0f8070f 100644 --- a/lib/bidding/detail/service.ts +++ b/lib/bidding/detail/service.ts @@ -1505,6 +1505,7 @@ export async function getBiddingListForPartners(companyId: number): Promise<Part respondedAt: biddingCompanies.respondedAt, finalQuoteAmount: biddingCompanies.finalQuoteAmount, finalQuoteSubmittedAt: biddingCompanies.finalQuoteSubmittedAt, + isFinalSubmission: biddingCompanies.isFinalSubmission, isWinner: biddingCompanies.isWinner, isAttendingMeeting: biddingCompanies.isAttendingMeeting, isPreQuoteSelected: biddingCompanies.isPreQuoteSelected, @@ -1624,6 +1625,7 @@ export async function getBiddingDetailsForPartners(biddingId: number, companyId: isPreQuoteSelected: biddingCompanies.isPreQuoteSelected, isBiddingParticipated: biddingCompanies.isBiddingParticipated, isPreQuoteParticipated: biddingCompanies.isPreQuoteParticipated, + isPriceAdjustmentApplicableQuestion: biddingCompanies.isPriceAdjustmentApplicableQuestion, hasSpecificationMeeting: biddings.hasSpecificationMeeting, // 응답한 조건들 (company_condition_responses) - 제시된 조건과 응답 모두 여기서 관리 paymentTermsResponse: companyConditionResponses.paymentTermsResponse, @@ -1811,37 +1813,37 @@ export async function submitPartnerResponse( // 임시저장: invitationStatus는 변경하지 않음 (bidding_accepted 유지) } - // 스냅샷은 임시저장/최종제출 관계없이 항상 생성 - if (response.prItemQuotations && response.prItemQuotations.length > 0) { - // 기존 스냅샷 조회 - const existingCompany = await tx - .select({ quotationSnapshots: biddingCompanies.quotationSnapshots }) - .from(biddingCompanies) - .where(eq(biddingCompanies.id, biddingCompanyId)) - .limit(1) - - const existingSnapshots = existingCompany[0]?.quotationSnapshots as any[] || [] - - // 새로운 스냅샷 생성 - const newSnapshot = { - id: Date.now().toString(), // 고유 ID - round: existingSnapshots.length + 1, // 차수 - submittedAt: new Date().toISOString(), - totalAmount: response.finalQuoteAmount, - currency: 'KRW', - isFinalSubmission: !!response.isFinalSubmission, - items: response.prItemQuotations.map(item => ({ - prItemId: item.prItemId, - bidUnitPrice: item.bidUnitPrice, - bidAmount: item.bidAmount, - proposedDeliveryDate: item.proposedDeliveryDate, - technicalSpecification: item.technicalSpecification - })) - } - - // 스냅샷 배열에 추가 - companyUpdateData.quotationSnapshots = [...existingSnapshots, newSnapshot] - } + // // 스냅샷은 임시저장/최종제출 관계없이 항상 생성 + // if (response.prItemQuotations && response.prItemQuotations.length > 0) { + // // 기존 스냅샷 조회 + // const existingCompany = await tx + // .select({ quotationSnapshots: biddingCompanies.quotationSnapshots }) + // .from(biddingCompanies) + // .where(eq(biddingCompanies.id, biddingCompanyId)) + // .limit(1) + + // const existingSnapshots = existingCompany[0]?.quotationSnapshots as any[] || [] + + // // 새로운 스냅샷 생성 + // const newSnapshot = { + // id: Date.now().toString(), // 고유 ID + // round: existingSnapshots.length + 1, // 차수 + // submittedAt: new Date().toISOString(), + // totalAmount: response.finalQuoteAmount, + // currency: 'KRW', + // isFinalSubmission: !!response.isFinalSubmission, + // items: response.prItemQuotations.map(item => ({ + // prItemId: item.prItemId, + // bidUnitPrice: item.bidUnitPrice, + // bidAmount: item.bidAmount, + // proposedDeliveryDate: item.proposedDeliveryDate, + // technicalSpecification: item.technicalSpecification + // })) + // } + + // // 스냅샷 배열에 추가 + // companyUpdateData.quotationSnapshots = [...existingSnapshots, newSnapshot] + // } } await tx @@ -2342,47 +2344,40 @@ export async function deleteBiddingDocument(documentId: number, biddingId: numbe } } -// 협력업체용 발주처 문서 조회 (캐시 적용) +// 협력업체용 발주처 문서 조회 (협력업체용 첨부파일만) export async function getBiddingDocumentsForPartners(biddingId: number) { - return unstable_cache( - async () => { - try { - const documents = await db - .select({ - id: biddingDocuments.id, - biddingId: biddingDocuments.biddingId, - companyId: biddingDocuments.companyId, - documentType: biddingDocuments.documentType, - fileName: biddingDocuments.fileName, - originalFileName: biddingDocuments.originalFileName, - fileSize: biddingDocuments.fileSize, - filePath: biddingDocuments.filePath, - title: biddingDocuments.title, - description: biddingDocuments.description, - uploadedAt: biddingDocuments.uploadedAt, - uploadedBy: biddingDocuments.uploadedBy - }) - .from(biddingDocuments) - .where( - and( - eq(biddingDocuments.biddingId, biddingId), - sql`${biddingDocuments.companyId} IS NULL`, // 발주처 문서만 - eq(biddingDocuments.isPublic, true) // 공개 문서만 - ) - ) - .orderBy(desc(biddingDocuments.uploadedAt)) + try { + const documents = await db + .select({ + id: biddingDocuments.id, + biddingId: biddingDocuments.biddingId, + companyId: biddingDocuments.companyId, + documentType: biddingDocuments.documentType, + fileName: biddingDocuments.fileName, + originalFileName: biddingDocuments.originalFileName, + fileSize: biddingDocuments.fileSize, + filePath: biddingDocuments.filePath, + title: biddingDocuments.title, + description: biddingDocuments.description, + uploadedAt: biddingDocuments.uploadedAt, + uploadedBy: biddingDocuments.uploadedBy + }) + .from(biddingDocuments) + .where( + and( + eq(biddingDocuments.biddingId, biddingId), + eq(biddingDocuments.documentType, 'company_proposal'), // 협력업체용 첨부파일만 + sql`${biddingDocuments.companyId} IS NULL`, // 발주처 문서만 + eq(biddingDocuments.isPublic, true) // 공개 문서만 + ) + ) + .orderBy(desc(biddingDocuments.uploadedAt)) - return documents - } catch (error) { - console.error('Failed to get bidding documents for partners:', error) - return [] - } - }, - [`bidding-documents-partners-${biddingId}`], - { - tags: [`bidding-${biddingId}`, 'bidding-documents'] - } - )() + return documents + } catch (error) { + console.error('Failed to get bidding documents for partners:', error) + return [] + } } // ================================================= |
