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.ts87
1 files changed, 84 insertions, 3 deletions
diff --git a/lib/bidding/detail/service.ts b/lib/bidding/detail/service.ts
index 8f9bf018..c9aaa66c 100644
--- a/lib/bidding/detail/service.ts
+++ b/lib/bidding/detail/service.ts
@@ -854,6 +854,7 @@ export async function registerBidding(biddingId: number, userId: string) {
// 3. 선정된 업체들에게 본입찰 초대 메일 발송
debugLog('registerBidding: Sending emails...')
for (const company of selectedCompanies) {
+ // 벤더 메인 이메일로 발송
if (company.contactEmail) {
try {
await sendEmail({
@@ -879,6 +880,51 @@ export async function registerBidding(biddingId: number, userId: string) {
debugError(`Failed to send bidding invitation email to ${company.contactEmail}:`, emailError)
}
}
+
+ // 추가 담당자들에게도 이메일 발송
+ try {
+ const contactInfos = await db
+ .select({
+ contactName: biddingCompaniesContacts.contactName,
+ contactEmail: biddingCompaniesContacts.contactEmail
+ })
+ .from(biddingCompaniesContacts)
+ .where(and(
+ eq(biddingCompaniesContacts.biddingId, biddingId),
+ eq(biddingCompaniesContacts.vendorId, company.companyId)
+ ));
+
+ for (const contact of contactInfos) {
+ // 벤더 메인 이메일과 중복되지 않는 경우에만 발송
+ if (contact.contactEmail && contact.contactEmail !== company.contactEmail) {
+ try {
+ await sendEmail({
+ to: contact.contactEmail,
+ template: 'bidding-invitation',
+ context: {
+ companyName: company.companyName,
+ biddingNumber: bidding.biddingNumber,
+ title: bidding.title,
+ projectName: bidding.projectName,
+ itemName: bidding.itemName,
+ biddingType: bidding.biddingType,
+ submissionStartDate: bidding.submissionStartDate,
+ submissionEndDate: bidding.submissionEndDate,
+ biddingUrl: `${process.env.NEXT_PUBLIC_BASE_URL}/partners/bid/${biddingId}`,
+ bidPicName: bidding.bidPicName,
+ supplyPicName: bidding.supplyPicName,
+ language: 'ko'
+ }
+ })
+ debugLog(`registerBidding: Email sent to contact ${contact.contactEmail}`)
+ } catch (emailError) {
+ debugError(`Failed to send bidding invitation email to contact ${contact.contactEmail}:`, emailError)
+ }
+ }
+ }
+ } catch (contactError) {
+ debugError('Failed to fetch contact emails:', contactError)
+ }
}
// 4. 입찰 공고 SMS 알림 전송
debugLog('registerBidding: Sending SMS...')
@@ -1467,6 +1513,41 @@ export async function saveBiddingDraft(
}
}
+// 본입찰용 품목별 견적 조회 (협력업체용)
+export async function getPartnerBiddingItemQuotations(biddingCompanyId: number) {
+ try {
+ const savedQuotations = await db
+ .select({
+ prItemId: companyPrItemBids.prItemId,
+ bidUnitPrice: companyPrItemBids.bidUnitPrice,
+ bidAmount: companyPrItemBids.bidAmount,
+ proposedDeliveryDate: companyPrItemBids.proposedDeliveryDate,
+ technicalSpecification: companyPrItemBids.technicalSpecification,
+ currency: companyPrItemBids.currency
+ })
+ .from(companyPrItemBids)
+ .where(
+ and(
+ eq(companyPrItemBids.biddingCompanyId, biddingCompanyId),
+ eq(companyPrItemBids.isPreQuote, false) // 본입찰 데이터
+ )
+ )
+
+ // Decimal 타입을 number로 변환
+ return savedQuotations.map(item => ({
+ prItemId: item.prItemId,
+ bidUnitPrice: parseFloat(item.bidUnitPrice || '0'),
+ bidAmount: parseFloat(item.bidAmount || '0'),
+ proposedDeliveryDate: item.proposedDeliveryDate,
+ technicalSpecification: item.technicalSpecification,
+ currency: item.currency
+ }))
+ } catch (error) {
+ console.error('Failed to get partner bidding item quotations:', error)
+ return []
+ }
+}
+
// =================================================
// 협력업체 페이지용 함수들 (Partners)
// =================================================
@@ -1839,14 +1920,14 @@ export async function submitPartnerResponse(
// adjustmentDate: response.priceAdjustmentForm.adjustmentDate || null,
// nonApplicableReason: response.priceAdjustmentForm.nonApplicableReason,
// }
-
+ //
// // 기존 연동제 정보가 있는지 확인
// const existingPriceAdjustment = await tx
// .select()
// .from(priceAdjustmentForms)
// .where(eq(priceAdjustmentForms.companyConditionResponsesId, companyConditionResponseId))
// .limit(1)
-
+ //
// if (existingPriceAdjustment.length > 0) {
// // 업데이트
// await tx
@@ -2573,4 +2654,4 @@ export async function setSpecificationMeetingParticipation(biddingCompanyId: num
console.error('Failed to update specification meeting participation:', error)
return { success: false, error: '사양설명회 참여상태 업데이트에 실패했습니다.' }
}
-} \ No newline at end of file
+}