summaryrefslogtreecommitdiff
path: root/lib/techsales-rfq/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/techsales-rfq/service.ts')
-rw-r--r--lib/techsales-rfq/service.ts33
1 files changed, 24 insertions, 9 deletions
diff --git a/lib/techsales-rfq/service.ts b/lib/techsales-rfq/service.ts
index fd50b7a6..44537876 100644
--- a/lib/techsales-rfq/service.ts
+++ b/lib/techsales-rfq/service.ts
@@ -15,7 +15,7 @@ import {
techSalesRfqItems,
biddingProjects
} from "@/db/schema";
-import { and, desc, eq, ilike, or, sql, inArray, count, asc } from "drizzle-orm";
+import { and, desc, eq, ilike, or, sql, inArray, count, asc, lt, ne } from "drizzle-orm";
import { unstable_cache } from "@/lib/unstable-cache";
import { filterColumns } from "@/lib/filter-columns";
import { getErrorMessage } from "@/lib/handle-error";
@@ -99,6 +99,15 @@ export async function getTechSalesRfqsWithJoin(input: GetTechSalesRfqsSchema & {
return unstable_cache(
async () => {
try {
+ // 마감일이 지났고 아직 Closed가 아닌 RFQ를 일괄 Closed로 변경
+ await db.update(techSalesRfqs)
+ .set({ status: "Closed", updatedAt: new Date() })
+ .where(
+ and(
+ lt(techSalesRfqs.dueDate, new Date()),
+ ne(techSalesRfqs.status, "Closed")
+ )
+ );
const offset = (input.page - 1) * input.perPage;
// 기본 필터 처리 - RFQFilterBox에서 오는 필터
@@ -1387,11 +1396,11 @@ export async function acceptTechSalesVendorQuotation(quotationId: number) {
return quotation
})
- // 메일 발송 (백그라운드에서 실행)
- // 선택된 벤더에게 견적 선택 알림 메일 발송
- sendQuotationAcceptedNotification(quotationId).catch(error => {
- console.error("벤더 견적 선택 알림 메일 발송 실패:", error);
- });
+ // // 메일 발송 (백그라운드에서 실행)
+ // // 선택된 벤더에게 견적 선택 알림 메일 발송
+ // sendQuotationAcceptedNotification(quotationId).catch(error => {
+ // console.error("벤더 견적 선택 알림 메일 발송 실패:", error);
+ // });
// 캐시 무효화
revalidateTag("techSalesVendorQuotations")
@@ -3359,9 +3368,15 @@ export async function getAcceptedTechSalesVendorQuotations(input: {
const offset = (input.page - 1) * input.perPage;
// 기본 WHERE 조건: status = 'Accepted'만 조회, rfqType이 'SHIP'이 아닌 것만
- const baseConditions = [
- eq(techSalesVendorQuotations.status, 'Accepted'),
- sql`${techSalesRfqs.rfqType} != 'SHIP'` // 조선 RFQ 타입 제외
+ // const baseConditions = [
+ // eq(techSalesVendorQuotations.status, 'Accepted'),
+ // sql`${techSalesRfqs.rfqType} != 'SHIP'` // 조선 RFQ 타입 제외
+ // ];
+ // 기본 WHERE 조건: status = 'Accepted'만 조회, rfqType이 'SHIP'이 아닌 것만
+ const baseConditions = [or(
+ eq(techSalesVendorQuotations.status, 'Submitted'),
+ eq(techSalesVendorQuotations.status, 'Accepted')
+ )
];
// 검색 조건 추가