From fc16886f05f8db277aafb9c60c0da2f1d4287745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Thu, 19 Feb 2026 10:10:38 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EA=B3=84=EC=A2=8C=EC=9E=85=EC=B6=9C?= =?UTF-8?q?=EA=B8=88=20=EC=A0=80=EC=9E=A5=20=EC=8B=9C=20=EB=8F=99=EC=9D=BC?= =?UTF-8?q?=20=EA=B1=B0=EB=9E=98=EC=9D=BC=EC=8B=9C=20=EB=A0=88=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=8D=AE=EC=96=B4=EC=93=B0=EA=B8=B0=20=EB=B0=A9?= =?UTF-8?q?=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기존: balance 제외 4컬럼 매칭 → 같은 시간/금액의 다른 거래가 중복으로 처리됨 - 수정: balance 포함 5컬럼 매칭 → DB unique 제약조건과 동일하게 정확히 식별 - update 시 balance 제외 (매칭 조건이므로 변경 불필요) Co-Authored-By: Claude Opus 4.6 --- app/Http/Controllers/Barobill/EaccountController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Barobill/EaccountController.php b/app/Http/Controllers/Barobill/EaccountController.php index 7b2813e0..573f9853 100644 --- a/app/Http/Controllers/Barobill/EaccountController.php +++ b/app/Http/Controllers/Barobill/EaccountController.php @@ -985,20 +985,21 @@ public function save(Request $request): JsonResponse $savedUniqueKeys[] = $uniqueKey; // 순수 Query Builder로 Upsert (Eloquent 모델 우회) - // balance 제외하고 매칭 → 같은 거래가 잔액만 다르게 들어와도 중복 방지 + // balance 포함하여 매칭 → DB unique 제약조건과 동일한 5개 컬럼으로 정확히 식별 $existingIds = DB::table('barobill_bank_transactions') ->where('tenant_id', $tenantId) ->where('bank_account_num', $data['bank_account_num']) ->where('trans_dt', $transDt) ->where('deposit', $data['deposit']) ->where('withdraw', $data['withdraw']) + ->where('balance', $data['balance']) ->orderByDesc('id') ->pluck('id'); if ($existingIds->isNotEmpty()) { $keepId = $existingIds->first(); // 최신 건 유지 - // 중복 건 삭제 (잔액만 다른 이전 레코드) + // 완전 동일한 중복 건 삭제 if ($existingIds->count() > 1) { DB::table('barobill_bank_transactions') ->whereIn('id', $existingIds->slice(1)->values()) @@ -1008,7 +1009,6 @@ public function save(Request $request): JsonResponse DB::table('barobill_bank_transactions') ->where('id', $keepId) ->update([ - 'balance' => $data['balance'], 'summary' => $data['summary'], 'cast' => $data['cast'], 'trans_office' => $data['trans_office'],