diff options
Diffstat (limited to 'lib/bidding/detail/service.ts')
| -rw-r--r-- | lib/bidding/detail/service.ts | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/lib/bidding/detail/service.ts b/lib/bidding/detail/service.ts index 99591e3b..eec3f253 100644 --- a/lib/bidding/detail/service.ts +++ b/lib/bidding/detail/service.ts @@ -854,15 +854,14 @@ export async function registerBidding(biddingId: number, userId: string) { await db.transaction(async (tx) => { debugLog('registerBidding: Transaction started') - // 0. 입찰서 제출기간 계산 (오프셋 기반) + // 0. 입찰서 제출기간 계산 (입력값 절대 기준) const { submissionStartOffset, submissionDurationDays, submissionStartDate, submissionEndDate } = bidding let calculatedStartDate = bidding.submissionStartDate let calculatedEndDate = bidding.submissionEndDate - // 오프셋 값이 있으면 날짜 계산 if (submissionStartOffset !== null && submissionDurationDays !== null) { - // 시간 추출 (기본값: 시작 09:00, 마감 18:00) + // DB에 저장된 시간을 숫자 그대로 가져옴 (예: 10:00 저장 → 10 반환) const startTime = submissionStartDate ? { hours: submissionStartDate.getUTCHours(), minutes: submissionStartDate.getUTCMinutes() } : { hours: 9, minutes: 0 } @@ -870,22 +869,30 @@ export async function registerBidding(biddingId: number, userId: string) { ? { hours: submissionEndDate.getUTCHours(), minutes: submissionEndDate.getUTCMinutes() } : { hours: 18, minutes: 0 } - // baseDate = 현재일 날짜만 (00:00:00) - const baseDate = new Date() - baseDate.setHours(0, 0, 0, 0) - - // 시작일 = baseDate + offset일 + 시작시간 - calculatedStartDate = new Date(baseDate) - calculatedStartDate.setDate(calculatedStartDate.getDate() + submissionStartOffset) - calculatedStartDate.setHours(startTime.hours, startTime.minutes, 0, 0) - - // 마감일 = 시작일(날짜만) + duration일 + 마감시간 - calculatedEndDate = new Date(calculatedStartDate) - calculatedEndDate.setHours(0, 0, 0, 0) - calculatedEndDate.setDate(calculatedEndDate.getDate() + submissionDurationDays) - calculatedEndDate.setHours(endTime.hours, endTime.minutes, 0, 0) - - debugLog('registerBidding: Submission dates calculated', { + // 서버의 오늘 날짜(년/월/일)를 그대로 사용해 00:00 UTC 시점 생성 + const now = new Date() + const baseDate = new Date(Date.UTC( + now.getFullYear(), + now.getMonth(), + now.getDate(), + 0, 0, 0 + )) + + // 시작일 = baseDate + offset일 + 입력 시간(숫자 그대로) + const tempStartDate = new Date(baseDate) + tempStartDate.setUTCDate(tempStartDate.getUTCDate() + submissionStartOffset) + tempStartDate.setUTCHours(startTime.hours, startTime.minutes, 0, 0) + + // 마감일 = 시작일 날짜만 기준 + duration일 + 입력 마감 시간 + const tempEndDate = new Date(tempStartDate) + tempEndDate.setUTCHours(0, 0, 0, 0) + tempEndDate.setUTCDate(tempEndDate.getUTCDate() + submissionDurationDays) + tempEndDate.setUTCHours(endTime.hours, endTime.minutes, 0, 0) + + calculatedStartDate = tempStartDate + calculatedEndDate = tempEndDate + + debugLog('registerBidding: Submission dates calculated (Input Value Based)', { baseDate: baseDate.toISOString(), calculatedStartDate: calculatedStartDate.toISOString(), calculatedEndDate: calculatedEndDate.toISOString(), |
