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
{
public function setServiceEntity(ServiceEntity $entity): self;
public function getServiceEntity(): ServiceEntity;
public function createService(): ServiceEntity;
public function modifyService(): ServiceEntity;
public function deleteService(): ServiceEntity;
public function createService(ServiceEntity $serviceEntity): ServiceEntity;
public function modifyService(ServiceEntity $serviceEntity): ServiceEntity;
public function deleteService(ServiceEntity $serviceEntity): ServiceEntity;
}

View File

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

View File

@ -9,58 +9,48 @@ use App\Interfaces\Customer\ServiceInterface;
class PaymentService extends ParentService implements ServiceInterface
{
private ?ServiceEntity $_serviceEntity = null;
public function __construct()
{
parent::__construct();
}
public function setServiceEntity(ServiceEntity $entity): self
private function action_process(ServiceEntity $serviceEntity, array $formDatas = []): array
{
$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 = []): 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['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
$formDatas['title'] = $serviceEntity->getServerEntity()->getTitle();
$formDatas['amount'] = $serviceEntity->getAmount();
$formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
$formDatas['billing_at'] = $this->getServiceEntity()->getBillingAt();
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
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에 결제정보 설정
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) {
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에 결제정보 설정
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
{
private ?ServiceEntity $_serviceEntity = null;
public function __construct()
{
parent::__construct();
}
final public function setServiceEntity(ServiceEntity $entity): self
{
$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
private function action_process(ServiceEntity $serviceEntity, array $formDatas = []): ServerEntity
{
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버상태가 설정되지 않았습니다.");
}
//서버정보 가져오기
$entity = $this->getEntity(['serviceinfo_uid' => $this->getServiceEntity()->getPK()]);
$entity = $this->getEntity(['serviceinfo_uid' => $serviceEntity->getPK()]);
if (!$entity instanceof ServerEntity) {
throw new \Exception("서비스정보[{$this->getServiceEntity()->getPK()}]에 해당하는 서버정보를 찾을수없습니다.");
throw new \Exception("서비스정보[{$serviceEntity->getPK()}]에 해당하는 서버정보를 찾을수없습니다.");
}
//서버정보 수정
return $this->modify($entity, $formDatas);
}
public function createService(): ServiceEntity
public function createService(ServiceEntity $serviceEntity): ServiceEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $this->getServiceEntity()->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $this->getServiceEntity()->getPK();
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas['status'] = STATUS['OCCUPIED'];
$entity = $this->action_process($formDatas);
$entity = $this->action_process($serviceEntity, $formDatas);
//서비스정보 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['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE'];
$entity = $this->action_process($formDatas);
$entity = $this->action_process($serviceEntity, $formDatas);
//서비스정보 Entity에 서버정보 설정
return $this->getServiceEntity()->setServerEntity($entity);
return $serviceEntity->setServerEntity($entity);
}
}

View File

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

View File

@ -9,61 +9,47 @@ use App\Services\Equipment\CSService as ParentService;
class CSService 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(array $formDatas = []): CSEntity
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): CSEntity
{
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: CS상태가 설정되지 않았습니다.");
}
//CS정보가져오기
$entity = $this->getEntity($this->getServerPartEntity()->getPartUID());
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof CSEntity) {
throw new \Exception("{$this->getServerPartEntity()->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
}
//CS정보 수정
return $this->modify($entity, $formDatas);
}
public function createServerPart(): ServerPartEntity
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $this->getServerPartEntity()->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $this->getServerPartEntity()->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $this->getServerPartEntity()->getServerInfoUID();
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['status'] = STATUS['OCCUPIED'];
$entity = $this->action_process($formDatas);
return $this->getServerPartEntity()->setPartEntity($entity);
$entity = $this->action_process($serverPartEntity, $formDatas);
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['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE'];
$entity = $this->action_process($formDatas);
return $this->getServerPartEntity()->setPartEntity($entity);
$entity = $this->action_process($serverPartEntity, $formDatas);
return $serverPartEntity->setPartEntity($entity);
}
}

View File

@ -9,61 +9,47 @@ use App\Services\Equipment\IPService as ParentService;
class IPService 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(array $formDatas = []): IPEntity
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): IPEntity
{
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: IP상태가 설정되지 않았습니다.");
}
//IP정보가져오기
$entity = $this->getEntity($this->getServerPartEntity()->getPartUID());
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof IPEntity) {
throw new \Exception("{$this->getServerPartEntity()->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
}
//IP정보 수정
return $this->modify($entity, $formDatas);
}
public function createServerPart(): ServerPartEntity
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $this->getServerPartEntity()->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $this->getServerPartEntity()->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $this->getServerPartEntity()->getServerInfoUID();
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['status'] = STATUS['OCCUPIED'];
$entity = $this->action_process($formDatas);
return $this->getServerPartEntity()->setPartEntity($entity);
$entity = $this->action_process($serverPartEntity, $formDatas);
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['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE'];
$entity = $this->action_process($formDatas);
return $this->getServerPartEntity()->setPartEntity($entity);
$entity = $this->action_process($serverPartEntity, $formDatas);
return $serverPartEntity->setPartEntity($entity);
}
}

View File

@ -9,58 +9,45 @@ use App\Services\Equipment\PartService as ParentService;
class PartService 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(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) {
throw new \Exception("{$this->getServerPartEntity()->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
}
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
$formDatas = [];
if ($action === "return") { //해지된 부품 재고 반납 처리
$formDatas['stock'] = $entity->getStock() + $this->getServerPartEntity()->getCnt();
$formDatas['stock'] = $entity->getStock() + $serverPartEntity->getCnt();
}
if ($action === "use") { //사용된 부품 재고 사용처리
if ($entity->getStock() < $this->getServerPartEntity()->getCnt()) {
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$this->getServerPartEntity()->getCnt()})가 더 많습니다.");
if ($entity->getStock() < $serverPartEntity->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);
}
public function createServerPart(): ServerPartEntity
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{
$entity = $this->action_process("use");
return $this->getServerPartEntity()->setPartEntity($entity);
$entity = $this->action_process($serverPartEntity, "use");
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");
return $this->getServerPartEntity()->setPartEntity($entity);
$entity = $this->action_process($serverPartEntity, "return");
return $serverPartEntity->setPartEntity($entity);
}
}

View File

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

View File

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

View File

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