- config/services.php에 barobill 설정 등록 (운영/테스트 모드 분기 정상화) - BarobillSetting 모델에 BelongsToTenant 적용 및 use_* 필드 casts 추가 - BarobillService API URL을 baroservice.com(SOAP)으로 수정 - BarobillService callApi 메서드 경로 하드코딩 제거 (서비스별 분기) - BarobillService 예외 이중 래핑 문제 수정 - BarobillController URL 메서드 중복 코드 제거 - 누락 모델 16개 생성 (MNG 패턴 준수, BelongsToTenant 적용) - 바로빌 전 테이블 options JSON 컬럼 추가 마이그레이션
98 lines
2.7 KiB
PHP
98 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Barobill;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class BarobillBankTransaction extends Model
|
|
{
|
|
use BelongsToTenant;
|
|
|
|
protected $table = 'barobill_bank_transactions';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'bank_account_num',
|
|
'bank_code',
|
|
'bank_name',
|
|
'trans_date',
|
|
'trans_time',
|
|
'trans_dt',
|
|
'deposit',
|
|
'withdraw',
|
|
'balance',
|
|
'summary',
|
|
'cast',
|
|
'memo',
|
|
'trans_office',
|
|
'account_code',
|
|
'account_name',
|
|
'is_manual',
|
|
'client_code',
|
|
'client_name',
|
|
];
|
|
|
|
protected $casts = [
|
|
'deposit' => 'decimal:2',
|
|
'withdraw' => 'decimal:2',
|
|
'balance' => 'decimal:2',
|
|
'is_manual' => 'boolean',
|
|
];
|
|
|
|
// =========================================================================
|
|
// 관계 정의
|
|
// =========================================================================
|
|
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Tenants\Tenant::class);
|
|
}
|
|
|
|
// =========================================================================
|
|
// 접근자
|
|
// =========================================================================
|
|
|
|
/**
|
|
* 거래 고유 키 (계좌번호|거래일시|입금|출금|잔액)
|
|
*/
|
|
public function getUniqueKeyAttribute(): string
|
|
{
|
|
return static::generateUniqueKey([
|
|
'bank_account_num' => $this->bank_account_num,
|
|
'trans_dt' => $this->trans_dt,
|
|
'deposit' => $this->deposit,
|
|
'withdraw' => $this->withdraw,
|
|
'balance' => $this->balance,
|
|
]);
|
|
}
|
|
|
|
// =========================================================================
|
|
// 헬퍼 메서드
|
|
// =========================================================================
|
|
|
|
public static function generateUniqueKey(array $data): string
|
|
{
|
|
return implode('|', [
|
|
$data['bank_account_num'] ?? '',
|
|
$data['trans_dt'] ?? '',
|
|
$data['deposit'] ?? '0',
|
|
$data['withdraw'] ?? '0',
|
|
$data['balance'] ?? '0',
|
|
]);
|
|
}
|
|
|
|
public static function getByDateRange(int $tenantId, string $startDate, string $endDate, ?string $accountNum = null)
|
|
{
|
|
$query = static::where('tenant_id', $tenantId)
|
|
->whereBetween('trans_date', [$startDate, $endDate]);
|
|
|
|
if ($accountNum) {
|
|
$query->where('bank_account_num', $accountNum);
|
|
}
|
|
|
|
return $query->orderBy('trans_date')->orderBy('trans_dt')->get();
|
|
}
|
|
}
|