dbms/app/Entities/Customer/ServicePaymentEntity.php
2025-07-11 10:52:38 +09:00

73 lines
2.0 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;
const STATUS_UNPAID = "default";
const STATUS_PAID = "paid";
//관리자정보객체
final public function getServiceUid(): int
{
return intval($this->attributes['serviceinfo_uid']);
}
final public function getOwnerUID(): int
{
return intval($this->attributes['ownerinfo_uid']);
}
final public function getUserUID(): int
{
return intval($this->attributes['user_uid']);
}
final public function getService(): ServiceEntity|null
{
return $this->_serviceEntity;
}
final public function setService(ServiceEntity $serviceEntity): void
{
$this->_serviceEntity = $serviceEntity;
}
//타 객체정의 부분
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
{
$result = "";
if ($this->getStatus() === DEFAULTS['STATUS']) {
$now = new DateTime(); // 오늘 날짜
$due = new DateTime($this->getBillingAt());
if ($due < $now) {
$interval = $due->diff($now);
$result = "{$interval->days}일지남";
} else if ($due > $now) {
$interval = $now->diff($due);
$day = $interval->days + 1;
$result = "{$day}일전";
} else {
$result = "당일";
}
}
return $result;
}
}