69 lines
1.9 KiB
PHP
69 lines
1.9 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 STATUS_UNPAID = "unpaid";
|
|
const STATUS_PAID = "paid";
|
|
const DEFAULT_STATUS = self::STATUS_UNPAID; // 기본 상태는 미지급(unpaid)
|
|
//관리자정보객체
|
|
final public function getUserUID(): int
|
|
{
|
|
return intval($this->attributes['user_uid']);
|
|
}
|
|
final public function getClientCode(): int
|
|
{
|
|
return intval($this->attributes['clientinfo_code']);
|
|
}
|
|
final public function getServiceCode(): int
|
|
{
|
|
return intval($this->attributes['serviceinfo_code']);
|
|
}
|
|
//타 객체정의 부분
|
|
public function getItemType(): string
|
|
{
|
|
return $this->attributes['item_type'];
|
|
}
|
|
public function getIsOnetime(): int
|
|
{
|
|
return intval($this->attributes['isOnetime']);
|
|
}
|
|
public function getAmount(): int
|
|
{
|
|
return intval($this->attributes['amount']);
|
|
}
|
|
public function getBillingAt(): string
|
|
{
|
|
return $this->attributes['billing_at'];
|
|
}
|
|
public function getPayMethod(): string
|
|
{
|
|
return $this->attributes['pay_method'];
|
|
}
|
|
public function getCountDueAt(): string
|
|
{
|
|
$result = "";
|
|
if ($this->getStatus() === self::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;
|
|
}
|
|
}
|