65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Entities;
|
|
|
|
use App\Models\PaymentModel;
|
|
use DateTime;
|
|
|
|
class PaymentEntity extends CommonEntity
|
|
{
|
|
const PK = PaymentModel::PK;
|
|
const TITLE = PaymentModel::TITLE;
|
|
final public function getUserUID(): int|null
|
|
{
|
|
return $this->attributes['user_uid'] ?? null;
|
|
}
|
|
final public function getClientInfoUID(): int|null
|
|
{
|
|
return $this->attributes['clientinfo_uid'] ?? null;
|
|
}
|
|
final public function getServiceInfoUID(): int|null
|
|
{
|
|
return $this->attributes['serviceinfo_uid'] ?? null;
|
|
}
|
|
//기본기능
|
|
public function getBilling(): string
|
|
{
|
|
return $this->attributes['billing'];
|
|
}
|
|
public function getAmount(): int
|
|
{
|
|
return $this->attributes['amount'];
|
|
}
|
|
public function getBillingAt(): string
|
|
{
|
|
return $this->attributes['billing_at'];
|
|
}
|
|
public function getPay(): string|null
|
|
{
|
|
return $this->attributes['pay'];
|
|
}
|
|
public function getContent(): string|null
|
|
{
|
|
return $this->attributes['content'] ?? null;
|
|
}
|
|
public function getCountDueAt(): string
|
|
{
|
|
$result = "";
|
|
if ($this->getStatus() === STATUS['UNPAID']) {
|
|
$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;
|
|
}
|
|
}
|