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.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/bidding/detail/service.ts b/lib/bidding/detail/service.ts
index b5a3cce8..6ab9270e 100644
--- a/lib/bidding/detail/service.ts
+++ b/lib/bidding/detail/service.ts
@@ -610,6 +610,40 @@ export async function updateBiddingDetailVendor(
}
}
+// 발주비율 취소 (발주비율을 null로 리셋하고 낙찰 상태 해제)
+export async function cancelAwardRatio(biddingCompanyId: number) {
+ try {
+ const result = await db.update(biddingCompanies)
+ .set({
+ awardRatio: null,
+ isWinner: false,
+ updatedAt: new Date(),
+ })
+ .where(eq(biddingCompanies.id, biddingCompanyId))
+ .returning({ biddingId: biddingCompanies.biddingId })
+
+ // 캐시 무효화
+ if (result.length > 0) {
+ const biddingId = result[0].biddingId
+ revalidateTag(`bidding-${biddingId}`)
+ revalidateTag('quotation-vendors')
+ revalidateTag('quotation-details')
+ revalidatePath(`/evcp/bid/${biddingId}`)
+ }
+
+ return {
+ success: true,
+ message: '발주비율이 성공적으로 취소되었습니다.',
+ }
+ } catch (error) {
+ console.error('Failed to cancel award ratio:', error)
+ return {
+ success: false,
+ error: error instanceof Error ? error.message : '발주비율 취소에 실패했습니다.'
+ }
+ }
+}
+
// 본입찰용 업체 추가
export async function createBiddingDetailVendor(
biddingId: number,