fix: [daily-fund] 일일자금일보 바로빌 데이터 자동 동기화 추가

- periodReport에서 데이터 조회 전 바로빌 API 자동 동기화 트리거
- BarobillBankSyncService 서비스 클래스 생성 (EaccountController 로직 분리)
- 현재 월 캐시 10분 만료, 과거 월 영구 캐시 정책 동일 적용
- 동기화 실패 시 기존 DB 캐시로 폴백 (서비스 중단 방지)
This commit is contained in:
김보곤
2026-03-11 09:55:50 +09:00
parent be1c984de0
commit ca36e8e54d
2 changed files with 383 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
use App\Models\Barobill\BankTransactionOverride;
use App\Models\Finance\DailyFundMemo;
use App\Models\Finance\DailyFundTransaction;
use App\Services\Barobill\BarobillBankSyncService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -173,6 +174,13 @@ public function periodReport(Request $request): JsonResponse
$startDateYmd = str_replace('-', '', $startDate);
$endDateYmd = str_replace('-', '', $endDate);
// 바로빌 데이터 자동 동기화 (캐시가 오래되었으면 API에서 갱신)
try {
app(BarobillBankSyncService::class)->syncIfNeeded($tenantId, $startDateYmd, $endDateYmd);
} catch (\Throwable $e) {
\Illuminate\Support\Facades\Log::warning('[DailyFund] 바로빌 동기화 실패 (DB 캐시로 계속): '.$e->getMessage());
}
// 기간 내 거래내역 조회 (중복 제거: balance 포함 고유키로 동일 거래만 제거)
$transactions = BarobillBankTransaction::where('tenant_id', $tenantId)
->whereBetween('trans_date', [$startDateYmd, $endDateYmd])