summaryrefslogtreecommitdiff
path: root/lib/bidding/detail/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bidding/detail/service.ts')
-rw-r--r--lib/bidding/detail/service.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/bidding/detail/service.ts b/lib/bidding/detail/service.ts
index df8427da..b00a4f4f 100644
--- a/lib/bidding/detail/service.ts
+++ b/lib/bidding/detail/service.ts
@@ -632,7 +632,7 @@ export async function createBiddingDetailVendor(
companyId: vendorId,
invitationStatus: 'pending',
isPreQuoteSelected: true, // 본입찰 등록 기본값
- isWinner: false,
+ isWinner: null, // 미정 상태로 초기화 0916
createdAt: new Date(),
updatedAt: new Date(),
}).returning({ id: biddingCompanies.id })
@@ -679,13 +679,23 @@ export async function createQuotationVendor(input: any, userId: string) {
try {
const userName = await getUserNameById(userId)
const result = await db.transaction(async (tx) => {
+ // 0. 중복 체크 - 이미 해당 입찰에 참여중인 업체인지 확인
+ const existingCompany = await tx
+ .select()
+ .from(biddingCompanies)
+ .where(sql`${biddingCompanies.biddingId} = ${input.biddingId} AND ${biddingCompanies.companyId} = ${input.companyId}`)
+
+ if (existingCompany.length > 0) {
+ throw new Error('이미 등록된 업체입니다')
+ }
+
// 1. biddingCompanies에 레코드 생성
const biddingCompanyResult = await tx.insert(biddingCompanies).values({
biddingId: input.biddingId,
companyId: input.vendorId,
finalQuoteAmount: input.quotationAmount?.toString(),
awardRatio: input.awardRatio?.toString(),
- isWinner: false,
+ isWinner: null, // 미정 상태로 초기화
contactPerson: input.contactPerson,
contactEmail: input.contactEmail,
contactPhone: input.contactPhone,