Files
sam-manage/app/Console/Commands/SyncBarobillCardTransactions.php
김보곤 0e2ea39328 feat: [barobill] 카드 사용내역 자동 동기화 스케줄러 추가
- BarobillCardSyncService: 전체/테넌트별 카드거래 자동 동기화
- SyncBarobillCardTransactions: artisan 커맨드 (barobill:sync-cards)
- 2시간마다 영업시간(08~22시) 자동 실행
- 신규 거래 자동 등록, 기존 거래 바로빌 원본 필드만 갱신 (사용자 편집 보존)
2026-03-19 19:03:57 +09:00

41 lines
1.4 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Services\Barobill\BarobillCardSyncService;
use Illuminate\Console\Command;
class SyncBarobillCardTransactions extends Command
{
protected $signature = 'barobill:sync-cards
{--tenant= : 특정 테넌트만 동기화}
{--days=7 : 동기화 대상 일수 (기본 7일)}';
protected $description = '바로빌 카드 사용내역 자동 동기화 (전체 테넌트)';
public function handle(BarobillCardSyncService $service): int
{
$tenantId = $this->option('tenant');
$days = (int) $this->option('days');
if ($tenantId) {
$this->info("테넌트 {$tenantId} 카드 동기화 시작 (최근 {$days}일)");
$result = $service->syncTenant((int) $tenantId, $days);
$this->info("완료: 신규 {$result['created']}건, 갱신 {$result['updated']}");
} else {
$this->info("전체 테넌트 카드 동기화 시작 (최근 {$days}일)");
$result = $service->syncAll($days);
$this->info("완료: {$result['synced']}개 테넌트, 신규 {$result['created']}건, 갱신 {$result['updated']}");
if (! empty($result['errors'])) {
$this->warn('오류 발생:');
foreach ($result['errors'] as $error) {
$this->error(" - {$error}");
}
}
}
return self::SUCCESS;
}
}