dbmsv2/app/Entities/Customer/PaymentEntity.php
2025-09-11 15:54:56 +09:00

49 lines
1.3 KiB
PHP

<?php
namespace App\Entities\Customer;
use App\Models\Customer\PaymentModel;
use DateTime;
class PaymentEntity extends CustomerEntity
{
const PK = PaymentModel::PK;
const TITLE = PaymentModel::TITLE;
const DEFAULT_STATUS = STATUS['UNPAID'];
public function getBilling(): string
{
return $this->attributes['billing'] ?? "";
}
public function getAmount(): int
{
return $this->attributes['amount'] ?? 0;
}
public function getBillingAt(): string
{
return $this->attributes['billing_at'] ?? "";
}
public function getPay(): string
{
return $this->attributes['pay'] ?? "";
}
public function getCountDueAt(): string
{
$result = "";
if ($this->getStatus() === self::DEFAULT_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;
}
}