88 lines
2.7 KiB
PHP
88 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Customer;
|
|
|
|
use App\Entities\Customer\AccountEntity;
|
|
use App\Entities\Customer\ClientEntity;
|
|
use App\Entities\PaymentEntity;
|
|
use App\Helpers\Customer\AccountHelper;
|
|
use App\Models\Customer\AccountModel;
|
|
|
|
class AccountService extends CustomerService
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new AccountModel(), new AccountHelper());
|
|
$this->addClassName('Account');
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"clientinfo_uid",
|
|
"bank",
|
|
"title",
|
|
"alias",
|
|
"issue_at",
|
|
"amount",
|
|
"status",
|
|
"content"
|
|
];
|
|
}
|
|
public function getFormFilters(): array
|
|
{
|
|
return [
|
|
"clientinfo_uid",
|
|
"bank",
|
|
"status",
|
|
];
|
|
}
|
|
public function getBatchjobFields(): array
|
|
{
|
|
return ['status'];
|
|
}
|
|
//고객예치금처리
|
|
private function setBalance(array $formDatas): ClientEntity
|
|
{
|
|
if (!array_key_exists('clientinfo_uid', $formDatas)) {
|
|
throw new \Exception("고객정보가 필요합니다.");
|
|
}
|
|
$entity = $this->getClientService()->getEntity($formDatas['clientinfo_uid']);
|
|
if (!$entity instanceof ClientEntity) {
|
|
throw new \Exception("{$formDatas['clientinfo_uid']}에 대한 고객정보를 찾을수 없습니다.");
|
|
}
|
|
return $this->getClientService()->setAccount($formDatas['status'], $entity, intval($formDatas['amount']));
|
|
}
|
|
//결제관련 예치금 차감 처리용
|
|
public function setPaid(PaymentEntity $paymentEntity): AccountEntity
|
|
{
|
|
$formDatas = [
|
|
'clientinfo_uid' => $paymentEntity->getClientInfoUID(),
|
|
'bank' => null,
|
|
'title' => "[결제차감] {$paymentEntity->getTitle()}",
|
|
'issue_at' => date('Y-m-d H:i:s'),
|
|
'amount' => $paymentEntity->getAmount(),
|
|
'status' => STATUS['PAID'],
|
|
];
|
|
$this->setBalance($formDatas);
|
|
return $this->getModel()->create($formDatas);
|
|
}
|
|
//기본 기능부분
|
|
//생성
|
|
protected function create_process(array $formDatas): AccountEntity
|
|
{
|
|
$this->setBalance($formDatas);
|
|
return parent::create_process($formDatas);
|
|
}
|
|
//수정
|
|
public function modify(mixed $entity, array $formDatas): AccountEntity
|
|
{
|
|
throw new \Exception("예치금은 수정하실 수 없습니다.");
|
|
}
|
|
//List 검색용
|
|
public function index_condition_filterWord(string $word): void
|
|
{
|
|
$this->getModel()->orLike($this->getModel()->getTable() . '.alias', $word, 'both');
|
|
parent::index_condition_filterWord($word);
|
|
}
|
|
}
|