dbmsv2 init...1

This commit is contained in:
choi.jh 2025-09-23 10:43:27 +09:00
parent 97e7bcdb0c
commit b3adf1835b
15 changed files with 189 additions and 343 deletions

View File

@ -6,9 +6,7 @@ use App\Entities\Customer\ServiceEntity;
interface ServiceInterface extends CustomerInterface interface ServiceInterface extends CustomerInterface
{ {
public function setServiceEntity(ServiceEntity $entity): self; public function createService(ServiceEntity $serviceEntity): ServiceEntity;
public function getServiceEntity(): ServiceEntity; public function modifyService(ServiceEntity $serviceEntity): ServiceEntity;
public function createService(): ServiceEntity; public function deleteService(ServiceEntity $serviceEntity): ServiceEntity;
public function modifyService(): ServiceEntity;
public function deleteService(): ServiceEntity;
} }

View File

@ -6,9 +6,7 @@ use App\Entities\Equipment\ServerPartEntity;
interface ServerPartInterface extends EquipmentInterface interface ServerPartInterface extends EquipmentInterface
{ {
public function setServerPartEntity(ServerPartEntity $entity): self; public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity;
public function getServerPartEntity(): ServerPartEntity; public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity;
public function createServerPart(): ServerPartEntity; public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity;
public function modifyServerPart(): ServerPartEntity;
public function deleteServerPart(): ServerPartEntity;
} }

View File

@ -9,58 +9,48 @@ use App\Interfaces\Customer\ServiceInterface;
class PaymentService extends ParentService implements ServiceInterface class PaymentService extends ParentService implements ServiceInterface
{ {
private ?ServiceEntity $_serviceEntity = null;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function setServiceEntity(ServiceEntity $entity): self private function action_process(ServiceEntity $serviceEntity, array $formDatas = []): array
{ {
$this->_serviceEntity = $entity; $formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
return $this; $formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
} $formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
public function getServiceEntity(): ServiceEntity $formDatas['title'] = $serviceEntity->getServerEntity()->getTitle();
{ $formDatas['amount'] = $serviceEntity->getAmount();
if (!$this->_serviceEntity instanceof ServiceEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서비스정보가 정의되지 않았습니다.");
}
return $this->_serviceEntity;
}
private function action_process(array $formDatas = []): array
{
$formDatas['clientinfo_uid'] = $this->getServiceEntity()->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $this->getServiceEntity()->getPK();
$formDatas['serverinfo_uid'] = $this->getServiceEntity()->getServerInfoUID();
$formDatas['title'] = $this->getServiceEntity()->getServerEntity()->getTitle();
$formDatas['amount'] = $this->getServiceEntity()->getAmount();
$formDatas['billing'] = PAYMENT['BILLING']['MONTH']; $formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
$formDatas['billing_at'] = $this->getServiceEntity()->getBillingAt(); $formDatas['billing_at'] = $serviceEntity->getBillingAt();
return $formDatas; return $formDatas;
} }
public function createService(): ServiceEntity public function createService(ServiceEntity $serviceEntity): ServiceEntity
{ {
//필수정보처리 후 결제정보등록 //필수정보처리 후 결제정보등록
$entity = $this->create($this->action_process()); $entity = $this->create($this->action_process($serviceEntity));
//서비스정보 Entity에 결제정보 설정 //서비스정보 Entity에 결제정보 설정
return $this->getServiceEntity()->setPaymentEntity($entity); return $serviceEntity->setPaymentEntity($entity);
} }
public function modifyService(): ServiceEntity public function modifyService(ServiceEntity $serviceEntity): ServiceEntity
{ {
//미납상태의 결제정보 가져오기 //결제정보 가져오기
$entity = $this->getEntity(['serviceinfo_uid' => $this->getServiceEntity()->getPK(), 'status' => STATUS['UNPAID']]); $entity = $serviceEntity->getPaymentEntity();
if (!$entity instanceof PaymentEntity) { if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: {$this->getServiceEntity()->getPK()}에 해당하는 결제정보를 찾을수 없습니다."); throw new \Exception(__METHOD__ . "에서 오류발생: {$serviceEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
}
//미납상태확인
if ($entity->getStatus() !== STATUS['UNPAID']) {
throw new \Exception(__METHOD__ . "에서 오류발생: 완료된 결제는 수정이 불가합니다.");
} }
//필수정보처리 후 결제정보수정 //필수정보처리 후 결제정보수정
$entity = $this->modify($entity, $this->action_process()); $entity = $this->modify($entity, $this->action_process($serviceEntity));
//서비스정보 Entity에 결제정보 설정 //서비스정보 Entity에 결제정보 설정
return $this->getServiceEntity()->setPaymentEntity($entity); return $serviceEntity->setPaymentEntity($entity);
} }
public function deleteService(): ServiceEntity public function deleteService(ServiceEntity $serviceEntity): ServiceEntity
{ {
//삭제시에는 아무것도 하지 않는다. //삭제시에는 아무것도 하지 않는다.
return $this->getServiceEntity(); return $serviceEntity;
} }
} }

View File

@ -9,60 +9,46 @@ use App\Interfaces\Customer\ServiceInterface;
class ServerService extends ParentService implements ServiceInterface class ServerService extends ParentService implements ServiceInterface
{ {
private ?ServiceEntity $_serviceEntity = null;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
final public function setServiceEntity(ServiceEntity $entity): self private function action_process(ServiceEntity $serviceEntity, array $formDatas = []): ServerEntity
{
$this->_serviceEntity = $entity;
return $this;
}
public function getServiceEntity(): ServiceEntity
{
if (!$this->_serviceEntity instanceof ServiceEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서브스정보가 정의되지 않았습니다.");
}
return $this->_serviceEntity;
}
private function action_process(array $formDatas = []): ServerEntity
{ {
if (!array_key_exists('status', $formDatas)) { if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버상태가 설정되지 않았습니다."); throw new \Exception(__METHOD__ . "에서 오류발생: 서버상태가 설정되지 않았습니다.");
} }
//서버정보 가져오기 //서버정보 가져오기
$entity = $this->getEntity(['serviceinfo_uid' => $this->getServiceEntity()->getPK()]); $entity = $this->getEntity(['serviceinfo_uid' => $serviceEntity->getPK()]);
if (!$entity instanceof ServerEntity) { if (!$entity instanceof ServerEntity) {
throw new \Exception("서비스정보[{$this->getServiceEntity()->getPK()}]에 해당하는 서버정보를 찾을수없습니다."); throw new \Exception("서비스정보[{$serviceEntity->getPK()}]에 해당하는 서버정보를 찾을수없습니다.");
} }
//서버정보 수정 //서버정보 수정
return $this->modify($entity, $formDatas); return $this->modify($entity, $formDatas);
} }
public function createService(): ServiceEntity public function createService(ServiceEntity $serviceEntity): ServiceEntity
{ {
$formDatas = []; $formDatas = [];
$formDatas['clientinfo_uid'] = $this->getServiceEntity()->getClientInfoUID(); $formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $this->getServiceEntity()->getPK(); $formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas['status'] = STATUS['OCCUPIED']; $formDatas['status'] = STATUS['OCCUPIED'];
$entity = $this->action_process($formDatas); $entity = $this->action_process($serviceEntity, $formDatas);
//서비스정보 Entity에 서버정보 설정 //서비스정보 Entity에 서버정보 설정
return $this->getServiceEntity()->setServerEntity($entity); return $serviceEntity->setServerEntity($entity);
} }
public function modifyService(): ServiceEntity public function modifyService(ServiceEntity $serviceEntity): ServiceEntity
{ {
return $this->createService(); return $this->createService($serviceEntity);
} }
public function deleteService(): ServiceEntity public function deleteService(ServiceEntity $serviceEntity): ServiceEntity
{ {
$formDatas = []; $formDatas = [];
$formDatas['clientinfo_uid'] = null; $formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null; $formDatas['serviceinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE']; $formDatas['status'] = STATUS['AVAILABLE'];
$entity = $this->action_process($formDatas); $entity = $this->action_process($serviceEntity, $formDatas);
//서비스정보 Entity에 서버정보 설정 //서비스정보 Entity에 서버정보 설정
return $this->getServiceEntity()->setServerEntity($entity); return $serviceEntity->setServerEntity($entity);
} }
} }

View File

@ -215,21 +215,25 @@ class ServiceService extends CustomerService
} }
//기본기능 //기본기능
//Action 기능 //Action 기능
private function action_process(ServiceEntity $entity, string $action): ServiceEntity
{
//서버정보수정
$entity = $this->getServerService()->$action($entity);
$entity = $this->getPaymentService()->$action($entity);
//결제정보PK정의
$entity = parent::modify($entity, ['payment_uid' => $entity->getPaymentEntity()->getPK()]);
return $entity;
}
//생성 //생성
public function create(array $formDatas): ServiceEntity public function create(array $formDatas): ServiceEntity
{ {
if (!array_key_exists('serverinfo_uid', $formDatas)) { if (!array_key_exists('serverinfo_uid', $formDatas)) {
throw new \Exception("서버가 지정되지 않았습니다."); throw new \Exception("서버가 지정되지 않았습니다.");
} }
//신규등록 //신규등록(월청구액 전달값 그대로 사용)
$entity = $this->getEntity(parent::create($formDatas)->getPK()); $entity = $this->getEntity(parent::create($formDatas)->getPK());
//신규 서버정보수정 //후처리작업
$entity->getServerService()->setServiceEntity($entity)->modifyService(); return $this->action_process($entity, __FUNCTION__ . 'Service');
//신규 결제정보등록
$entity = $this->getPaymentService()->setServiceEntity($entity)->createService();
//신규 결제정보PK수정
$entity = parent::modify($entity, ['payment_uid' => $entity->getPaymentEntity()->getPK()]);
return $entity;
} }
//수정 //수정
public function modify(mixed $entity, array $formDatas): ServiceEntity public function modify(mixed $entity, array $formDatas): ServiceEntity
@ -237,27 +241,23 @@ class ServiceService extends CustomerService
if (!array_key_exists('serverinfo_uid', $formDatas)) { if (!array_key_exists('serverinfo_uid', $formDatas)) {
throw new \Exception("서버가 지정되지 않았습니다."); throw new \Exception("서버가 지정되지 않았습니다.");
} }
//기존 서버파트정보 //기존 서버정보 해지
if ($entity->getServerEntity()->getPK() !== $formDatas['serverinfo_uid']) { if ($entity->getServerEntity()->getPK() !== $formDatas['serverinfo_uid']) {
//기존 서버정보 해지 $entity->getServerService()->deleteService($entity);
$entity->getServerService()->setServiceEntity($entity)->deleteService();
} }
//수정작업 //수정작업(월청구액계산 확인 후 서비스정보에 수정)
//월청구액계산 확인 후 서비스정보에 수정
$entity = $this->getEntity(parent::modify( $entity = $this->getEntity(parent::modify(
$entity, $entity,
['amount' => $this->getServerService()->getTotalAmount($entity->getServerEntity()->getPK())] ['amount' => $this->getServerService()->getTotalAmount($entity->getServerEntity()->getPK())]
)->getPK()); )->getPK());
//신규 서버정보수정 //후처리작업
$entity->getServerService()->setServiceEntity($entity)->modifyService(); return $this->action_process($entity, __FUNCTION__ . 'Service');
return $entity;
} }
//삭제 //삭제
public function delete(mixed $entity): ServiceEntity public function delete(mixed $entity): ServiceEntity
{ {
//서버정보 해지 $entity = parent::delete($entity);
$entity->getServerService()->setServiceEntity($entity)->deleteService(); //후처리작업
//결제정보는 하지않음 return $this->action_process($entity, __FUNCTION__ . 'Service');
return parent::delete($entity);
} }
} }

View File

@ -9,61 +9,47 @@ use App\Services\Equipment\CSService as ParentService;
class CSService extends ParentService implements ServerPartInterface class CSService extends ParentService implements ServerPartInterface
{ {
private ?ServerPartEntity $_serverPartEntity = null;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function setServerPartEntity(ServerPartEntity $entity): self
{
$this->_serverPartEntity = $entity;
return $this;
}
public function getServerPartEntity(): ServerPartEntity
{
if (!$this->_serverPartEntity instanceof ServerPartEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버파트정보가 정의되지 않았습니다.");
}
return $this->_serverPartEntity;
}
//서버연결정보용 등록 //서버연결정보용 등록
private function action_process(array $formDatas = []): CSEntity private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): CSEntity
{ {
if (!array_key_exists('status', $formDatas)) { if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: CS상태가 설정되지 않았습니다."); throw new \Exception(__METHOD__ . "에서 오류발생: CS상태가 설정되지 않았습니다.");
} }
//CS정보가져오기 //CS정보가져오기
$entity = $this->getEntity($this->getServerPartEntity()->getPartUID()); $entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof CSEntity) { if (!$entity instanceof CSEntity) {
throw new \Exception("{$this->getServerPartEntity()->getPartUID()}에 해당하는 CS정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
} }
//CS정보 수정 //CS정보 수정
return $this->modify($entity, $formDatas); return $this->modify($entity, $formDatas);
} }
public function createServerPart(): ServerPartEntity public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
$formDatas = []; $formDatas = [];
$formDatas['clientinfo_uid'] = $this->getServerPartEntity()->getClientInfoUID(); $formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $this->getServerPartEntity()->getServiceInfoUID(); $formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $this->getServerPartEntity()->getServerInfoUID(); $formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['status'] = STATUS['OCCUPIED']; $formDatas['status'] = STATUS['OCCUPIED'];
$entity = $this->action_process($formDatas); $entity = $this->action_process($serverPartEntity, $formDatas);
return $this->getServerPartEntity()->setPartEntity($entity); return $serverPartEntity->setPartEntity($entity);
} }
public function modifyServerPart(): ServerPartEntity public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
return $this->createServerPart(); return $this->createServerPart($serverPartEntity);
} }
public function deleteServerPart(): ServerPartEntity public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
$formDatas = []; $formDatas = [];
$formDatas['clientinfo_uid'] = null; $formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null; $formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null; $formDatas['serverinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE']; $formDatas['status'] = STATUS['AVAILABLE'];
$entity = $this->action_process($formDatas); $entity = $this->action_process($serverPartEntity, $formDatas);
return $this->getServerPartEntity()->setPartEntity($entity); return $serverPartEntity->setPartEntity($entity);
} }
} }

View File

@ -9,61 +9,47 @@ use App\Services\Equipment\IPService as ParentService;
class IPService extends ParentService implements ServerPartInterface class IPService extends ParentService implements ServerPartInterface
{ {
private ?ServerPartEntity $_serverPartEntity = null;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function setServerPartEntity(ServerPartEntity $entity): self
{
$this->_serverPartEntity = $entity;
return $this;
}
public function getServerPartEntity(): ServerPartEntity
{
if (!$this->_serverPartEntity instanceof ServerPartEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버파트정보가 정의되지 않았습니다.");
}
return $this->_serverPartEntity;
}
//서버연결정보용 등록 //서버연결정보용 등록
private function action_process(array $formDatas = []): IPEntity private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): IPEntity
{ {
if (!array_key_exists('status', $formDatas)) { if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: IP상태가 설정되지 않았습니다."); throw new \Exception(__METHOD__ . "에서 오류발생: IP상태가 설정되지 않았습니다.");
} }
//IP정보가져오기 //IP정보가져오기
$entity = $this->getEntity($this->getServerPartEntity()->getPartUID()); $entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof IPEntity) { if (!$entity instanceof IPEntity) {
throw new \Exception("{$this->getServerPartEntity()->getPartUID()}에 해당하는 IP정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
} }
//IP정보 수정 //IP정보 수정
return $this->modify($entity, $formDatas); return $this->modify($entity, $formDatas);
} }
public function createServerPart(): ServerPartEntity public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
$formDatas = []; $formDatas = [];
$formDatas['clientinfo_uid'] = $this->getServerPartEntity()->getClientInfoUID(); $formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $this->getServerPartEntity()->getServiceInfoUID(); $formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $this->getServerPartEntity()->getServerInfoUID(); $formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['status'] = STATUS['OCCUPIED']; $formDatas['status'] = STATUS['OCCUPIED'];
$entity = $this->action_process($formDatas); $entity = $this->action_process($serverPartEntity, $formDatas);
return $this->getServerPartEntity()->setPartEntity($entity); return $serverPartEntity->setPartEntity($entity);
} }
public function modifyServerPart(): ServerPartEntity public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
return $this->createServerPart(); return $this->createServerPart($serverPartEntity);
} }
public function deleteServerPart(): ServerPartEntity public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
$formDatas = []; $formDatas = [];
$formDatas['clientinfo_uid'] = null; $formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null; $formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null; $formDatas['serverinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE']; $formDatas['status'] = STATUS['AVAILABLE'];
$entity = $this->action_process($formDatas); $entity = $this->action_process($serverPartEntity, $formDatas);
return $this->getServerPartEntity()->setPartEntity($entity); return $serverPartEntity->setPartEntity($entity);
} }
} }

View File

@ -9,58 +9,45 @@ use App\Services\Equipment\PartService as ParentService;
class PartService extends ParentService implements ServerPartInterface class PartService extends ParentService implements ServerPartInterface
{ {
private ?ServerPartEntity $_serverPartEntity = null;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function setServerPartEntity(ServerPartEntity $entity): self
{
$this->_serverPartEntity = $entity;
return $this;
}
public function getServerPartEntity(): ServerPartEntity
{
if (!$this->_serverPartEntity instanceof ServerPartEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버파트정보가 정의되지 않았습니다.");
}
return $this->_serverPartEntity;
}
//서버연결정보용 등록 //서버연결정보용 등록
private function action_process(string $action): PartEntity private function action_process(ServerPartEntity $serverPartEntity, string $action): PartEntity
{ {
//부품정보가져오기 //부품정보가져오기
$entity = $this->getEntity($this->getServerPartEntity()->getPartUID()); $entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof PartEntity) { if (!$entity instanceof PartEntity) {
throw new \Exception("{$this->getServerPartEntity()->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
} }
//부품정보에 서버정보 설정 및 서비스,고객정보 정의 //부품정보에 서버정보 설정 및 서비스,고객정보 정의
$formDatas = []; $formDatas = [];
if ($action === "return") { //해지된 부품 재고 반납 처리 if ($action === "return") { //해지된 부품 재고 반납 처리
$formDatas['stock'] = $entity->getStock() + $this->getServerPartEntity()->getCnt(); $formDatas['stock'] = $entity->getStock() + $serverPartEntity->getCnt();
} }
if ($action === "use") { //사용된 부품 재고 사용처리 if ($action === "use") { //사용된 부품 재고 사용처리
if ($entity->getStock() < $this->getServerPartEntity()->getCnt()) { if ($entity->getStock() < $serverPartEntity->getCnt()) {
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$this->getServerPartEntity()->getCnt()})가 더 많습니다."); throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
} }
$formDatas['stock'] = $entity->getStock() - $this->getServerPartEntity()->getCnt(); $formDatas['stock'] = $entity->getStock() - $serverPartEntity->getCnt();
} }
return $this->modify($entity, $formDatas); return $this->modify($entity, $formDatas);
} }
public function createServerPart(): ServerPartEntity public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
$entity = $this->action_process("use"); $entity = $this->action_process($serverPartEntity, "use");
return $this->getServerPartEntity()->setPartEntity($entity); return $serverPartEntity->setPartEntity($entity);
} }
public function modifyServerPart(): ServerPartEntity public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
return $this->createServerPart(); return $this->createServerPart($serverPartEntity,);
} }
public function deleteServerPart(): ServerPartEntity public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
$entity = $this->action_process("return"); $entity = $this->action_process($serverPartEntity, "return");
return $this->getServerPartEntity()->setPartEntity($entity); return $serverPartEntity->setPartEntity($entity);
} }
} }

View File

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

View File

@ -1,57 +0,0 @@
<?php
namespace App\Services\Equipment\ServerPart;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\Equipment\ServerService as ParentService;
class ServerService extends ParentService implements ServerPartInterface
{
private ?ServerPartEntity $_serverPartEntity = null;
public function __construct()
{
parent::__construct();
}
public function setServerPartEntity(ServerPartEntity $entity): self
{
$this->_serverPartEntity = $entity;
return $this;
}
public function getServerPartEntity(): ServerPartEntity
{
if (!$this->_serverPartEntity instanceof ServerPartEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버파트정보가 정의되지 않았습니다.");
}
return $this->_serverPartEntity;
}
//월과금은 해당 서비스의 항목별 금액을 총 합산후 청구금액을 설정후 결제정보에 신규등록/수정한다
private function action_process(): ServerEntity
{
//Service Entity 가져오기
$entity = $this->getEntity($this->getServerPartEntity()->getServiceInfoUID());
if (!$entity instanceof ServerEntity) {
throw new \Exception("[{$this->getServerPartEntity()->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
}
//서비스금액은 modify 함수내에서 재계산을 하므로 여기서는 modify만 호출함
return parent::modify($entity, []);
}
public function createServerPart(): ServerPartEntity
{
//필수정보처리 후 FormData 가져오기
$this->action_process();
return $this->getServerPartEntity();
}
public function modifyServerPart(): ServerPartEntity
{
return $this->createServerPart();
}
public function deleteServerPart(): ServerPartEntity
{
return $this->createServerPart();
}
}

View File

@ -10,48 +10,33 @@ use App\Services\Customer\ServiceService as ParentService;
class ServiceService extends ParentService implements ServerPartInterface class ServiceService extends ParentService implements ServerPartInterface
{ {
private ?ServerPartEntity $_serverPartEntity = null;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
private function action_process(ServerPartEntity $serverPartEntity): ServiceEntity
public function setServerPartEntity(ServerPartEntity $entity): self
{
$this->_serverPartEntity = $entity;
return $this;
}
public function getServerPartEntity(): ServerPartEntity
{
if (!$this->_serverPartEntity instanceof ServerPartEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버파트정보가 정의되지 않았습니다.");
}
return $this->_serverPartEntity;
}
//월과금은 해당 서비스의 항목별 금액을 총 합산후 청구금액을 설정후 결제정보에 신규등록/수정한다
private function action_process(): ServiceEntity
{ {
//Service Entity 가져오기 //Service Entity 가져오기
$entity = $this->getEntity($this->getServerPartEntity()->getServiceInfoUID()); $entity = $this->getEntity($serverPartEntity->getServiceInfoUID());
if (!$entity instanceof ServiceEntity) { if (!$entity instanceof ServiceEntity) {
throw new \Exception("[{$this->getServerPartEntity()->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다."); throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
} }
//서비스금액은 modify 함수내에서 재계산을 하므로 여기서는 modify만 호출함 //서비스금액은 modify 함수내에서 재계산을 하므로 여기서는 modify만 호출함
return parent::modify($entity, []); return parent::modify($entity, []);
} }
public function createServerPart(): ServerPartEntity public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
//필수정보처리 후 FormData 가져오기 $this->action_process($serverPartEntity);
$this->action_process(); return $serverPartEntity;
return $this->getServerPartEntity();
} }
public function modifyServerPart(): ServerPartEntity //create와 같은 작업임
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
return $this->createServerPart(); return $this->createServerPart($serverPartEntity);
} }
public function deleteServerPart(): ServerPartEntity //create와 같은 작업임
public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
return $this->createServerPart(); return $this->createServerPart($serverPartEntity);
} }
} }

View File

@ -9,61 +9,47 @@ use App\Services\Equipment\SwitchService as ParentService;
class SwitchService extends ParentService implements ServerPartInterface class SwitchService extends ParentService implements ServerPartInterface
{ {
private ?ServerPartEntity $_serverPartEntity = null;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function setServerPartEntity(ServerPartEntity $entity): self
{
$this->_serverPartEntity = $entity;
return $this;
}
public function getServerPartEntity(): ServerPartEntity
{
if (!$this->_serverPartEntity instanceof ServerPartEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버파트정보가 정의되지 않았습니다.");
}
return $this->_serverPartEntity;
}
//서버연결정보용 등록 //서버연결정보용 등록
private function action_process(array $formDatas = []): SwitchEntity private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): SwitchEntity
{ {
if (!array_key_exists('status', $formDatas)) { if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: Switch상태가 설정되지 않았습니다."); throw new \Exception(__METHOD__ . "에서 오류발생: Switch상태가 설정되지 않았습니다.");
} }
//Switch정보가져오기 //Switch정보가져오기
$entity = $this->getEntity($this->getServerPartEntity()->getPartUID()); $entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof SwitchEntity) { if (!$entity instanceof SwitchEntity) {
throw new \Exception("{$this->getServerPartEntity()->getPartUID()}에 해당하는 Switch정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 Switch정보를 찾을수없습니다.");
} }
//Switch정보 수정 //Switch정보 수정
return $this->modify($entity, $formDatas); return $this->modify($entity, $formDatas);
} }
public function createServerPart(): ServerPartEntity public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
$formDatas = []; $formDatas = [];
$formDatas['clientinfo_uid'] = $this->getServerPartEntity()->getClientInfoUID(); $formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $this->getServerPartEntity()->getServiceInfoUID(); $formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $this->getServerPartEntity()->getServerInfoUID(); $formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['status'] = STATUS['OCCUPIED']; $formDatas['status'] = STATUS['OCCUPIED'];
$entity = $this->action_process($formDatas); $entity = $this->action_process($serverPartEntity, $formDatas);
return $this->getServerPartEntity()->setPartEntity($entity); return $serverPartEntity->setPartEntity($entity);
} }
public function modifyServerPart(): ServerPartEntity public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
return $this->createServerPart(); return $this->createServerPart($serverPartEntity);
} }
public function deleteServerPart(): ServerPartEntity public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
$formDatas = []; $formDatas = [];
$formDatas['clientinfo_uid'] = null; $formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null; $formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null; $formDatas['serverinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE']; $formDatas['status'] = STATUS['AVAILABLE'];
$entity = $this->action_process($formDatas); $entity = $this->action_process($serverPartEntity, $formDatas);
return $this->getServerPartEntity()->setPartEntity($entity); return $serverPartEntity->setPartEntity($entity);
} }
} }

View File

@ -8,13 +8,13 @@ use App\Entities\PaymentEntity;
use App\Helpers\Equipment\ServerPartHelper; use App\Helpers\Equipment\ServerPartHelper;
use App\Models\Equipment\ServerPartModel; use App\Models\Equipment\ServerPartModel;
use App\Services\Equipment\EquipmentService; use App\Services\Equipment\EquipmentService;
use App\Services\Equipment\ServerPart\ServiceService;
use App\Services\Equipment\ServerPart\ServerService;
use App\Services\Equipment\ServerPart\CSService; use App\Services\Equipment\ServerPart\CSService;
use App\Services\Equipment\ServerPart\IPService; use App\Services\Equipment\ServerPart\IPService;
use App\Services\Equipment\ServerPart\PartService; use App\Services\Equipment\ServerPart\PartService;
use App\Services\Equipment\ServerPart\SwitchService;
use App\Services\Equipment\ServerPart\PaymentService; use App\Services\Equipment\ServerPart\PaymentService;
use App\Services\Equipment\ServerPart\ServiceService;
use App\Services\Equipment\ServerPart\SwitchService;
use App\Services\Equipment\ServerService;
class ServerPartService extends EquipmentService class ServerPartService extends EquipmentService
{ {
@ -214,28 +214,30 @@ class ServerPartService extends EquipmentService
case 'DISK': case 'DISK':
case 'OS': case 'OS':
case 'DB': case 'DB':
case 'SOFTWARE': case 'SOFTWARE': //재고수 처리 필요
$entity = $this->getPartService()->$action($entity); $entity = $this->getPartService()->$action($entity);
break; break;
case 'SWITCH': case 'SWITCH': //사용여부 처리 필요
$entity = $this->getSwitchService()->$action($entity); $entity = $this->getSwitchService()->$action($entity);
break; break;
case 'IP': case 'IP': //사용여부 처리 필요
$entity = $this->getIPService()->$action($entity); $entity = $this->getIPService()->$action($entity);
break; break;
case 'CS': case 'CS': //사용여부 처리 필요
$entity = $this->getCSService()->$action($entity); $entity = $this->getCSService()->$action($entity);
break; break;
} }
//서비스 및 결제정보 처리 //서비스 및 결제정보 처리
switch ($entity->getBilling()) { switch ($entity->getBilling()) {
case PAYMENT['BILLING']['MONTH']: //월별 case PAYMENT['BILLING']['MONTH']: //월별과금일때만 처리
$entity = $this->getServiceService()->$action($entity); $entity = $this->getServiceService()->$action($entity);
break; break;
case PAYMENT['BILLING']['ONETIME']: //일회성 case PAYMENT['BILLING']['ONETIME']: //일회성일때만 처리
$entity = $this->getPaymentService()->$action($entity); $entity = $this->getPaymentService()->$action($entity);
//결제정보PK정의
$entity = parent::modify($entity, ['payment_uid' => $entity->getPaymentEntity()->getPK()]);
break; break;
case PAYMENT['BILLING']['BASE']: //기본 case PAYMENT['BILLING']['BASE']: //기본처리
//아무처리 않함 //아무처리 않함
break; break;
default: default:
@ -248,25 +250,24 @@ class ServerPartService extends EquipmentService
public function create(array $formDatas): ServerPartEntity public function create(array $formDatas): ServerPartEntity
{ {
//서버정보가져오기 //서버정보가져오기
$serverEntity = null; if (!array_key_exists('serverinfo_uid', $formDatas)) {
if (array_key_exists('serverEntity', $formDatas)) { throw new \Exception("서버 정보가 지정되지 않았습니다.");
$serverEntity = $formDatas['serverEntity'];
} else {
if (!array_key_exists('serverinfo_uid', $formDatas)) {
throw new \Exception("서버 정보가 지정되지 않았습니다.");
}
$serverEntity = $this->getServerService()->getEntity($formDatas['serverinfo_uid']);
} }
$serverEntity = $this->getServerService()->getEntity($formDatas['serverinfo_uid']);
if (!$serverEntity instanceof ServerEntity) { if (!$serverEntity instanceof ServerEntity) {
throw new \Exception("서버 정보가 지정되지 않았습니다."); throw new \Exception("서버 정보가 지정되지 않았습니다.");
} }
//서비스정의확인(기본은 제외)
if ($formDatas['billing'] !== PAYMENT['BILLING']['BASE'] && $serverEntity->getServiceInfoUID() === null) {
throw new \Exception(__METHOD__ . "에서 오류발생:{월,일회성 과금용은 서비스가 지정되어야 작업이 가능합니다.");
}
//생성작업 //생성작업
$formDatas["clientinfo_uid"] = $serverEntity->getClientInfoUID(); $formDatas["clientinfo_uid"] = $serverEntity->getClientInfoUID();
$formDatas["serviceinfo_uid"] = $serverEntity->getServiceInfoUID(); $formDatas["serviceinfo_uid"] = $serverEntity->getServiceInfoUID();
$formDatas["serverinfo_uid"] = $serverEntity->getPK(); $formDatas["serverinfo_uid"] = $serverEntity->getPK();
$entity = parent::create($formDatas); $entity = parent::create($formDatas);
//부품연결정보관련 정보처리 //후처리작업
return $this->action_process($entity, __FUNCTION__ . 'ServerPart'); return $this->action_process($entity, __FUNCTION__ . 'ServerPart');
} }
//수정 //수정
public function modify(mixed $entity, array $formDatas): ServerPartEntity public function modify(mixed $entity, array $formDatas): ServerPartEntity
@ -288,15 +289,16 @@ class ServerPartService extends EquipmentService
$formDatas["serviceinfo_uid"] = $serverEntity->getServiceInfoUID(); $formDatas["serviceinfo_uid"] = $serverEntity->getServiceInfoUID();
$formDatas["serverinfo_uid"] = $serverEntity->getPK(); $formDatas["serverinfo_uid"] = $serverEntity->getPK();
$entity = parent::modify($entity, $formDatas); $entity = parent::modify($entity, $formDatas);
//수정 부품연결정보관련 정보처리 //후처리작업
$entity = $this->action_process($entity, __FUNCTION__ . 'ServerPart'); $entity = $this->action_process($entity, __FUNCTION__ . 'ServerPart');
return $entity; return $entity;
} }
//삭제 //삭제
public function delete(mixed $entity): ServerPartEntity public function delete(mixed $entity): ServerPartEntity
{ {
//부품연결정보관련 정보처리 $entity = parent::delete($entity);
//후처리작업
$entity = $this->action_process($entity, __FUNCTION__ . 'ServerPart'); $entity = $this->action_process($entity, __FUNCTION__ . 'ServerPart');
return parent::delete($entity); return $entity;
} }
} }

View File

@ -20,6 +20,7 @@
</div> </div>
<div class="col-4"> <div class="col-4">
<?= $this->include("{$viewDatas['layout']}/welcome/user_history"); ?> <?= $this->include("{$viewDatas['layout']}/welcome/user_history"); ?>
<?= $this->include("{$viewDatas['layout']}/welcome/stock"); ?>
</div> </div>
</div> </div>
<!-- Layout Right End --> <!-- Layout Right End -->

View File

@ -0,0 +1,13 @@
<div class="layout_header" style="margin-top:20px;">
<ul class="nav nav-tabs">
<li class="nav-item">
<span class="nav-item navbar-brand" aria-current="page">
<h4>&nbsp;&nbsp;<?= ICONS['SETUP'] ?>재고현황&nbsp;&nbsp;</h4>
</span>
</li>
</ul>
</div>
<div style="border-left: 1px solid black; border-right: 1px solid black; padding:20px;">
준비중....
</div>
<div class="layout_footer"></div>