dbmsv2/app/Services/Equipment/ServerPart/PaymentService.php
2025-09-24 11:00:04 +09:00

68 lines
3.3 KiB
PHP

<?php
namespace App\Services\Equipment\ServerPart;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\PaymentEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\PaymentService as ParentService;
//이 클래스는 일회성일때만 실행된다.
class PaymentService extends ParentService implements ServerPartInterface
{
public function __construct()
{
parent::__construct();
}
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): 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['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->getCaculatedAmount(); //단가*cnt
$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 = parent::create($formDatas);
//서버연결정보 Entity에 결제정보 설정
return $serverPartEntity->setPaymentEntity($entity);
}
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{
//결제정보 가져오기
$entity = $serverPartEntity->getPaymentEntity();
if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버파트연결정보{$serverPartEntity->getPK()}]에 해당하는 결제정보를 찾을수 없습니다.");
}
//필수정보처리 후 FormData 가져오기
$formDatas = $this->action_process($serverPartEntity);
//결제정보수정
$entity = parent::modify($entity, $formDatas);
//서버연결정보 Entity에 결제정보 설정
return $serverPartEntity->setPaymentEntity($entity);
}
public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{
//삭제시에는 아무것도 하지 않는다.
return $serverPartEntity;
}
}