Files
sam-manage/app/Models/Barobill/BankSyncStatus.php
김보곤 1686198fcd feat:바로빌 계좌 입출금내역 API 캐싱 전략 구현
- BankSyncStatus 모델 추가 (월별 동기화 상태 추적)
- BankTransaction에 getCachedByMonth() 메서드 추가
- EaccountController fetchAccountTransactions() 캐싱 로직 적용
  - 과거 월: sync 레코드 존재 시 DB 캐시 반환
  - 현재 월: 10분 이내 sync이면 DB 캐시 반환, 초과 시 API 재호출
  - 미동기화: API 호출 → DB 자동 저장 → sync 상태 갱신
- cacheApiTransactions(): insertOrIgnore로 기존 레코드 보호
- convertDbToRawLog(): DB→SOAP 객체 변환 (기존 파싱 로직 호환)
- updateSyncStatus(): 동기화 상태 upsert

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 20:48:35 +09:00

34 lines
700 B
PHP

<?php
namespace App\Models\Barobill;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use App\Models\Tenants\Tenant;
/**
* 바로빌 계좌 거래 동기화 상태 모델
*
* 월별 API 동기화 완료 여부를 추적하여 캐시 판단에 사용
*/
class BankSyncStatus extends Model
{
protected $table = 'barobill_bank_sync_status';
protected $fillable = [
'tenant_id',
'bank_account_num',
'synced_year_month',
'synced_at',
];
protected $casts = [
'synced_at' => 'datetime',
];
public function tenant(): BelongsTo
{
return $this->belongsTo(Tenant::class);
}
}