47 lines
1.8 KiB
PHP
47 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Equipment\Server;
|
|
|
|
use App\Entities\Customer\ServiceEntity;
|
|
use App\Entities\Equipment\ServerEntity;
|
|
use App\Interfaces\Equipment\ServerInterface;
|
|
use App\Services\Customer\ServiceService as ParentService;
|
|
|
|
//서버가격이 변한경우 서비스의 가격을 변경하기 위함.
|
|
class ServiceService extends ParentService implements ServerInterface
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function createServer(ServerEntity $serverEntity): ServerEntity
|
|
{
|
|
//아무것도 하지 않음
|
|
return $serverEntity;
|
|
}
|
|
public function modifyServer(ServerEntity $serverEntity): ServerEntity
|
|
{
|
|
//서비스정보가 NULL이 아니고 형식이 대체(alternative)가 아닌경우만 적용
|
|
if ($serverEntity->getServiceInfoUID() !== null && $serverEntity->getType() !== "alternative") {
|
|
//Service Entity 가져오기
|
|
$entity = $this->getEntity($serverEntity->getServiceInfoUID());
|
|
if (!$entity instanceof ServiceEntity) {
|
|
throw new \Exception("[{$serverEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
|
|
}
|
|
//서비스금액변경 사항이 있는지 확인후 처리
|
|
$entity = $this->setAmount($entity);
|
|
}
|
|
return $serverEntity;
|
|
}
|
|
public function deleteServer(ServerEntity $serverEntity): ServerEntity
|
|
{
|
|
//서비스중인지 확인
|
|
if ($serverEntity->getServiceInfoUID() !== null || $serverEntity->getStatus() === STATUS['OCCUPIED']) {
|
|
throw new \Exception("서비스중이 서버는 삭제하실수 없습니다.");
|
|
}
|
|
//아무것도 하지 않음
|
|
return $serverEntity;
|
|
}
|
|
}
|