dbms/app/Entities/Customer/ServicePaymentEntity.php
2025-06-12 19:09:31 +09:00

48 lines
1.2 KiB
PHP

<?php
namespace App\Entities\Customer;
use App\Models\Customer\ServicePaymentModel;
use DateTime;
class ServicePaymentEntity extends CustomerEntity
{
const PK = ServicePaymentModel::PK;
const TITLE = ServicePaymentModel::TITLE;
public function getServiceUid(): int
{
return intval($this->attributes['serviceinfo_uid']);
}
public function getItemType(): string
{
return $this->attributes['item_type'];
}
public function getItemUid(): int
{
return intval($this->attributes['item_uid']);
}
public function getAmount(): int
{
return intval($this->attributes['amount']);
}
public function getBillingAt(): string
{
return $this->attributes['billing_at'];
}
public function getView_CounDueAt(): string
{
$now = new DateTime(); // 오늘 날짜
$due = new DateTime($this->getBillingAt());
if ($due < $now) {
$interval = $due->diff($now);
return "{$interval->days}일 전";
} else if ($due > $now) {
$interval = $now->diff($due);
return "{$interval->days}일 남음";
} else {
return "당일";
}
}
}