- config/services.php에 barobill 설정 등록 (운영/테스트 모드 분기 정상화) - BarobillSetting 모델에 BelongsToTenant 적용 및 use_* 필드 casts 추가 - BarobillService API URL을 baroservice.com(SOAP)으로 수정 - BarobillService callApi 메서드 경로 하드코딩 제거 (서비스별 분기) - BarobillService 예외 이중 래핑 문제 수정 - BarobillController URL 메서드 중복 코드 제거 - 누락 모델 16개 생성 (MNG 패턴 준수, BelongsToTenant 적용) - 바로빌 전 테이블 options JSON 컬럼 추가 마이그레이션
109 lines
3.0 KiB
PHP
109 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Barobill;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class BarobillCardTransaction extends Model
|
|
{
|
|
use BelongsToTenant;
|
|
|
|
protected $table = 'barobill_card_transactions';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'card_num',
|
|
'card_company',
|
|
'card_company_name',
|
|
'use_dt',
|
|
'use_date',
|
|
'use_time',
|
|
'approval_num',
|
|
'approval_type',
|
|
'approval_amount',
|
|
'tax',
|
|
'service_charge',
|
|
'payment_plan',
|
|
'currency_code',
|
|
'merchant_name',
|
|
'merchant_biz_num',
|
|
'merchant_addr',
|
|
'merchant_ceo',
|
|
'merchant_biz_type',
|
|
'merchant_tel',
|
|
'memo',
|
|
'use_key',
|
|
'account_code',
|
|
'account_name',
|
|
'deduction_type',
|
|
'evidence_name',
|
|
'description',
|
|
'modified_supply_amount',
|
|
'modified_tax',
|
|
'is_manual',
|
|
];
|
|
|
|
protected $casts = [
|
|
'approval_amount' => 'decimal:2',
|
|
'tax' => 'decimal:2',
|
|
'service_charge' => 'decimal:2',
|
|
'modified_supply_amount' => 'decimal:2',
|
|
'modified_tax' => 'decimal:2',
|
|
'is_manual' => 'boolean',
|
|
];
|
|
|
|
// =========================================================================
|
|
// 관계 정의
|
|
// =========================================================================
|
|
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Tenants\Tenant::class);
|
|
}
|
|
|
|
// =========================================================================
|
|
// 접근자
|
|
// =========================================================================
|
|
|
|
/**
|
|
* 거래 고유 키 (cardNum|useDt|approvalNum|approvalAmount)
|
|
*/
|
|
public function getUniqueKeyAttribute(): string
|
|
{
|
|
return static::generateUniqueKey([
|
|
'card_num' => $this->card_num,
|
|
'use_dt' => $this->use_dt,
|
|
'approval_num' => $this->approval_num,
|
|
'approval_amount' => $this->approval_amount,
|
|
]);
|
|
}
|
|
|
|
// =========================================================================
|
|
// 헬퍼 메서드
|
|
// =========================================================================
|
|
|
|
public static function generateUniqueKey(array $data): string
|
|
{
|
|
return implode('|', [
|
|
$data['card_num'] ?? '',
|
|
$data['use_dt'] ?? '',
|
|
$data['approval_num'] ?? '',
|
|
$data['approval_amount'] ?? '0',
|
|
]);
|
|
}
|
|
|
|
public static function getByDateRange(int $tenantId, string $startDate, string $endDate, ?string $cardNum = null)
|
|
{
|
|
$query = static::where('tenant_id', $tenantId)
|
|
->whereBetween('use_date', [$startDate, $endDate]);
|
|
|
|
if ($cardNum) {
|
|
$query->where('card_num', $cardNum);
|
|
}
|
|
|
|
return $query->orderBy('use_date')->orderBy('use_dt')->get();
|
|
}
|
|
}
|