dbmsv2 init...1

This commit is contained in:
choi.jh 2025-09-19 19:48:28 +09:00
parent 6db67ae3f8
commit 194b3dad43
11 changed files with 192 additions and 118 deletions

View File

@ -3,10 +3,11 @@
namespace App\Interfaces\Customer;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
interface ServiceInterface extends CustomerInterface
{
public function setService(string $action, ServiceEntity $serviceEntity, array $serviceDatas);
public function setService(string $action, ServiceEntity $serviceEntity, array $serviceDatas): ServiceENtity;
public function setServiceAmount(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity;
}

View File

@ -6,5 +6,7 @@ use App\Entities\Equipment\ServerPartEntity;
interface ServerPartInterface extends EquipmentInterface
{
public function setServerPart(string $action, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity;
public function createServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity;
public function modifyServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity;
public function deleteServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity;
}

View File

@ -26,28 +26,28 @@ abstract class CustomerService extends CommonService
parent::__construct($model, $helper);
$this->addClassName('Customer');
}
final public function getClientService(): ClientService
public function getClientService(): ClientService
{
if (!$this->_clientService) {
$this->_clientService = new ClientService();
}
return $this->_clientService;
}
final public function getUSerService(): UserService
public function getUSerService(): UserService
{
if (!$this->_userService) {
$this->_userService = new UserService();
}
return $this->_userService;
}
final public function getServiceService(): ServiceService
public function getServiceService(): ServiceService
{
if (!$this->_serviceService) {
$this->_serviceService = new ServiceService();
}
return $this->_serviceService;
}
final public function getServerService(): ServerService
public function getServerService(): ServerService
{
if (!$this->_serverService) {
$this->_serverService = new ServerService();

View File

@ -9,7 +9,7 @@ use App\Entities\PaymentEntity;
use App\Entities\UserEntity;
use App\Helpers\Customer\ServiceHelper;
use App\Models\Customer\ServiceModel;
use App\Services\Equipment\ServerService;
use App\Services\Equipment\Server\Service as ServerService;
use App\Services\Payment\Service as PaymentService;
use App\Traits\IPTrait;
@ -130,6 +130,13 @@ class ServiceService extends CustomerService
}
return $this->_paymentService;
}
public function getServerService(): ServerService
{
if (!$this->_serverService) {
$this->_serverService = new ServerService();
}
return $this->_serverService;
}
//기본 기능부분
public function getFormOption(string $field, array $options = []): array
{
@ -220,8 +227,8 @@ class ServiceService extends CustomerService
if (!array_key_exists('serverinfo_uid', $formDatas)) {
throw new \Exception("서버가 지정되지 않았습니다.");
}
$entity = parent::create($formDatas);
$entity = $entity->setServerEntity($this->getServerService()->setService($entity, $formDatas['serverinfo_uid'], STATUS['OCCUPIED']));
$entity = parent::create(formDatas: $formDatas);
$entity = $this->getServerService()->setService(__FUNCTION__, $entity, ['serverinfo_uid' => $formDatas['serverinfo_uid'], 'status' => STATUS['OCCUPIED']]);
// 결제정보에 추가한다.
$this->getPaymentService()->setService(__FUNCTION__, $entity);
return $entity;

View File

@ -0,0 +1,36 @@
<?php
namespace App\Services\Equipment\Server;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Interfaces\Customer\ServiceInterface;
use App\Services\Equipment\ServerService;
class Service extends ServerService implements ServiceInterface
{
public function __construct()
{
parent::__construct();
}
//서버연결정보용 등록
//서비스정보용 등록
public function setService(string $action, ServiceEntity $serviceEntity, array $serviceDatas = []): ServiceENtity
{
$entity = $this->getEntity($serviceDatas['serverinfo_uid']);
if (!($entity instanceof ServerEntity)) {
throw new \Exception("{$serviceDatas['serverinfo_uid']}에 해당하는 서버정보를 찾을수없습니다.");
}
$formDatas = [];
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas['status'] = $serviceDatas['status'];
$entity = $this->modify($entity, $formDatas);
return $serviceEntity->setServerENtity($entity);
}
public function setServiceAmount(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{
return $serverPartEntity;
}
}

View File

@ -7,10 +7,10 @@ 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\ServicePart as CSService;
use App\Services\Equipment\IP\ServicePart as IPService;
use App\Services\Equipment\Part\ServicePart as PartService;
use App\Services\Equipment\Switch\ServicePart as SwitchService;
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\Payment\ServicePart as PaymentService;
class ServerPartService extends EquipmentService
@ -194,16 +194,16 @@ class ServerPartService extends EquipmentService
case 'OS':
case 'DB':
case 'SOFTWARE':
$entity = $this->getPartService()->setServerPart($action, $entity, $formDatas);
$entity = $this->getPartService()->$action($entity, $formDatas);
break;
case 'SWITCH':
$entity = $this->getSwitchService()->setServerPart($action, $entity, $formDatas);
$entity = $this->getSwitchService()->$action($entity, $formDatas);
break;
case 'IP':
$entity = $this->getIPService()->setServerPart($action, $entity, $formDatas);
$entity = $this->getIPService()->$action($entity, $formDatas);
break;
case 'CS':
$entity = $this->getCSService()->setServerPart($action, $entity, $formDatas);
$entity = $this->getCSService()->$action($entity, $formDatas);
break;
}
return $entity;
@ -230,9 +230,11 @@ class ServerPartService extends EquipmentService
$formDatas["serverinfo_uid"] = $serverEntity->getPK();
$entity = parent::create($formDatas);
//부품정보 설정
$entity = $this->setServerPart(__FUNCTION__, $entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
//결제관련정보 설정
$entity = $this->getPaymentService()->setServerPart(__FUNCTION__, $entity);
$entity = $this->setServerPart("createServerPart", $entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
//결제방식이 기본이 아니면 결제관련정보 설정
if ($entity->getBilling() !== PAYMENT['BILLING']['BASE']) {
$entity = $this->getPaymentService()->createServerPart($entity);
}
return $entity;
}
//수정
@ -248,7 +250,7 @@ class ServerPartService extends EquipmentService
}
//부품연결정보에 부품정보가 변경된 경우(기존것은 AVAILABLE로 변경)
if ($entity->getPartUID() != $formDatas['part_uid']) {
$entity = $this->setServerPart(__FUNCTION__, $entity, ['part_uid' => $entity->getPartUID(), 'status' => STATUS['AVAILABLE']]);
$entity = $this->setServerPart("modifyServerPart", $entity, ['part_uid' => $entity->getPartUID(), 'status' => STATUS['AVAILABLE']]);
}
//수정작업
$formDatas["clientinfo_uid"] = $serverEntity->getClientInfoUID();
@ -257,17 +259,23 @@ class ServerPartService extends EquipmentService
$entity = parent::modify($entity, $formDatas);
//부품연결정보에 부품정보가 변경된 경우 OCCUPIED로 변경
if ($entity->getPartUID() != $formDatas['part_uid']) {
$entity = $this->setServerPart(__FUNCTION__, $entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
$entity = $this->setServerPart("modifyServerPart", $entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
}
//결제방식이 기본이 아니면 결제관련정보 설정
if ($entity->getBilling() !== PAYMENT['BILLING']['BASE']) {
$entity = $this->getPaymentService()->modifyeServerPart($entity);
}
//결제관련정보 정의
$entity = $this->getPaymentService()->setServerPart(__FUNCTION__, $entity);
return $entity;
}
//삭제
public function delete(mixed $entity): ServerPartEntity
{
//부품연결정보에 부품정보 정의
$entity = $this->setServerPart(__FUNCTION__, $entity, ['part_uid' => $entity->getPartUID(), 'status' => STATUS['AVAILABLE']]);
$entity = $this->setServerPart("deleteServerPart", $entity, ['part_uid' => $entity->getPartUID(), 'status' => STATUS['AVAILABLE']]);
//결제방식이 기본이 아니면 결제관련정보 설정
if ($entity->getBilling() !== PAYMENT['BILLING']['BASE']) {
$entity = $this->getPaymentService()->deleteServerPart($entity);
}
return parent::delete($entity);
}
}

View File

@ -121,20 +121,6 @@ class ServerService extends EquipmentService
throw new \Exception("Server코드[{$formDatas['code']}의 형식이 맞지않습니다");
}
}
//서비스 설정
public function setService(ServiceEntity $serviceEntity, mixed $uid, string $status): ServerEntity
{
$entity = $this->getEntity($uid);
if (!($entity instanceof ServerEntity)) {
throw new \Exception("{$uid}에 해당하는 서버정보를 찾을수없습니다.");
}
$formDatas = [];
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas['status'] = $status;
//서버정보 상태수정
return $this->modify($entity, $formDatas);
}
// 수정
public function modify(mixed $entity, array $formDatas): ServerEntity
{

View File

@ -0,0 +1,101 @@
<?php
namespace App\Services\Payment;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\PaymentEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\Equipment\ServerPartService;
use App\Services\PaymentService;
class ServerPart extends PaymentService implements ServerPartInterface
{
private ?ServerPartService $_serverPartService = null;
public function __construct()
{
parent::__construct();
}
final public function getServerPartService(): ServerPartService
{
if (!$this->_serverPartService) {
$this->_serverPartService = new ServerPartService();
}
return $this->_serverPartService;
}
//월과금은 해당 서비스의 항목별 금액을 총 합산후 청구금액을 설정후 결제정보에 신규등록/수정한다
private function serverPart_process_month(ServiceEntity $serviceEntity, ServerPartEntity $serverPartEntity): ServiceEntity
{
//월비용인경우 서비스 제공가에 서버연결정보 제공가 합산금액으로 설정
$serviceFormDatas = [];
$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);
}
private function serverPart_process(ServerPartEntity $serverPartEntity, array $formDatas = []): array
{
//Service Entity 가져오기
$serviceEntity = $this->getServiceService()->getEntity($serverPartEntity->getServiceInfoUID());
if (!$serviceEntity) {
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
}
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); //서버연결정보 수정시에 필요함
$formDatas['serverpartinfo_uid'] = $serverPartEntity->getPK();
//타이틀은 기타의 경우 직접작성한 제목을 등록하고 아닌경우는 Part의 Title을 사용한다.
$formDatas['title'] = $serverPartEntity->getType() === 'ETC' ? $serverPartEntity->getTitle() : $serverPartEntity->getPartEntity()->getTitle();
$formDatas['amount'] = $serverPartEntity->getAmount();
$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;
}
public function createServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas = []): ServerPartEntity
{
if ($serverPartEntity->getServiceInfoUID() === null) {
throw new \Exception(lang("{$this->getClassName()}.BILLING." . PAYMENT['BILLING']['MONTH']) . "지급 상품은 서비스정보가 정의된 후에만 가능합니다.");
}
//Service Entity 가져오기
$serviceEntity = $this->getServiceService()->getEntity($serverPartEntity->getServiceInfoUID());
if (!$serviceEntity) {
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
}
//기본 처리 후 FormData 가져오기
$formDatas = $this->serverPart_process($serverPartEntity);
//결제정보등록
$this->create($formDatas);
return $serverPartEntity;
}
public function modifyServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas = []): ServerPartEntity
{
//serverpartinfo_uid에 해당하는 결제정보 가져오기
$entity = $this->getEntity(['serverpartinfo_uid' => $serverPartEntity->getPK(), 'status' => STATUS['UNPAID']]);
if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: {$serverPartEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
}
//기본 처리 후 FormData 가져오기
$formDatas = $this->serverPart_process($serverPartEntity);
//결제수정등록
$this->modify($entity, $formDatas);
return $serverPartEntity;
}
}

View File

@ -15,7 +15,7 @@ class Service extends ServiceService implements ServiceInterface
}
//서버연결정보용 등록
//서비스정보용 등록
public function setService(string $action, ServiceEntity $serviceEntity, array $serviceDatas = []): ServiceEntity
public function setService(string $action, ServiceEntity $serviceEntity, array $serviceDatas = []): ServiceENtity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();

View File

@ -1,77 +0,0 @@
<?php
namespace App\Services\Payment;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\PaymentEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\PaymentService;
class ServicePart extends PaymentService implements ServerPartInterface
{
public function __construct()
{
parent::__construct();
}
//서버연결정보용 등록
public function setServerPart(string $action, ServerPartEntity $serverPartEntity, array $serverPartDatas = []): ServerPartEntity
{
$formDatas = [];
switch ($serverPartEntity->getBilling()) {
case PAYMENT['BILLING']['MONTH']:
if ($serverPartEntity->getServiceInfoUID() === null) {
throw new \Exception(lang("{$this->getClassName()}.BILLING." . PAYMENT['BILLING']['MONTH']) . "지급 상품은 서비스정보가 정의된 후에만 가능합니다.");
}
//Service Entity 가져오기
$serviceEntity = $this->getServiceService()->getEntity($serverPartEntity->getServiceInfoUID());
if (!$serviceEntity) {
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
}
//월비용인경우 서비스 제공가에 서버연결정보 제공가 합산금액으로 설정
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) {
$formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
$formDatas['amount'] = $serviceEntity->getAmount() + $serverPartEntity->getAmount();
$this->getServiceService()->modify($serviceEntity, $formDatas);
}
break;
case PAYMENT['BILLING']['ONETIME']:
if ($serverPartEntity->getServiceInfoUID() === null) {
throw new \Exception(lang("{$this->getClassName()}.BILLING." . PAYMENT['BILLING']['ONETIME']) . "지급 상품은 서비스정보가 정의된 후에만 가능합니다.");
}
//Service Entity 가져오기
$serviceEntity = $this->getServiceService()->getEntity($serverPartEntity->getServiceInfoUID());
if (!$serviceEntity) {
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
}
//일회성인경우
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME']) {
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['serverpartinfo_uid'] = $serverPartEntity->getPK();
$formDatas['title'] = $serverPartEntity->getType() === 'ETC' ? $serverPartEntity->getTitle() : $serverPartEntity->getPartEntity()->getTitle();
$formDatas['amount'] = $serverPartEntity->getAmount();
$formDatas['billing'] = $serverPartEntity->getBilling();
$formDatas['billing_at'] = $serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME'] ? date("Y-m-d") : $serviceEntity->getBillingAT();
if ($action === 'create') {
//지급기한일 설정
$formDatas['billing_at'] = $serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME'] ? date("Y-m-d") : $serviceEntity->getBillingAT();
$this->create($formDatas);
}
if ($action === 'modify') {
if (!array_key_exists('serverpartinfo_uid', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 기존 결제정보가 지정되지 않았습니다.");
}
$entity = $this->getEntity(['serverpartinfo_uid' => $serverPartEntity->getPK(), 'status' => STATUS['UNPAID']]);
if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: {$serverPartEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
}
$this->modify($entity, $formDatas);
}
}
break;
}
return $serverPartEntity;
}
}

View File

@ -14,7 +14,17 @@ class ServicePart extends ServiceService implements ServerPartInterface
parent::__construct();
}
//서버연결정보용 등록
public function setServerPart(string $action, ServerPartEntity $serverPartEntity, array $serverPartDatas = []): ServerPartEntity
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;