98 lines
2.9 KiB
PHP
98 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Customer;
|
|
|
|
use App\Entities\Customer\ServiceEntity;
|
|
use App\Entities\Customer\ServiceItemEntity;
|
|
use App\Entities\Customer\PaymentEntity;
|
|
use App\Models\Customer\PaymentModel;
|
|
|
|
class PaymentService extends CustomerService
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new PaymentModel());
|
|
$this->addClassName('Payment');
|
|
}
|
|
public function getModelClass(): PaymentModel
|
|
{
|
|
return new PaymentModel();
|
|
}
|
|
public function getEntityClass(): PaymentEntity
|
|
{
|
|
return new PaymentEntity();
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"clientinfo_code",
|
|
"serviceinfo_code",
|
|
"title",
|
|
"amount",
|
|
"billing_method",
|
|
"billing_at",
|
|
"pay_method",
|
|
"status",
|
|
"updated_at"
|
|
];
|
|
}
|
|
public function getFilterFields(): array
|
|
{
|
|
return ['clientinfo_code', 'billing_method', 'pay_method', 'status', 'user_uid'];
|
|
}
|
|
public function getBatchJobFields(): array
|
|
{
|
|
return ['clientinfo_code', 'billing_method', 'pay_method', 'status'];
|
|
}
|
|
public function getIndexFields(): array
|
|
{
|
|
return ['clientinfo_code', 'billing_method', 'amount', 'billing_at', 'pay_method', 'status', 'countdown', 'user_uid'];
|
|
}
|
|
public function getBatchJobButtons(): array
|
|
{
|
|
return [
|
|
'invoice' => '청구서 발행',
|
|
];
|
|
}
|
|
//기본 기능부분
|
|
//FieldForm관련용
|
|
public function getFormFieldOption(string $field, array $options = []): array
|
|
{
|
|
switch ($field) {
|
|
case 'user_uid':
|
|
$options = $this->getUserService()->getEntities();
|
|
break;
|
|
case 'clientinfo_code':
|
|
$options = $this->getClientService()->getEntities();
|
|
break;
|
|
case 'serviceinfo_code':
|
|
$options = $this->getServiceService()->getEntities();
|
|
break;
|
|
default:
|
|
$options = parent::getFormFieldOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
//미납서비스 정보
|
|
final public function getUnPaidCount(): array
|
|
{
|
|
$sql = sprintf("SELECT serviceinfo_code,COUNT(*) as CNT
|
|
FROM payment
|
|
WHERE billing_at < NOW() AND amount > 0 AND status = '%s'
|
|
GROUP BY serviceinfo_code", PaymentEntity::DEFAULT_STATUS);
|
|
$unpaids = [];
|
|
foreach ($this->getModel()->query($sql)->getResult() as $row) {
|
|
$unpaids[$row->serverinfo_code] = $row->CNT;
|
|
}
|
|
return $unpaids;
|
|
}
|
|
//List 검색용
|
|
//OrderBy 처리
|
|
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
|
{
|
|
$this->getModel()->orderBy('billing_at ASC');
|
|
parent::setOrderBy($field, $value);
|
|
}
|
|
}
|