Files
sam-manage/app/Models/Barobill/BarobillMember.php
김보곤 425e0e79d6 refactor:바로빌 서버 모드를 회원사별 개별 설정으로 변경
기존 전역 세션 기반 서버 모드 → 회원사별 개별 설정 방식으로 변경

주요 변경사항:
- BarobillMember 모델: server_mode 필드 및 accessor 추가
- BarobillService: switchServerMode() 메서드 추가 (동적 서버 전환)
- BarobillMemberController: 회원사별 서버 모드 변경 API 추가
- 회원사 목록 테이블: 서버 모드 컬럼 추가 (클릭 시 변경 모달)
- 서버 변경 확인 모달: 요금 부과 경고 및 동의 체크박스 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 07:48:13 +09:00

122 lines
2.9 KiB
PHP

<?php
namespace App\Models\Barobill;
use App\Models\Tenants\Tenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class BarobillMember extends Model
{
use SoftDeletes;
protected $table = 'barobill_members';
protected $fillable = [
'tenant_id',
'biz_no',
'corp_name',
'ceo_name',
'addr',
'biz_type',
'biz_class',
'barobill_id',
'barobill_pwd',
'manager_name',
'manager_email',
'manager_hp',
'status',
'server_mode',
];
protected $casts = [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
'barobill_pwd' => 'encrypted', // 복호화 가능한 암호화 (바로빌 API 호출 시 필요)
];
protected $hidden = [
'barobill_pwd',
];
/**
* 테넌트 관계
*/
public function tenant(): BelongsTo
{
return $this->belongsTo(Tenant::class);
}
/**
* 사업자번호 포맷팅 (XXX-XX-XXXXX)
*/
public function getFormattedBizNoAttribute(): string
{
$bizNo = preg_replace('/[^0-9]/', '', $this->biz_no);
if (strlen($bizNo) === 10) {
return substr($bizNo, 0, 3) . '-' . substr($bizNo, 3, 2) . '-' . substr($bizNo, 5);
}
return $this->biz_no;
}
/**
* 상태 라벨
*/
public function getStatusLabelAttribute(): string
{
return match ($this->status) {
'active' => '활성',
'inactive' => '비활성',
'pending' => '대기중',
default => $this->status,
};
}
/**
* 상태별 색상 클래스
*/
public function getStatusColorAttribute(): string
{
return match ($this->status) {
'active' => 'bg-green-100 text-green-800',
'inactive' => 'bg-gray-100 text-gray-800',
'pending' => 'bg-yellow-100 text-yellow-800',
default => 'bg-gray-100 text-gray-800',
};
}
/**
* 서버 모드 라벨
*/
public function getServerModeLabelAttribute(): string
{
return match ($this->server_mode) {
'test' => '테스트',
'production' => '운영',
default => '테스트',
};
}
/**
* 서버 모드별 색상 클래스
*/
public function getServerModeColorAttribute(): string
{
return match ($this->server_mode) {
'test' => 'bg-amber-100 text-amber-800',
'production' => 'bg-green-100 text-green-800',
default => 'bg-amber-100 text-amber-800',
};
}
/**
* 테스트 모드 여부
*/
public function isTestMode(): bool
{
return $this->server_mode !== 'production';
}
}