summaryrefslogtreecommitdiff
path: root/lib/bidding/detail
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bidding/detail')
-rw-r--r--lib/bidding/detail/service.ts109
1 files changed, 1 insertions, 108 deletions
diff --git a/lib/bidding/detail/service.ts b/lib/bidding/detail/service.ts
index 6ab9270e..39bf0c46 100644
--- a/lib/bidding/detail/service.ts
+++ b/lib/bidding/detail/service.ts
@@ -918,114 +918,6 @@ export async function registerBidding(biddingId: number, userId: string) {
}
}
-// 재입찰 생성 (기존 입찰의 revision 업데이트 + 메일 발송)
-export async function createRebidding(biddingId: number, userId: string) {
- try {
- // 기존 입찰 정보 조회
- const bidding = await db
- .select()
- .from(biddings)
- .where(eq(biddings.id, biddingId))
- .limit(1)
-
- if (bidding.length === 0) {
- return { success: false, error: '입찰을 찾을 수 없습니다.' }
- }
-
- const originalBidding = bidding[0]
-
- // 기존 입찰 참여 업체들 조회
- const participantCompanies = await db
- .select({
- companyId: biddingCompanies.companyId,
- companyName: vendors.vendorName,
- contactEmail: vendors.email
- })
- .from(biddingCompanies)
- .leftJoin(vendors, eq(biddingCompanies.companyId, vendors.id))
- .where(and(
- eq(biddingCompanies.biddingId, biddingId),
- eq(biddingCompanies.isBiddingParticipated, true)
- ))
- const userName = await getUserNameById(userId)
- // 기존 입찰의 revision 증가 및 상태 변경
- const updatedBidding = await db
- .update(biddings)
- .set({
- revision: (originalBidding.revision || 0) + 1,
- status: 'bidding_opened', // 재입찰 시 다시 오픈 상태로
- updatedBy: userName,
- updatedAt: new Date()
- })
- .where(eq(biddings.id, biddingId))
- .returning({
- id: biddings.id,
- biddingNumber: biddings.biddingNumber,
- revision: biddings.revision
- })
-
- if (updatedBidding.length === 0) {
- return { success: false, error: '재입찰 업데이트에 실패했습니다.' }
- }
-
- // // 참여 업체들의 상태를 대기로 변경
- // await db
- // .update(biddingCompanies)
- // .set({
- // isBiddingParticipated: null, // 대기 상태로 변경
- // invitationStatus: 'sent',
- // updatedAt: new Date()
- // })
- // .where(and(
- // eq(biddingCompanies.biddingId, biddingId),
- // eq(biddingCompanies.isBiddingParticipated, true)
- // ))
-
- // 재입찰 안내 메일 발송
- for (const company of participantCompanies) {
- if (company.contactEmail) {
- try {
- await sendEmail({
- to: company.contactEmail,
- template: 'rebidding-invitation',
- context: {
- companyName: company.companyName,
- biddingNumber: updatedBidding[0].biddingNumber,
- title: originalBidding.title,
- projectName: originalBidding.projectName,
- itemName: originalBidding.itemName,
- biddingType: originalBidding.biddingType,
- revision: updatedBidding[0].revision || 1,
- submissionStartDate: originalBidding.submissionStartDate,
- submissionEndDate: originalBidding.submissionEndDate,
- biddingUrl: `${process.env.NEXT_PUBLIC_BASE_URL}/partners/bid/${biddingId}`,
- bidPicName: originalBidding.bidPicName,
- supplyPicName: originalBidding.supplyPicName,
- language: 'ko'
- }
- })
- } catch (emailError) {
- console.error(`Failed to send rebidding email to ${company.contactEmail}:`, emailError)
- }
- }
- }
-
- // 캐시 무효화
- revalidateTag(`bidding-${biddingId}`)
- revalidateTag('quotation-vendors')
- revalidateTag('quotation-details')
- revalidatePath('/evcp/bid')
- revalidatePath(`/evcp/bid/${biddingId}`)
-
- return {
- success: true,
- message: `재입찰이 성공적으로 처리되었습니다. ${participantCompanies.length}개 업체에 안내 메일을 발송했습니다.`
- }
- } catch (error) {
- console.error('Failed to create rebidding:', error)
- return { success: false, error: '재입찰 처리에 실패했습니다.' }
- }
-}
// 업체 선정 사유 업데이트
export async function updateVendorSelectionReason(biddingId: number, selectedCompanyId: number, selectionReason: string, userId: string) {
@@ -1559,6 +1451,7 @@ export interface PartnersBiddingListItem {
respondedAt: string | null
finalQuoteAmount: number | null
finalQuoteSubmittedAt: string | null
+ isFinalSubmission: boolean | null
isWinner: boolean | null
isAttendingMeeting: boolean | null
isPreQuoteSelected: boolean | null