69 lines
3.2 KiB
PHP
69 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Payment;
|
|
|
|
use App\Entities\Equipment\ServerPartEntity;
|
|
use App\Entities\PaymentEntity;
|
|
use App\Interfaces\Equipment\ServerPartInterface;
|
|
use App\Services\PaymentService;
|
|
|
|
class ServerPart extends PaymentService implements ServerPartInterface
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
private function action_process(ServerPartEntity $serverPartEntity): array
|
|
{
|
|
if ($serverPartEntity->getServiceInfoUID() === null) {
|
|
throw new \Exception(__METHOD__ . "에서 오류발생: 서비스정보가 정의된 후에만 가능합니다.");
|
|
}
|
|
//일회인이 아닌경우
|
|
if ($serverPartEntity->getBilling() !== PAYMENT['BILLING']['ONETIME']) {
|
|
throw new \Exception(__METHOD__ . "에서 오류발생: :" . lang("{$this->getClassName()}.BILLING." . PAYMENT['BILLING'][$serverPartEntity->getBilling()]) . "지급 상품은 처리가 불가, 일회성만 가능합니다.");
|
|
}
|
|
|
|
$formDatas = [];
|
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
|
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); //서버연결정보 수정시에 필요함
|
|
//타이틀은 기타의 경우 직접작성한 제목을 등록하고 아닌경우는 Part의 Title을 사용한다.
|
|
$formDatas['title'] = $serverPartEntity->getType() === 'ETC' ? $serverPartEntity->getTitle() : $serverPartEntity->getPartEntity()->getTitle();
|
|
$formDatas['amount'] = $serverPartEntity->getAmount();
|
|
$formDatas['billing'] = $serverPartEntity->getBilling();
|
|
return $formDatas;
|
|
}
|
|
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
|
{
|
|
//필수정보처리 후 FormData 가져오기
|
|
$formDatas = $this->action_process($serverPartEntity);
|
|
//당일결체일로 설정
|
|
$formDatas['billing_at'] = date("Y-m-d");
|
|
//결제정보등록
|
|
$entity = $this->create($formDatas);
|
|
//서버연결정보 Entity에 결제정보 설정
|
|
return $serverPartEntity->setPaymentEntity($entity);
|
|
}
|
|
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
|
{
|
|
//미납상태의 결제정보 가져오기
|
|
$entity = $this->getEntity(['serverpartinfo_uid' => $serverPartEntity->getPK(), 'status' => STATUS['UNPAID']]);
|
|
if (!$entity instanceof PaymentEntity) {
|
|
throw new \Exception(__METHOD__ . "에서 오류발생: {$serverPartEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
|
|
}
|
|
//필수정보처리 후 FormData 가져오기
|
|
$formDatas = $this->action_process($serverPartEntity);
|
|
//결제정보수정
|
|
$entity = $this->modify($entity, $formDatas);
|
|
//서버연결정보 Entity에 결제정보 설정
|
|
return $serverPartEntity->setPaymentEntity($entity);
|
|
}
|
|
|
|
public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
|
{
|
|
//삭제시에는 아무것도 하지 않는다.
|
|
return $serverPartEntity;
|
|
}
|
|
}
|