dbmsv2 init...1
This commit is contained in:
parent
f41b645166
commit
2eccd6d67c
@ -3,11 +3,11 @@
|
|||||||
namespace App\Interfaces\Customer;
|
namespace App\Interfaces\Customer;
|
||||||
|
|
||||||
use App\Entities\Customer\ServiceEntity;
|
use App\Entities\Customer\ServiceEntity;
|
||||||
use App\Entities\Equipment\ServerEntity;
|
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
|
|
||||||
interface ServiceInterface extends CustomerInterface
|
interface ServiceInterface extends CustomerInterface
|
||||||
{
|
{
|
||||||
public function setService(string $action, ServiceEntity $serviceEntity, array $serviceDatas): ServiceENtity;
|
public function createService(ServiceEntity $serviceEntity): ServiceEntity;
|
||||||
public function setServiceAmount(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity;
|
public function modifyService(ServiceEntity $serviceEntity): ServiceEntity;
|
||||||
|
public function deleteService(ServiceEntity $serviceEntity): ServiceEntity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ use App\Entities\Equipment\ServerPartEntity;
|
|||||||
|
|
||||||
interface ServerPartInterface extends EquipmentInterface
|
interface ServerPartInterface extends EquipmentInterface
|
||||||
{
|
{
|
||||||
public function createServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity;
|
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity;
|
||||||
public function modifyServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity;
|
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity;
|
||||||
public function deleteServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity;
|
public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity;
|
||||||
}
|
}
|
||||||
|
|||||||
43
app/Services/Customer/Service/ServerPart.php
Normal file
43
app/Services/Customer/Service/ServerPart.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Service;
|
||||||
|
|
||||||
|
use App\Entities\Customer\ServiceEntity;
|
||||||
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
|
use App\Interfaces\Equipment\ServerPartInterface;
|
||||||
|
use App\Services\Customer\ServiceService;
|
||||||
|
|
||||||
|
|
||||||
|
class ServerPart extends ServiceService implements ServerPartInterface
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
//월과금은 해당 서비스의 항목별 금액을 총 합산후 청구금액을 설정후 결제정보에 신규등록/수정한다
|
||||||
|
private function action_process(ServerPartEntity $serverPartEntity): ServiceEntity
|
||||||
|
{
|
||||||
|
//Service Entity 가져오기
|
||||||
|
$entity = $this->getEntity($serverPartEntity->getServiceInfoUID());
|
||||||
|
if (!$entity instanceof ServiceEntity) {
|
||||||
|
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
//서비스금액은 modify 함수내에서 재계산을 하므로 여기서는 modify만 호출함
|
||||||
|
return parent::modify($entity, []);
|
||||||
|
}
|
||||||
|
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
//필수정보처리 후 FormData 가져오기
|
||||||
|
$this->action_process($serverPartEntity);
|
||||||
|
return $serverPartEntity;
|
||||||
|
}
|
||||||
|
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
return $this->createServerPart($serverPartEntity);
|
||||||
|
}
|
||||||
|
public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
return $this->createServerPart($serverPartEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,22 +2,24 @@
|
|||||||
|
|
||||||
namespace App\Services\Customer;
|
namespace App\Services\Customer;
|
||||||
|
|
||||||
use App\Entities\Customer\ClientEntity;
|
|
||||||
use App\Entities\Customer\ServiceEntity;
|
|
||||||
use App\Entities\Equipment\ServerEntity;
|
|
||||||
use App\Entities\PaymentEntity;
|
|
||||||
use App\Entities\UserEntity;
|
|
||||||
use App\Helpers\Customer\ServiceHelper;
|
|
||||||
use App\Models\Customer\ServiceModel;
|
|
||||||
use App\Services\Equipment\Server\Service as ServerService;
|
|
||||||
use App\Services\Payment\Service as PaymentService;
|
|
||||||
use App\Traits\IPTrait;
|
use App\Traits\IPTrait;
|
||||||
|
use App\Services\Payment\Service as PaymentService;
|
||||||
|
use App\Services\Equipment\Server\Service as ServerService;
|
||||||
|
use App\Services\Equipment\ServerPartService;
|
||||||
|
use App\Models\Customer\ServiceModel;
|
||||||
|
use App\Helpers\Customer\ServiceHelper;
|
||||||
|
use App\Entities\UserEntity;
|
||||||
|
use App\Entities\PaymentEntity;
|
||||||
|
use App\Entities\Equipment\ServerEntity;
|
||||||
|
use App\Entities\Customer\ServiceEntity;
|
||||||
|
use App\Entities\Customer\ClientEntity;
|
||||||
|
|
||||||
class ServiceService extends CustomerService
|
class ServiceService extends CustomerService
|
||||||
{
|
{
|
||||||
use IPTrait;
|
use IPTrait;
|
||||||
private ?ServerService $_serverService = null;
|
private ?ServerService $_serverService = null;
|
||||||
private ?PaymentService $_paymentService = null;
|
private ?PaymentService $_paymentService = null;
|
||||||
|
private ?ServerPartService $_serverPartService = null;
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct(new ServiceModel(), new ServiceHelper());
|
parent::__construct(new ServiceModel(), new ServiceHelper());
|
||||||
@ -35,8 +37,8 @@ class ServiceService extends CustomerService
|
|||||||
"line",
|
"line",
|
||||||
"start_at",
|
"start_at",
|
||||||
"billing_at",
|
"billing_at",
|
||||||
"amount",
|
|
||||||
"status",
|
"status",
|
||||||
|
'amount',
|
||||||
"history",
|
"history",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -137,6 +139,13 @@ class ServiceService extends CustomerService
|
|||||||
}
|
}
|
||||||
return $this->_serverService;
|
return $this->_serverService;
|
||||||
}
|
}
|
||||||
|
public function getServerPartService(): ServerPartService
|
||||||
|
{
|
||||||
|
if (!$this->_serverPartService) {
|
||||||
|
$this->_serverPartService = new ServerPartService();
|
||||||
|
}
|
||||||
|
return $this->_serverPartService;
|
||||||
|
}
|
||||||
//기본 기능부분
|
//기본 기능부분
|
||||||
public function getFormOption(string $field, array $options = []): array
|
public function getFormOption(string $field, array $options = []): array
|
||||||
{
|
{
|
||||||
@ -219,18 +228,41 @@ class ServiceService extends CustomerService
|
|||||||
) WHERE billing_at = ? AND status = ?";
|
) WHERE billing_at = ? AND status = ?";
|
||||||
return $this->getModel()->query($sql, [$billing_at, $status]);
|
return $this->getModel()->query($sql, [$billing_at, $status]);
|
||||||
}
|
}
|
||||||
|
//월청구액 계산값
|
||||||
|
final public function getCalculatedAmount(ServiceEntity $entity): int
|
||||||
|
{
|
||||||
|
$serverEntity = $this->getServerService()->getEntity($entity->getServerInfoUID());
|
||||||
|
if (!$serverEntity instanceof ServerEntity) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:[{$entity->getServerInfoUID()}]에 대한 서버정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
$total_amount = $serverEntity->getPrice(); //서버금액(price)
|
||||||
|
//해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart 전체를 다시 검사하여 월청구액을 합산한다.
|
||||||
|
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $serverEntity->getPK()]) as $serverPartEntity) {
|
||||||
|
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) {
|
||||||
|
$total_amount += $serverPartEntity->getAmount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $total_amount;
|
||||||
|
}
|
||||||
//기본기능
|
//기본기능
|
||||||
|
private function action_process(ServiceEntity $entity, string $action): ServiceEntity
|
||||||
|
{
|
||||||
|
//서버정보에 서비스정보 등록
|
||||||
|
$entity = $this->getServerService()->$action($entity);
|
||||||
|
$entity = $this->getPaymentService()->$action($entity);
|
||||||
|
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 = parent::create(formDatas: $formDatas);
|
//신규등록
|
||||||
$entity = $this->getServerService()->setService(__FUNCTION__, $entity, ['serverinfo_uid' => $formDatas['serverinfo_uid'], 'status' => STATUS['OCCUPIED']]);
|
$entity = parent::create($formDatas);
|
||||||
// 결제정보에 추가한다.
|
//월청구액계산 후 서비스정보에 수정
|
||||||
$this->getPaymentService()->setService(__FUNCTION__, $entity);
|
$entity = parent::modify($entity, ['amount' => $this->getCalculatedAmount($entity)]);
|
||||||
|
$this->action_process($entity, __FUNCTION__ . 'Service');
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//수정
|
//수정
|
||||||
@ -239,43 +271,21 @@ 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->getServerInfoUID() && $entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) {
|
if ($entity->getServerInfoUID() && $entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) {
|
||||||
$this->getServerService()->setService($entity, $entity->getServerEntity()->getPK(), STATUS['AVAILABLE']);
|
$this->action_process($entity, 'deleteService');
|
||||||
}
|
}
|
||||||
//서비스 정보수정
|
//수정작업
|
||||||
|
//월청구액계산 후 서비스정보에 수정
|
||||||
|
$formDatas['amount'] = $this->getCalculatedAmount($entity->getPK());
|
||||||
$entity = parent::modify($entity, $formDatas);
|
$entity = parent::modify($entity, $formDatas);
|
||||||
//신규서버정보 사용중으로 설정
|
$this->action_process($entity, __FUNCTION__ . 'Service');
|
||||||
if ($entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) {
|
|
||||||
$entity->setServerEntity($this->getServerService()->setService($entity, $formDatas['serverinfo_uid'], STATUS['OCCUPIED']));
|
|
||||||
}
|
|
||||||
//수정된 정보중 서버,결제일,청구액이 바뀐경우 결제정보에서 미납인경우 수정해준다.
|
|
||||||
if (
|
|
||||||
$entity->getServerInfoUID() !== $formDatas['serverinfo_uid'] ||
|
|
||||||
$entity->getBillingAt() !== $formDatas['billing_at'] ||
|
|
||||||
$entity->getAmount() !== $formDatas['amount']
|
|
||||||
) {
|
|
||||||
$paymentEntity = $this->getPaymentService()->getEntity(['serviceinfo_uid' => $entity->getPK(), 'status' => STATUS['UNPAID']]);
|
|
||||||
if (!($paymentEntity instanceof PaymentEntity)) {
|
|
||||||
throw new \Exception("{$entity->getPK()}에 해당하는 미결제정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
$paymentDatas = [];
|
|
||||||
$paymentDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
|
||||||
$paymentDatas['serviceinfo_uid'] = $entity->getPK();
|
|
||||||
$paymentDatas['serverinfo_uid'] = $entity->getServerInfoUID();
|
|
||||||
$paymentDatas['title'] = $entity->getServerEntity()->getTitle();
|
|
||||||
$paymentDatas['amount'] = $entity->getAmount();
|
|
||||||
$paymentDatas['billing'] = PAYMENT['BILLING']['MONTH'];
|
|
||||||
$paymentDatas['billing_at'] = $entity->getBillingAt();
|
|
||||||
$this->getPaymentService()->modify($paymentEntity, $paymentDatas);
|
|
||||||
}
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//삭제
|
//삭제
|
||||||
public function delete(mixed $entity): ServiceEntity
|
public function delete(mixed $entity): ServiceEntity
|
||||||
{
|
{
|
||||||
//기존서버정보 사용가능으로 설정
|
$this->action_process($entity, __FUNCTION__ . 'Service');
|
||||||
$this->getServerService()->setService($entity, $entity->getServerEntity()->getPK(), STATUS['AVAILABLE']);
|
|
||||||
return parent::delete($entity);
|
return parent::delete($entity);
|
||||||
}
|
}
|
||||||
//History
|
//History
|
||||||
|
|||||||
53
app/Services/Equipment/CS/ServerPart.php
Normal file
53
app/Services/Equipment/CS/ServerPart.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Equipment\CS;
|
||||||
|
|
||||||
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
|
use App\Entities\Equipment\CSEntity;
|
||||||
|
use App\Interfaces\Equipment\ServerPartInterface;
|
||||||
|
use App\Services\Equipment\CSService;
|
||||||
|
|
||||||
|
class ServerPart extends CSService implements ServerPartInterface
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
//서버연결정보용 등록
|
||||||
|
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): CSEntity
|
||||||
|
{
|
||||||
|
if (!array_key_exists('status', $formDatas)) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생: CS상태가 설정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
//CS정보가져오기
|
||||||
|
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
||||||
|
if (!($entity instanceof CSEntity)) {
|
||||||
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
|
||||||
|
}
|
||||||
|
//CS정보 수정
|
||||||
|
return $this->modify($entity, $formDatas);
|
||||||
|
}
|
||||||
|
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||||
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||||
|
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
||||||
|
$formDatas['status'] = STATUS['OCCUPIED'];
|
||||||
|
$entity = $this->action_process($serverPartEntity, $formDatas);
|
||||||
|
return $serverPartEntity->setPartEntity($entity);
|
||||||
|
}
|
||||||
|
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
return $this->createServerPart($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($serverPartEntity, $formDatas);
|
||||||
|
return $serverPartEntity->setPartEntity($entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Equipment\CS;
|
|
||||||
|
|
||||||
use App\Entities\Equipment\CSEntity;
|
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
|
||||||
use App\Interfaces\Equipment\ServerPartInterface;
|
|
||||||
use App\Services\Equipment\CSService;
|
|
||||||
|
|
||||||
class ServicePart extends CSService implements ServerPartInterface
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
//서버연결정보용 등록
|
|
||||||
public function setServerPart(string $action, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
if (!array_key_exists('part_uid', $serverPartDatas)) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
|
|
||||||
}
|
|
||||||
if (!array_key_exists('status', $serverPartDatas)) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->getEntity($serverPartDatas['part_uid']);
|
|
||||||
if (!($entity instanceof CSEntity)) {
|
|
||||||
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 CS정보를를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
||||||
$formDatas = [];
|
|
||||||
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) {
|
|
||||||
//사용가능
|
|
||||||
$formDatas['clientinfo_uid'] = null;
|
|
||||||
$formDatas['serviceinfo_uid'] = null;
|
|
||||||
$formDatas['serverinfo_uid'] = null;
|
|
||||||
} else {
|
|
||||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
|
||||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
|
||||||
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
|
||||||
}
|
|
||||||
$formDatas['status'] = $serverPartDatas['status'];
|
|
||||||
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
53
app/Services/Equipment/IP/ServerPart.php
Normal file
53
app/Services/Equipment/IP/ServerPart.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Equipment\IP;
|
||||||
|
|
||||||
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
|
use App\Entities\Equipment\IPEntity;
|
||||||
|
use App\Interfaces\Equipment\ServerPartInterface;
|
||||||
|
use App\Services\Equipment\IPService;
|
||||||
|
|
||||||
|
class ServerPart extends IPService implements ServerPartInterface
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
//서버연결정보용 등록
|
||||||
|
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): IPEntity
|
||||||
|
{
|
||||||
|
if (!array_key_exists('status', $formDatas)) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생: IP상태가 설정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
//IP정보가져오기
|
||||||
|
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
||||||
|
if (!($entity instanceof IPEntity)) {
|
||||||
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
|
||||||
|
}
|
||||||
|
//IP정보 수정
|
||||||
|
return $this->modify($entity, $formDatas);
|
||||||
|
}
|
||||||
|
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||||
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||||
|
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
||||||
|
$formDatas['status'] = STATUS['OCCUPIED'];
|
||||||
|
$entity = $this->action_process($serverPartEntity, $formDatas);
|
||||||
|
return $serverPartEntity->setPartEntity($entity);
|
||||||
|
}
|
||||||
|
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
return $this->createServerPart($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($serverPartEntity, $formDatas);
|
||||||
|
return $serverPartEntity->setPartEntity($entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Equipment\IP;
|
|
||||||
|
|
||||||
use App\Entities\Equipment\IPEntity;
|
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
|
||||||
use App\Interfaces\Equipment\ServerPartInterface;
|
|
||||||
use App\Services\Equipment\IPService;
|
|
||||||
|
|
||||||
class ServicePart extends IPService implements ServerPartInterface
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
//서버연결정보용 등록
|
|
||||||
public function setServerPart(string $action, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
if (!array_key_exists('part_uid', $serverPartDatas)) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
|
|
||||||
}
|
|
||||||
if (!array_key_exists('status', $serverPartDatas)) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->getEntity($serverPartDatas['part_uid']);
|
|
||||||
if (!($entity instanceof IPEntity)) {
|
|
||||||
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 IP정보를를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
||||||
$formDatas = [];
|
|
||||||
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) {
|
|
||||||
//사용가능
|
|
||||||
$formDatas['clientinfo_uid'] = null;
|
|
||||||
$formDatas['serviceinfo_uid'] = null;
|
|
||||||
$formDatas['serverinfo_uid'] = null;
|
|
||||||
} else {
|
|
||||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
|
||||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
|
||||||
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
|
||||||
}
|
|
||||||
$formDatas['status'] = $serverPartDatas['status'];
|
|
||||||
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
52
app/Services/Equipment/Part/ServerPart.php
Normal file
52
app/Services/Equipment/Part/ServerPart.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Equipment\Part;
|
||||||
|
|
||||||
|
use App\Entities\Equipment\PartEntity;
|
||||||
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
|
use App\Interfaces\Equipment\ServerPartInterface;
|
||||||
|
use App\Services\Equipment\PartService;
|
||||||
|
|
||||||
|
class ServerPart extends PartService implements ServerPartInterface
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
//서버연결정보용 등록
|
||||||
|
private function action_process(ServerPartEntity $serverPartEntity, string $action): PartEntity
|
||||||
|
{
|
||||||
|
//부품정보가져오기
|
||||||
|
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
||||||
|
if (!($entity instanceof PartEntity)) {
|
||||||
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
||||||
|
}
|
||||||
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||||
|
$formDatas = [];
|
||||||
|
if ($action === "return") { //해지된 부품 재고 반납 처리
|
||||||
|
$formDatas['stock'] = $entity->getStock() + $serverPartEntity->getCnt();
|
||||||
|
}
|
||||||
|
if ($action === "use") { //사용된 부품 재고 사용처리
|
||||||
|
if ($entity->getStock() < $serverPartEntity->getCnt()) {
|
||||||
|
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
||||||
|
}
|
||||||
|
$formDatas['stock'] = $entity->getStock() - $serverPartEntity->getCnt();
|
||||||
|
}
|
||||||
|
return $this->modify($entity, $formDatas);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
$entity = $this->action_process($serverPartEntity, "use");
|
||||||
|
return $serverPartEntity->setPartEntity($entity);
|
||||||
|
}
|
||||||
|
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
return $this->createServerPart($serverPartEntity);
|
||||||
|
}
|
||||||
|
public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
$entity = $this->action_process($serverPartEntity, "return");
|
||||||
|
return $serverPartEntity->setPartEntity($entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Equipment\Part;
|
|
||||||
|
|
||||||
use App\Entities\Equipment\PartEntity;
|
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
|
||||||
use App\Interfaces\Equipment\ServerPartInterface;
|
|
||||||
use App\Services\Equipment\PartService;
|
|
||||||
|
|
||||||
class ServicePart extends PartService implements ServerPartInterface
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
//서버연결정보용 등록
|
|
||||||
public function setServerPart(string $action, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
if (!array_key_exists('part_uid', $serverPartDatas)) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
|
|
||||||
}
|
|
||||||
if (!array_key_exists('status', $serverPartDatas)) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
|
|
||||||
}
|
|
||||||
//부품정보가져오기
|
|
||||||
$entity = $this->getEntity($serverPartDatas['part_uid']);
|
|
||||||
if (!($entity instanceof PartEntity)) {
|
|
||||||
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 부품정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
||||||
$formDatas = [];
|
|
||||||
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) { //해지된 부품 재고수를 처리
|
|
||||||
$formDatas['stock'] = $entity->getStock() + $serverPartEntity->getCnt();
|
|
||||||
}
|
|
||||||
if ($serverPartDatas['status'] === STATUS['OCCUPIED']) { //추가된 부품 재고수를 처리
|
|
||||||
if ($entity->getStock() < $serverPartEntity->getCnt()) {
|
|
||||||
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
|
||||||
}
|
|
||||||
$formDatas['stock'] = $entity->getStock() - $serverPartEntity->getCnt();
|
|
||||||
}
|
|
||||||
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -4,7 +4,6 @@ namespace App\Services\Equipment\Server;
|
|||||||
|
|
||||||
use App\Entities\Customer\ServiceEntity;
|
use App\Entities\Customer\ServiceEntity;
|
||||||
use App\Entities\Equipment\ServerEntity;
|
use App\Entities\Equipment\ServerEntity;
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
|
||||||
use App\Interfaces\Customer\ServiceInterface;
|
use App\Interfaces\Customer\ServiceInterface;
|
||||||
use App\Services\Equipment\ServerService;
|
use App\Services\Equipment\ServerService;
|
||||||
|
|
||||||
@ -14,23 +13,41 @@ class Service extends ServerService implements ServiceInterface
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
//서버연결정보용 등록
|
private function action_process(ServiceEntity $serviceEntity, array $formDatas = []): ServerEntity
|
||||||
//서비스정보용 등록
|
|
||||||
public function setService(string $action, ServiceEntity $serviceEntity, array $serviceDatas = []): ServiceENtity
|
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity($serviceDatas['serverinfo_uid']);
|
if (!array_key_exists('status', $formDatas)) {
|
||||||
if (!($entity instanceof ServerEntity)) {
|
throw new \Exception(__METHOD__ . "에서 오류발생: 서버상태가 설정되지 않았습니다.");
|
||||||
throw new \Exception("{$serviceDatas['serverinfo_uid']}에 해당하는 서버정보를 찾을수없습니다.");
|
|
||||||
}
|
}
|
||||||
|
//서버정보 가져오기
|
||||||
|
$entity = $this->getEntity($serviceEntity->getServerInfoUID());
|
||||||
|
if (!($entity instanceof ServerEntity)) {
|
||||||
|
throw new \Exception("{$serviceEntity->getServerInfoUID()}에 해당하는 서버정보를 찾을수없습니다.");
|
||||||
|
}
|
||||||
|
//서버정보 수정
|
||||||
|
return $this->modify($entity, $formDatas);
|
||||||
|
}
|
||||||
|
public function createService(ServiceEntity $serviceEntity): ServiceEntity
|
||||||
|
{
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
|
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
|
||||||
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
||||||
$formDatas['status'] = $serviceDatas['status'];
|
$formDatas['status'] = STATUS['OCCUPIED'];
|
||||||
$entity = $this->modify($entity, $formDatas);
|
$entity = $this->action_process($serviceEntity, $formDatas);
|
||||||
return $serviceEntity->setServerENtity($entity);
|
//서비스정보 Entity에 서버정보 설정
|
||||||
|
return $serviceEntity->setServerEntity($entity);
|
||||||
}
|
}
|
||||||
public function setServiceAmount(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
public function modifyService(ServiceEntity $serviceEntity): ServiceEntity
|
||||||
{
|
{
|
||||||
return $serverPartEntity;
|
return $this->createService($serviceEntity);
|
||||||
|
}
|
||||||
|
public function deleteService(ServiceEntity $serviceEntity): ServiceEntity
|
||||||
|
{
|
||||||
|
$formDatas = [];
|
||||||
|
$formDatas['clientinfo_uid'] = null;
|
||||||
|
$formDatas['serviceinfo_uid'] = null;
|
||||||
|
$formDatas['status'] = STATUS['AVAILABLE'];
|
||||||
|
$entity = $this->action_process($serviceEntity, $formDatas);
|
||||||
|
//서비스정보 Entity에 서버정보 설정
|
||||||
|
return $serviceEntity->setServerEntity($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,16 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Services\Equipment;
|
namespace App\Services\Equipment;
|
||||||
|
|
||||||
use App\Entities\Equipment\ServerEntity;
|
use App\Services\Payment\ServerPart as PaymentService;
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
|
||||||
use App\Helpers\Equipment\ServerPartHelper;
|
|
||||||
use App\Models\Equipment\ServerPartModel;
|
|
||||||
use App\Services\Equipment\EquipmentService;
|
|
||||||
use App\Services\Equipment\CS\ServerePart as CSService;
|
|
||||||
use App\Services\Equipment\IP\ServerePart as IPService;
|
|
||||||
use App\Services\Equipment\Part\ServerPart as PartService;
|
|
||||||
use App\Services\Equipment\Switch\ServerPart as SwitchService;
|
use App\Services\Equipment\Switch\ServerPart as SwitchService;
|
||||||
use App\Services\Payment\ServicePart as PaymentService;
|
use App\Services\Equipment\Part\ServerPart as PartService;
|
||||||
|
use App\Services\Equipment\IP\ServerPart as IPService;
|
||||||
|
use App\Services\Equipment\CS\ServerPart as CSService;
|
||||||
|
use App\Services\Equipment\EquipmentService;
|
||||||
|
use App\Models\Equipment\ServerPartModel;
|
||||||
|
use App\Helpers\Equipment\ServerPartHelper;
|
||||||
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
|
use App\Entities\Equipment\ServerEntity;
|
||||||
|
|
||||||
class ServerPartService extends EquipmentService
|
class ServerPartService extends EquipmentService
|
||||||
{
|
{
|
||||||
@ -73,13 +73,6 @@ class ServerPartService extends EquipmentService
|
|||||||
{
|
{
|
||||||
return ['billing', 'type'];
|
return ['billing', 'type'];
|
||||||
}
|
}
|
||||||
final public function getSwitchService(): SwitchService
|
|
||||||
{
|
|
||||||
if (!$this->_switchService) {
|
|
||||||
$this->_switchService = new SwitchService();
|
|
||||||
}
|
|
||||||
return $this->_switchService;
|
|
||||||
}
|
|
||||||
final public function getPartService(): PartService
|
final public function getPartService(): PartService
|
||||||
{
|
{
|
||||||
if (!$this->_partService) {
|
if (!$this->_partService) {
|
||||||
@ -87,6 +80,13 @@ class ServerPartService extends EquipmentService
|
|||||||
}
|
}
|
||||||
return $this->_partService;
|
return $this->_partService;
|
||||||
}
|
}
|
||||||
|
final public function getSwitchService(): SwitchService
|
||||||
|
{
|
||||||
|
if (!$this->_switchService) {
|
||||||
|
$this->_switchService = new SwitchService();
|
||||||
|
}
|
||||||
|
return $this->_switchService;
|
||||||
|
}
|
||||||
final public function getIPService(): IPService
|
final public function getIPService(): IPService
|
||||||
{
|
{
|
||||||
if (!$this->_ipService) {
|
if (!$this->_ipService) {
|
||||||
@ -184,7 +184,7 @@ class ServerPartService extends EquipmentService
|
|||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
//파트별정보 설정
|
//파트별정보 설정
|
||||||
private function setServerPart(string $action, ServerPartEntity $entity, array $formDatas): ServerPartEntity
|
private function action_process(ServerPartEntity $entity, string $action): ServerPartEntity
|
||||||
{
|
{
|
||||||
//Type에 따른 부품서비스 정의
|
//Type에 따른 부품서비스 정의
|
||||||
switch ($entity->getType()) {
|
switch ($entity->getType()) {
|
||||||
@ -194,18 +194,33 @@ class ServerPartService extends EquipmentService
|
|||||||
case 'OS':
|
case 'OS':
|
||||||
case 'DB':
|
case 'DB':
|
||||||
case 'SOFTWARE':
|
case 'SOFTWARE':
|
||||||
$entity = $this->getPartService()->$action($entity, $formDatas);
|
$entity = $this->getPartService()->$action($entity);
|
||||||
break;
|
break;
|
||||||
case 'SWITCH':
|
case 'SWITCH':
|
||||||
$entity = $this->getSwitchService()->$action($entity, $formDatas);
|
$entity = $this->getSwitchService()->$action($entity);
|
||||||
break;
|
break;
|
||||||
case 'IP':
|
case 'IP':
|
||||||
$entity = $this->getIPService()->$action($entity, $formDatas);
|
$entity = $this->getIPService()->$action($entity);
|
||||||
break;
|
break;
|
||||||
case 'CS':
|
case 'CS':
|
||||||
$entity = $this->getCSService()->$action($entity, $formDatas);
|
$entity = $this->getCSService()->$action($entity);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
//서비스 및 결제정보 처리
|
||||||
|
switch ($entity->getBilling()) {
|
||||||
|
case PAYMENT['BILLING']['MONTH']: //월별
|
||||||
|
$entity = $this->getServiceService()->$action($entity);
|
||||||
|
break;
|
||||||
|
case PAYMENT['BILLING']['ONETIME']: //일회성
|
||||||
|
$entity = $this->getPaymentService()->$action($entity);
|
||||||
|
break;
|
||||||
|
case PAYMENT['BILLING']['BASE']: //기본
|
||||||
|
//아무처리 않함
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:{$entity->getBilling()}은 지정되지 않은 결제방식입니다.");
|
||||||
|
// break;
|
||||||
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//부품연결정보생성
|
//부품연결정보생성
|
||||||
@ -229,13 +244,8 @@ 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::create($formDatas);
|
$entity = parent::create($formDatas);
|
||||||
//부품정보 설정
|
//부품연결정보관련 정보처리
|
||||||
$entity = $this->setServerPart("createServerPart", $entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
|
return $this->action_process($entity, __FUNCTION__ . 'ServerPart');
|
||||||
//결제방식이 기본이 아니면 결제관련정보 설정
|
|
||||||
if ($entity->getBilling() !== PAYMENT['BILLING']['BASE']) {
|
|
||||||
$entity = $this->getPaymentService()->createServerPart($entity);
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
}
|
||||||
//수정
|
//수정
|
||||||
public function modify(mixed $entity, array $formDatas): ServerPartEntity
|
public function modify(mixed $entity, array $formDatas): ServerPartEntity
|
||||||
@ -248,34 +258,24 @@ class ServerPartService extends EquipmentService
|
|||||||
if (!($serverEntity instanceof ServerEntity)) {
|
if (!($serverEntity instanceof ServerEntity)) {
|
||||||
throw new \Exception("서버 정보가 지정되지 않았습니다.");
|
throw new \Exception("서버 정보가 지정되지 않았습니다.");
|
||||||
}
|
}
|
||||||
//부품연결정보에 부품정보가 변경된 경우(기존것은 AVAILABLE로 변경)
|
//수정 전 부품연결정보관련 정보처리
|
||||||
if ($entity->getPartUID() != $formDatas['part_uid']) {
|
if ($entity->getCnt() != $formDatas['cnt'] || $entity->getPartUID() !== $formDatas['part_uid']) {
|
||||||
$entity = $this->setServerPart("modifyServerPart", $entity, ['part_uid' => $entity->getPartUID(), 'status' => STATUS['AVAILABLE']]);
|
$entity = $this->action_process($entity, 'deleteServerPart');
|
||||||
}
|
}
|
||||||
//수정작업
|
//수정작업
|
||||||
$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::modify($entity, $formDatas);
|
$entity = parent::modify($entity, $formDatas);
|
||||||
//부품연결정보에 부품정보가 변경된 경우 OCCUPIED로 변경
|
//수정 후 부품연결정보관련 정보처리
|
||||||
if ($entity->getPartUID() != $formDatas['part_uid']) {
|
$entity = $this->action_process($entity, __FUNCTION__ . 'ServerPart');
|
||||||
$entity = $this->setServerPart("modifyServerPart", $entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
|
|
||||||
}
|
|
||||||
//결제방식이 기본이 아니면 결제관련정보 설정
|
|
||||||
if ($entity->getBilling() !== PAYMENT['BILLING']['BASE']) {
|
|
||||||
$entity = $this->getPaymentService()->modifyeServerPart($entity);
|
|
||||||
}
|
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//삭제
|
//삭제
|
||||||
public function delete(mixed $entity): ServerPartEntity
|
public function delete(mixed $entity): ServerPartEntity
|
||||||
{
|
{
|
||||||
//부품연결정보에 부품정보 정의
|
//부품연결정보관련 정보처리
|
||||||
$entity = $this->setServerPart("deleteServerPart", $entity, ['part_uid' => $entity->getPartUID(), 'status' => STATUS['AVAILABLE']]);
|
$entity = $this->action_process($entity, __FUNCTION__ . 'ServerPart');
|
||||||
//결제방식이 기본이 아니면 결제관련정보 설정
|
|
||||||
if ($entity->getBilling() !== PAYMENT['BILLING']['BASE']) {
|
|
||||||
$entity = $this->getPaymentService()->deleteServerPart($entity);
|
|
||||||
}
|
|
||||||
return parent::delete($entity);
|
return parent::delete($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
app/Services/Equipment/Switch/ServerPart.php
Normal file
53
app/Services/Equipment/Switch/ServerPart.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Equipment\Switch;
|
||||||
|
|
||||||
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
|
use App\Entities\Equipment\SwitchEntity;
|
||||||
|
use App\Interfaces\Equipment\ServerPartInterface;
|
||||||
|
use App\Services\Equipment\SwitchService;
|
||||||
|
|
||||||
|
class ServerPart extends SwitchService implements ServerPartInterface
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
//서버연결정보용 등록
|
||||||
|
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): SwitchEntity
|
||||||
|
{
|
||||||
|
if (!array_key_exists('status', $formDatas)) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생: 스위치상태가 설정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
//스위치정보가져오기
|
||||||
|
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
||||||
|
if (!($entity instanceof SwitchEntity)) {
|
||||||
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 스위치정보를 찾을수없습니다.");
|
||||||
|
}
|
||||||
|
//스위치정보 수정
|
||||||
|
return $this->modify($entity, $formDatas);
|
||||||
|
}
|
||||||
|
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||||
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||||
|
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
||||||
|
$formDatas['status'] = STATUS['OCCUPIED'];
|
||||||
|
$entity = $this->action_process($serverPartEntity, $formDatas);
|
||||||
|
return $serverPartEntity->setPartEntity($entity);
|
||||||
|
}
|
||||||
|
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
return $this->createServerPart($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($serverPartEntity, $formDatas);
|
||||||
|
return $serverPartEntity->setPartEntity($entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Equipment\Switch;
|
|
||||||
|
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
|
||||||
use App\Entities\Equipment\SwitchEntity;
|
|
||||||
use App\Interfaces\Equipment\ServerPartInterface;
|
|
||||||
use App\Services\Equipment\SwitchService;
|
|
||||||
|
|
||||||
class ServicePart extends SwitchService implements ServerPartInterface
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
//서버연결정보용 등록
|
|
||||||
public function setServerPart(string $action, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
if (!array_key_exists('part_uid', $serverPartDatas)) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
|
|
||||||
}
|
|
||||||
if (!array_key_exists('status', $serverPartDatas)) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->getEntity($serverPartDatas['part_uid']);
|
|
||||||
if (!($entity instanceof SwitchEntity)) {
|
|
||||||
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 스위치정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
|
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
||||||
$formDatas = [];
|
|
||||||
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) {
|
|
||||||
//사용가능
|
|
||||||
$formDatas['clientinfo_uid'] = null;
|
|
||||||
$formDatas['serviceinfo_uid'] = null;
|
|
||||||
$formDatas['serverinfo_uid'] = null;
|
|
||||||
} else {
|
|
||||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
|
||||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
|
||||||
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
|
||||||
}
|
|
||||||
$formDatas['status'] = $serverPartDatas['status'];
|
|
||||||
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Services\Payment;
|
namespace App\Services\Payment;
|
||||||
|
|
||||||
use App\Entities\Customer\ServiceEntity;
|
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
use App\Entities\PaymentEntity;
|
use App\Entities\PaymentEntity;
|
||||||
use App\Interfaces\Equipment\ServerPartInterface;
|
use App\Interfaces\Equipment\ServerPartInterface;
|
||||||
@ -25,29 +24,17 @@ class ServerPart extends PaymentService implements ServerPartInterface
|
|||||||
return $this->_serverPartService;
|
return $this->_serverPartService;
|
||||||
}
|
}
|
||||||
|
|
||||||
//월과금은 해당 서비스의 항목별 금액을 총 합산후 청구금액을 설정후 결제정보에 신규등록/수정한다
|
private function action_process(ServerPartEntity $serverPartEntity): array
|
||||||
private function serverPart_process_month(ServiceEntity $serviceEntity, ServerPartEntity $serverPartEntity): ServiceEntity
|
|
||||||
{
|
{
|
||||||
//월비용인경우 서비스 제공가에 서버연결정보 제공가 합산금액으로 설정
|
if ($serverPartEntity->getServiceInfoUID() === null) {
|
||||||
$serviceFormDatas = [];
|
throw new \Exception(__METHOD__ . "에서 오류발생: 서비스정보가 정의된 후에만 가능합니다.");
|
||||||
$serviceFormDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
|
|
||||||
$serviceFormDatas['billing_at'] = $serviceEntity->getBillingAt();
|
|
||||||
//해당 서비스(서버) 관련 경제방식(Billing)이 Month인 ServerPart 전체를 다시 검사하여 월청구액을 수정한다.
|
|
||||||
$serviceFormDatas['amount'] = $serviceEntity->getServerEntity()->getPrice(); //서버금액(price)
|
|
||||||
//월과금용 ServerPartEntity의 금액을 모두 총합산한 금액을 설정한다.
|
|
||||||
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $serviceEntity->getServerInfoUID()]) as $serverPartEntity) {
|
|
||||||
$serviceFormDatas['amount'] += $serverPartEntity->getAmount();
|
|
||||||
}
|
}
|
||||||
return $this->getServiceService()->modify($serviceEntity, $serviceFormDatas);
|
//일회인이 아닌경우
|
||||||
}
|
if ($serverPartEntity->getBilling() !== PAYMENT['BILLING']['ONETIME']) {
|
||||||
private function serverPart_process(ServerPartEntity $serverPartEntity, array $formDatas = []): array
|
throw new \Exception(__METHOD__ . "에서 오류발생: :" . lang("{$this->getClassName()}.BILLING." . PAYMENT['BILLING'][$serverPartEntity->getBilling()]) . "지급 상품은 처리가 불가, 일회성만 가능합니다.");
|
||||||
{
|
|
||||||
//Service Entity 가져오기
|
|
||||||
$serviceEntity = $this->getServiceService()->getEntity($serverPartEntity->getServiceInfoUID());
|
|
||||||
if (!$serviceEntity) {
|
|
||||||
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$formDatas = [];
|
||||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||||
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); //서버연결정보 수정시에 필요함
|
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); //서버연결정보 수정시에 필요함
|
||||||
@ -56,46 +43,35 @@ class ServerPart extends PaymentService implements ServerPartInterface
|
|||||||
$formDatas['title'] = $serverPartEntity->getType() === 'ETC' ? $serverPartEntity->getTitle() : $serverPartEntity->getPartEntity()->getTitle();
|
$formDatas['title'] = $serverPartEntity->getType() === 'ETC' ? $serverPartEntity->getTitle() : $serverPartEntity->getPartEntity()->getTitle();
|
||||||
$formDatas['amount'] = $serverPartEntity->getAmount();
|
$formDatas['amount'] = $serverPartEntity->getAmount();
|
||||||
$formDatas['billing'] = $serverPartEntity->getBilling();
|
$formDatas['billing'] = $serverPartEntity->getBilling();
|
||||||
//월과금인경우
|
|
||||||
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) {
|
|
||||||
//결제일설정
|
|
||||||
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
|
|
||||||
$this->serverPart_process_month($serviceEntity, $serverPartEntity);
|
|
||||||
}
|
|
||||||
//일회성인경우
|
|
||||||
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME']) {
|
|
||||||
//당일결체일로 설정
|
|
||||||
$formDatas['billing_at'] = date("Y-m-d");
|
|
||||||
}
|
|
||||||
return $formDatas;
|
return $formDatas;
|
||||||
}
|
}
|
||||||
public function createServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas = []): ServerPartEntity
|
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
{
|
{
|
||||||
if ($serverPartEntity->getServiceInfoUID() === null) {
|
//필수정보처리 후 FormData 가져오기
|
||||||
throw new \Exception(lang("{$this->getClassName()}.BILLING." . PAYMENT['BILLING']['MONTH']) . "지급 상품은 서비스정보가 정의된 후에만 가능합니다.");
|
$formDatas = $this->action_process($serverPartEntity);
|
||||||
}
|
//당일결체일로 설정
|
||||||
//Service Entity 가져오기
|
$formDatas['billing_at'] = date("Y-m-d");
|
||||||
$serviceEntity = $this->getServiceService()->getEntity($serverPartEntity->getServiceInfoUID());
|
|
||||||
if (!$serviceEntity) {
|
|
||||||
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
//기본 처리 후 FormData 가져오기
|
|
||||||
$formDatas = $this->serverPart_process($serverPartEntity);
|
|
||||||
//결제정보등록
|
//결제정보등록
|
||||||
$this->create($formDatas);
|
$this->create($formDatas);
|
||||||
return $serverPartEntity;
|
return $serverPartEntity;
|
||||||
}
|
}
|
||||||
public function modifyServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas = []): ServerPartEntity
|
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
{
|
{
|
||||||
//serverpartinfo_uid에 해당하는 결제정보 가져오기
|
//미납상태의 결제정보 가져오기
|
||||||
$entity = $this->getEntity(['serverpartinfo_uid' => $serverPartEntity->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__ . "에서 오류발생: {$serverPartEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
|
throw new \Exception(__METHOD__ . "에서 오류발생: {$serverPartEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
//기본 처리 후 FormData 가져오기
|
//필수정보처리 후 FormData 가져오기
|
||||||
$formDatas = $this->serverPart_process($serverPartEntity);
|
$formDatas = $this->action_process($serverPartEntity);
|
||||||
//결제수정등록
|
//결제정보수정
|
||||||
$this->modify($entity, $formDatas);
|
$this->modify($entity, $formDatas);
|
||||||
return $serverPartEntity;
|
return $serverPartEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
|
||||||
|
{
|
||||||
|
//삭제시에는 아무것도 하지 않는다.
|
||||||
|
return $serverPartEntity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Services\Payment;
|
namespace App\Services\Payment;
|
||||||
|
|
||||||
use App\Entities\Customer\ServiceEntity;
|
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
|
||||||
use App\Interfaces\Customer\ServiceInterface;
|
|
||||||
use App\Services\Customer\ServiceService;
|
use App\Services\Customer\ServiceService;
|
||||||
|
use App\Interfaces\Customer\ServiceInterface;
|
||||||
|
use App\Entities\PaymentEntity;
|
||||||
|
use App\Entities\Customer\ServiceEntity;
|
||||||
|
|
||||||
class Service extends ServiceService implements ServiceInterface
|
class Service extends ServiceService implements ServiceInterface
|
||||||
{
|
{
|
||||||
@ -13,11 +13,8 @@ class Service extends ServiceService implements ServiceInterface
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
//서버연결정보용 등록
|
private function action_process(ServiceEntity $serviceEntity, array $formDatas = []): array
|
||||||
//서비스정보용 등록
|
|
||||||
public function setService(string $action, ServiceEntity $serviceEntity, array $serviceDatas = []): ServiceENtity
|
|
||||||
{
|
{
|
||||||
$formDatas = [];
|
|
||||||
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
|
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
|
||||||
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
||||||
$formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
|
$formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
|
||||||
@ -25,11 +22,28 @@ class Service extends ServiceService implements ServiceInterface
|
|||||||
$formDatas['amount'] = $serviceEntity->getAmount();
|
$formDatas['amount'] = $serviceEntity->getAmount();
|
||||||
$formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
|
$formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
|
||||||
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
|
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
|
||||||
$this->create($formDatas);
|
return $formDatas;
|
||||||
|
}
|
||||||
|
public function createService(ServiceEntity $serviceEntity): ServiceEntity
|
||||||
|
{
|
||||||
|
//필수정보처리 후 결제정보등록
|
||||||
|
$this->create($this->action_process($serviceEntity));
|
||||||
return $serviceEntity;
|
return $serviceEntity;
|
||||||
}
|
}
|
||||||
public function setServiceAmount(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
public function modifyService(ServiceEntity $serviceEntity): ServiceEntity
|
||||||
{
|
{
|
||||||
return $serverPartEntity;
|
//미납상태의 결제정보 가져오기
|
||||||
|
$entity = $this->getEntity(['serviceinfo_uid' => $serviceEntity->getPK(), 'status' => STATUS['UNPAID']]);
|
||||||
|
if (!$entity instanceof PaymentEntity) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생: {$serviceEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
//필수정보처리 후 결제정보수정
|
||||||
|
$this->modify($entity, $this->action_process($serviceEntity));
|
||||||
|
return $serviceEntity;
|
||||||
|
}
|
||||||
|
public function deleteService(ServiceEntity $serviceEntity): ServiceEntity
|
||||||
|
{
|
||||||
|
//삭제시에는 아무것도 하지 않는다.
|
||||||
|
return $serviceEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Service;
|
|
||||||
|
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
|
||||||
use App\Interfaces\Equipment\ServerPartInterface;
|
|
||||||
use App\Services\Customer\ServiceService;
|
|
||||||
|
|
||||||
|
|
||||||
class ServicePart extends ServiceService implements ServerPartInterface
|
|
||||||
{
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
//서버연결정보용 등록
|
|
||||||
public function createServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas = []): ServerPartEntity
|
|
||||||
{
|
|
||||||
$formDatas = [];
|
|
||||||
return $serverPartEntity;
|
|
||||||
}
|
|
||||||
public function modifyServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas = []): ServerPartEntity
|
|
||||||
{
|
|
||||||
$formDatas = [];
|
|
||||||
return $serverPartEntity;
|
|
||||||
}
|
|
||||||
public function deleteServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas = []): ServerPartEntity
|
|
||||||
{
|
|
||||||
$formDatas = [];
|
|
||||||
return $serverPartEntity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user