dbmsv3 init...1
This commit is contained in:
parent
40b4443f41
commit
7f58a58b68
@ -6,7 +6,5 @@ use App\Entities\Customer\ServiceEntity;
|
|||||||
|
|
||||||
interface ServiceInterface extends CustomerInterface
|
interface ServiceInterface extends CustomerInterface
|
||||||
{
|
{
|
||||||
public function setService(ServiceEntity $serviceEntity, array $formDatas): ServiceEntity;
|
public function setService(string $action, ServiceEntity $serviceEntity, array $formDatas): ServiceEntity;
|
||||||
public function changeService(ServiceEntity $oldServiceEntity, ServiceEntity $serviceEntity, array $formDatas): ServiceEntity;
|
|
||||||
public function unsetService(ServiceEntity $serviceEntity, array $formDatas): ServiceEntity;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,5 @@ use App\Entities\Equipment\ServerEntity;
|
|||||||
|
|
||||||
interface ServerInterface extends EquipmentInterface
|
interface ServerInterface extends EquipmentInterface
|
||||||
{
|
{
|
||||||
public function setServer(ServerEntity $serverEntity, array $formDatas): ServerEntity;
|
public function setServer(string $action, ServerEntity $serverEntity, array $formDatas): ServerEntity;
|
||||||
public function changeServer(ServerEntity $oldServerEntity, ServerEntity $serverEntity, array $formDatas): ServerEntity;
|
|
||||||
public function unsetServer(ServerEntity $serverEntity, array $formDatas): ServerEntity;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,5 @@ use App\Entities\Equipment\ServerPartEntity;
|
|||||||
|
|
||||||
interface ServerPartInterface extends EquipmentInterface
|
interface ServerPartInterface extends EquipmentInterface
|
||||||
{
|
{
|
||||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $formDatas): ServerPartEntity;
|
public function setServerPart(string $action, ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): mixed;
|
||||||
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $formDatas): ServerPartEntity;
|
|
||||||
public function unsetServerPart(ServerPartEntity $serverPartEntity, array $formDatas): ServerPartEntity;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,6 @@ namespace App\Services\Customer;
|
|||||||
|
|
||||||
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\Entities\PaymentEntity;
|
use App\Entities\PaymentEntity;
|
||||||
use App\Helpers\Customer\ServiceHelper;
|
use App\Helpers\Customer\ServiceHelper;
|
||||||
use App\Models\Customer\ServiceModel;
|
use App\Models\Customer\ServiceModel;
|
||||||
@ -209,105 +208,76 @@ class ServiceService extends CustomerService
|
|||||||
//생성
|
//생성
|
||||||
public function create(array $formDatas): ServiceEntity
|
public function create(array $formDatas): ServiceEntity
|
||||||
{
|
{
|
||||||
|
//신규등록(월청구액 전달값 그대로 사용하므로 getCaculatedAmount 필요없음)
|
||||||
|
$entity = parent::create($formDatas);
|
||||||
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 서버가 지정되지 않았습니다.");
|
throw new \Exception(__METHOD__ . "에서 오류발생: 서버가 지정되지 않았습니다.");
|
||||||
}
|
}
|
||||||
//신규등록(월청구액 전달값 그대로 사용하므로 getCaculatedAmount 필요없음)
|
|
||||||
$entity = parent::create($formDatas);
|
|
||||||
//서버등록
|
//서버등록
|
||||||
$serverEntity = $this->getServerService()->getEntity($formDatas['serverinfo_uid']);
|
$entity = $entity->setServerEntity($this->getServerService()->setService('create', $entity, $formDatas));
|
||||||
if (!$serverEntity instanceof ServerEntity || $serverEntity->getStatus() != STATUS['AVAILABLE']) {
|
|
||||||
throw new \Exception("{$formDatas['serverinfo_uid']}에 대한 서버정보를 찾을수 없거나, 사용가능 서버가 아닙니다.");
|
|
||||||
}
|
|
||||||
$formDatas = [];
|
|
||||||
$formDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
|
||||||
$formDatas['serviceinfo_uid'] = $entity->getPK();
|
|
||||||
$formDatas['status'] = STATUS['OCCUPIED'];
|
|
||||||
//필수정보처리 후 서버정보등록 후 서비스정보 Entity에 서버정보 설정
|
|
||||||
$entity = $entity->setServerEntity($this->getServerService()->modify($serverEntity, $formDatas));
|
|
||||||
//전체 서비스금액 설정
|
//전체 서비스금액 설정
|
||||||
$formDatas = [];
|
$entity = $entity->setPaymentEntity($this->getPaymentService()->setService('create', $entity, $formDatas));
|
||||||
$formDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
return $entity;
|
||||||
$formDatas['serviceinfo_uid'] = $entity->getPK();
|
|
||||||
$formDatas['serverinfo_uid'] = $entity->getServerInfoUID();
|
|
||||||
$formDatas['title'] = $entity->getServerEntity()->getTitle();
|
|
||||||
$formDatas['amount'] = $entity->getAmount();
|
|
||||||
$formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
|
|
||||||
$formDatas['billing_at'] = $entity->getBillingAt();
|
|
||||||
//필수정보처리 후 결제정보등록 후 서비스정보 Entity에 결제정보 설정
|
|
||||||
return $entity->setPaymentEntity($this->getPaymentService()->create($formDatas));
|
|
||||||
}
|
}
|
||||||
//수정
|
//수정
|
||||||
public function modify(mixed $entity, array $formDatas): ServiceEntity
|
public function modify(mixed $entity, array $formDatas): ServiceEntity
|
||||||
{
|
{
|
||||||
//수정전 정보
|
//수정전 정보
|
||||||
$oldEntity = $entity;
|
$oldEntity = $entity;
|
||||||
//서비스정보 수정
|
//서비스 금액 재계산 후 서비스정보 수정
|
||||||
|
$formDatas['amount'] = $this->getCaculatedAmount($entity);
|
||||||
$entity = parent::modify($entity, $formDatas);
|
$entity = parent::modify($entity, $formDatas);
|
||||||
//기존 서버정보와 다르다면 서버변경
|
//기존 서버정보와 다르다면 서버변경
|
||||||
if ($oldEntity->getServerEntity()->getPK() != $formDatas['serverinfo_uid']) {
|
if ($oldEntity->getServerEntity()->getPK() != $formDatas['serverinfo_uid']) {
|
||||||
$serverEntity = $oldEntity->getServerEntity();
|
//기존서버처리
|
||||||
$formDatas = [];
|
$entity = $entity->setServerEntity($this->getServerService()->setService('delete', $oldEntity, ['serverinfo_uid' => $oldEntity->getServerInfoUID()]));
|
||||||
$formDatas['clientinfo_uid'] = null;
|
//수정할신규서버처리
|
||||||
$formDatas['serviceinfo_uid'] = null;
|
$entity = $entity->setServerEntity($this->getServerService()->setService('create', $entity, $formDatas));
|
||||||
$formDatas['format_at'] = date("Y-m-d");
|
|
||||||
$formDatas['status'] = STATUS['AVAILABLE'];
|
|
||||||
$entity = $entity->setServerEntity($this->getServerService()->modify($serverEntity, $formDatas));
|
|
||||||
}
|
}
|
||||||
//전체 서비스금액 설정
|
//전체 서비스금액 설정
|
||||||
$formDatas = [];
|
$entity = $entity->setPaymentEntity($this->getPaymentService()->setService('modify', $entity));
|
||||||
$formDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
return $entity;
|
||||||
$formDatas['serviceinfo_uid'] = $entity->getPK();
|
|
||||||
$formDatas['serverinfo_uid'] = $entity->getServerInfoUID();
|
|
||||||
$formDatas['title'] = $entity->getServerEntity()->getTitle();
|
|
||||||
$formDatas['amount'] = $entity->getAmount();
|
|
||||||
$formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
|
|
||||||
$formDatas['billing_at'] = $entity->getBillingAt();
|
|
||||||
//필수정보처리 후 결제정보등록 후 서비스정보 Entity에 결제정보 설정
|
|
||||||
return $entity->setPaymentEntity($this->getPaymentService()->create($formDatas));
|
|
||||||
}
|
}
|
||||||
//삭제
|
//삭제
|
||||||
public function delete(mixed $entity): ServiceEntity
|
public function delete(mixed $entity): ServiceEntity
|
||||||
{
|
{
|
||||||
//서버해지
|
//서버해지
|
||||||
$this->getServerService()->unsetService($entity, ['serverinfo_uid' => $entity->getServerEntity()->getPK()]);
|
$entity = $entity->setServerEntity($this->getServerService()->setService('delete', $entity));
|
||||||
return parent::delete($entity);
|
return parent::delete($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
//대체서버추가(가격변동은 없음)
|
//대체서버추가(가격변동은 없음)
|
||||||
public function addServer(ServiceEntity $entity, array $formDatas): ServiceEntity
|
public function addServer(ServiceEntity $entity, array $formDatas): ServiceEntity
|
||||||
{
|
{
|
||||||
//대체서버용인지 확인
|
//대체서버추가 및 결제처리는 하지않음
|
||||||
$this->getServerService()->setService($entity, $formDatas);
|
$formDatas['type'] = 'alternative';
|
||||||
|
$this->getServerService()->setService('create', $entity, $formDatas);
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
//대체서버를 메인서버로 설정
|
//대체서버를 메인서버로 설정
|
||||||
public function changeServere(ServiceEntity $entity, array $formDatas): ServiceEntity
|
public function changeServere(ServiceEntity $entity, array $formDatas): ServiceEntity
|
||||||
{
|
{
|
||||||
// //기존메인서버 정보
|
$serverEntity = $entity->getServerEntity();
|
||||||
// $oldServerEntity = $entity->getServerEntity();
|
|
||||||
// //메인서버로 선정된 대체서버정보
|
|
||||||
$serverEntity = $this->getServerService()->getEntity($formDatas['serverinfo_uid']);
|
|
||||||
if (!$serverEntity instanceof ServerEntity) {
|
if (!$serverEntity instanceof ServerEntity) {
|
||||||
throw new \Exception("{$formDatas['serverinfo_uid']}에 대한 서버정보를 찾을수 없습니다.");
|
throw new \Exception(__METHOD__ . "에서 오류발생: 기존 메인 서버정보를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
// //메인서버로 선정된 서버의 형식을 기존메인서버의 형식으로 바꿈
|
//기존메인서버 정보회수처리용
|
||||||
// $serverEntity = $this->getServerService()->modify($serverEntity, ['type' => $oldServerEntity->getType()]);
|
$entity = $entity->setServerEntity($this->getServerService()->setService('delete', $entity));
|
||||||
//수정전 서비스정보
|
//메인서버로 선정된 대체서버정보
|
||||||
$oldEntity = $entity;
|
$formDatas['type'] = $serverEntity->getType();
|
||||||
//메인서버 변경(메인서버를 선정된 대체서버로 바꾼다.)
|
$this->getServerService()->setService('create', $entity, $formDatas);
|
||||||
$entity = parent::modify($entity, ['serverinfo_uid' => $serverEntity->getPK()]);
|
//서비스 금액 재계산 후 서비스정보 수정
|
||||||
|
$formDatas['amount'] = $this->getCaculatedAmount($entity);
|
||||||
|
$entity = parent::modify($entity, $formDatas);
|
||||||
//전체 서비스금액 설정
|
//전체 서비스금액 설정
|
||||||
$entity = $this->setAmount($entity);
|
$entity = $entity->setPaymentEntity($this->getPaymentService()->setService('modify', $entity));
|
||||||
//결제정보수정
|
return $entity;
|
||||||
$entity = $this->getPaymentService()->changeService($oldEntity, $entity, $formDatas);
|
|
||||||
//결제정보 PK설정
|
|
||||||
return parent::modify($entity, ['payment_uid' => $entity->getPaymentEntity()->getPK()]);
|
|
||||||
}
|
}
|
||||||
//대체서버해지(대체서버는 해지는 가격변동은 없음)
|
//대체서버해지(대체서버는 해지는 가격변동은 없음)
|
||||||
public function terminateServer(ServiceEntity $entity, array $formDatas): ServiceEntity
|
public function terminateServer(ServiceEntity $entity, array $formDatas): ServiceEntity
|
||||||
{
|
{
|
||||||
$this->getServerService()->unsetService($entity, $formDatas);
|
//대체서버해지 및 결제처리는 하지않음
|
||||||
|
$entity = $entity->setServerEntity($this->getServerService()->setService('delete', $entity, $formDatas));
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ use App\Entities\Equipment\ServerEntity;
|
|||||||
use App\Entities\Equipment\ServerPartEntity;
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
use App\Entities\PaymentEntity;
|
use App\Entities\PaymentEntity;
|
||||||
use App\Helpers\Equipment\ServerPartHelper;
|
use App\Helpers\Equipment\ServerPartHelper;
|
||||||
use App\Interfaces\Equipment\ServerInterface;
|
|
||||||
use App\Models\Equipment\ServerPartModel;
|
use App\Models\Equipment\ServerPartModel;
|
||||||
use App\Services\Customer\ServiceService;
|
use App\Services\Customer\ServiceService;
|
||||||
use App\Services\Equipment\EquipmentService;
|
use App\Services\Equipment\EquipmentService;
|
||||||
@ -21,7 +20,7 @@ use App\Services\Part\SOFTWAREService;
|
|||||||
use App\Services\Part\SWITCHService;
|
use App\Services\Part\SWITCHService;
|
||||||
use App\Services\PaymentService;
|
use App\Services\PaymentService;
|
||||||
|
|
||||||
class ServerPartService extends EquipmentService implements ServerInterface
|
class ServerPartService extends EquipmentService
|
||||||
{
|
{
|
||||||
private ?ServiceService $_serviceService = null;
|
private ?ServiceService $_serviceService = null;
|
||||||
private ?ServerService $_serverService = null;
|
private ?ServerService $_serverService = null;
|
||||||
@ -201,7 +200,38 @@ class ServerPartService extends EquipmentService implements ServerInterface
|
|||||||
}
|
}
|
||||||
return $service;
|
return $service;
|
||||||
}
|
}
|
||||||
|
//서버정보 설정
|
||||||
|
final public function setServer(string $action, ServerEntity $serverEntity, array $serverFormDatas = []): void
|
||||||
|
{
|
||||||
|
switch ($action) {
|
||||||
|
case 'delete':
|
||||||
|
//기존 ServerPart정보 삭제(서버파트정보 (월비용,일회성) 상품 회수처리)
|
||||||
|
foreach ($this->getEntities(['serverinfo_uid' => $serverEntity->getPK()]) as $entity) {
|
||||||
|
switch ($entity->getType()) {
|
||||||
|
case 'CPU':
|
||||||
|
case 'RAM':
|
||||||
|
//기본이 아닌 결제방식의 경우 모두 회수처리
|
||||||
|
if ($entity->getBilling() !== PAYMENT['BILLING']['BASE']) {
|
||||||
|
//Type에 따른 부품서비스 정의
|
||||||
|
$this->getPartService($entity->getType())->setServerPart('delete', $entity, $entity, []);
|
||||||
|
//서버연결정보 식제
|
||||||
|
parent::delete($entity);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: //DISK,IP,SWITCH,CS,SOFTWARE,OS등은 모두 회수처리
|
||||||
|
//Type에 따른 부품서비스 정의
|
||||||
|
$this->getPartService($entity->getType())->setServerPart('delete', $entity, $entity, []);
|
||||||
|
//서버연결정보 식제
|
||||||
|
parent::delete($entity);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:{$action}은 정의되지 않은 작업입니다.");
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
}
|
||||||
//partEntity 정보 추가
|
//partEntity 정보 추가
|
||||||
protected function getEntity_process(mixed $entity): ServerPartEntity
|
protected function getEntity_process(mixed $entity): ServerPartEntity
|
||||||
{
|
{
|
||||||
@ -266,28 +296,17 @@ class ServerPartService extends EquipmentService implements ServerInterface
|
|||||||
$entity = parent::create($formDatas);
|
$entity = parent::create($formDatas);
|
||||||
//후처리작업
|
//후처리작업
|
||||||
//Type에 따른 부품서비스 정의
|
//Type에 따른 부품서비스 정의
|
||||||
$this->getPartService($entity->getType())->setServerPart($entity, $formDatas);
|
$this->getPartService($entity->getType())->setServerPart('create', $entity, $entity, $formDatas);
|
||||||
//서비스 및 결제정보 처리
|
//서비스 및 결제정보 처리
|
||||||
switch ($entity->getBilling()) {
|
switch ($entity->getBilling()) {
|
||||||
case PAYMENT['BILLING']['MONTH']: //월별과금일때만 처리
|
case PAYMENT['BILLING']['MONTH']: //월별과금일때만 처리
|
||||||
if ($entity->getServiceInfoUID() === null) {
|
if ($entity->getServiceInfoUID() === null) {
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 서비스정보가 정의된 후에만 가능합니다.");
|
throw new \Exception(__METHOD__ . "에서 오류발생: 서비스정보가 정의된 후에만 가능합니다.");
|
||||||
}
|
}
|
||||||
$serviceEntity = $this->getServiceService()->getEntity($entity->getServiceInfoUID());
|
$entity = $this->getServiceService()->setAmount($this->getServiceService()->getEntity($entity->getServiceInfoUID()));
|
||||||
$entity = $this->getServiceService()->setAmount($serviceEntity);
|
|
||||||
break;
|
break;
|
||||||
case PAYMENT['BILLING']['ONETIME']: //일회성일때만 처리
|
case PAYMENT['BILLING']['ONETIME']: //일회성일때만 처리
|
||||||
$formDatas = [];
|
$entity->setPaymentEntity($this->getPaymentService()->setServerPart('create', $entity, $formDatas));
|
||||||
$formDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
|
||||||
$formDatas['serviceinfo_uid'] = $entity->getServiceInfoUID();
|
|
||||||
$formDatas['serverinfo_uid'] = $entity->getServerInfoUID(); //서버연결정보 수정시에 필요함
|
|
||||||
//타이틀은 기타의 경우 직접작성한 제목을 등록하고 아닌경우는 Part의 Title을 사용한다.
|
|
||||||
$formDatas['title'] = $entity->getPartEntity()->getTitle();
|
|
||||||
$formDatas['amount'] = $entity->getTotalAmount(); //단가*cnt
|
|
||||||
$formDatas['billing'] = $entity->getBilling();
|
|
||||||
//당일결체일로 설정
|
|
||||||
$formDatas['billing_at'] = date("Y-m-d");
|
|
||||||
$entity->setPaymentEntity($this->getPaymentService()->create($formDatas));
|
|
||||||
//결제정보PK정의
|
//결제정보PK정의
|
||||||
$entity = parent::modify($entity, ['payment_uid' => $entity->getPaymentEntity()->getPK()]);
|
$entity = parent::modify($entity, ['payment_uid' => $entity->getPaymentEntity()->getPK()]);
|
||||||
break;
|
break;
|
||||||
@ -320,19 +339,17 @@ class ServerPartService extends EquipmentService implements ServerInterface
|
|||||||
$entity = parent::modify($entity, $formDatas);
|
$entity = parent::modify($entity, $formDatas);
|
||||||
//후처리작업
|
//후처리작업
|
||||||
//Type에 따른 부품서비스 정의
|
//Type에 따른 부품서비스 정의
|
||||||
$this->getPartService($entity->getType())->changeServerPart($oldEntity, $entity, $formDatas);
|
$this->getPartService($entity->getType())->setServerPart('modify', $oldEntity, $entity, $formDatas);
|
||||||
//서비스 및 결제정보 처리
|
//서비스 및 결제정보 처리
|
||||||
switch ($entity->getBilling()) {
|
switch ($entity->getBilling()) {
|
||||||
case PAYMENT['BILLING']['MONTH']: //월별과금일때만 처리
|
case PAYMENT['BILLING']['MONTH']: //월별과금일때만 처리
|
||||||
if ($entity->getServiceInfoUID() !== null) {
|
if ($entity->getServiceInfoUID() !== null) { //서비스가 정의되어 있으면
|
||||||
$serviceEntity = $this->getServiceService()->getEntity($entity->getServiceInfoUID());
|
$entity = $this->getServiceService()->setAmount($this->getServiceService()->getEntity($entity->getServiceInfoUID()));
|
||||||
$entity = $this->getServiceService()->setAmount($serviceEntity);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PAYMENT['BILLING']['ONETIME']: //일회성일때만 처리
|
case PAYMENT['BILLING']['ONETIME']: //일회성일때만 처리
|
||||||
if ($entity->getPaymentUID() !== null) {
|
if ($entity->getPaymentUID() !== null) { //결제정보가 정의되어 있으면
|
||||||
$paymentEntity = $this->getPaymentService()->getEntity($entity->getPaymentUID());
|
$entity->setPaymentEntity($this->getPaymentService()->setServerPart('modify', $entity, $formDatas));
|
||||||
$entity->setPaymentEntity($this->getPaymentService()->setAmount($paymentEntity, $entity->getAmount() * $entity->getCnt()));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PAYMENT['BILLING']['BASE']: //기본처리
|
case PAYMENT['BILLING']['BASE']: //기본처리
|
||||||
@ -347,9 +364,11 @@ class ServerPartService extends EquipmentService implements ServerInterface
|
|||||||
//삭제
|
//삭제
|
||||||
public function delete(mixed $entity): ServerPartEntity
|
public function delete(mixed $entity): ServerPartEntity
|
||||||
{
|
{
|
||||||
|
//수정전 정보
|
||||||
|
$oldEntity = $entity;
|
||||||
$entity = parent::delete($entity);
|
$entity = parent::delete($entity);
|
||||||
//Type에 따른 부품서비스 정의
|
//Type에 따른 부품서비스 정의
|
||||||
$this->getPartService($entity->getType())->unSetServerPart($entity, []);
|
$this->getPartService($entity->getType())->setServerPart('delete', $oldEntity, $entity, []);
|
||||||
//삭제시는 월비용 서비스만 처리
|
//삭제시는 월비용 서비스만 처리
|
||||||
if ($entity->getBilling() === PAYMENT['BILLING']['MONTH']) {
|
if ($entity->getBilling() === PAYMENT['BILLING']['MONTH']) {
|
||||||
//서비스가 정의되어 있으면 실행
|
//서비스가 정의되어 있으면 실행
|
||||||
@ -360,41 +379,4 @@ class ServerPartService extends EquipmentService implements ServerInterface
|
|||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
//서버관련 작업
|
|
||||||
public function setServer(ServerEntity $serverEntity, array $serverDatas): ServerEntity
|
|
||||||
{
|
|
||||||
//아무것도 하지 않음
|
|
||||||
return $serverEntity;
|
|
||||||
}
|
|
||||||
public function changeServer(ServerEntity $oldServerEntity, ServerEntity $serverEntity, array $serverDatas): ServerEntity
|
|
||||||
{
|
|
||||||
//아무것도 하지 않음
|
|
||||||
return $serverEntity;
|
|
||||||
}
|
|
||||||
public function unsetServer(ServerEntity $serverEntity, array $serverDatas): ServerEntity
|
|
||||||
{
|
|
||||||
|
|
||||||
//기존 ServerPart정보 삭제(서버파트정보 (월비용,일회성) 상품 회수처리)
|
|
||||||
foreach ($this->getEntities(['serverinfo_uid' => $serverEntity->getPK()]) as $serverPartEntity) {
|
|
||||||
switch ($serverPartEntity->getType()) {
|
|
||||||
case 'CPU':
|
|
||||||
case 'RAM':
|
|
||||||
//기본이 아닌 결제방식의 경우 모두 회수처리
|
|
||||||
if ($serverPartEntity->getBilling() !== PAYMENT['BILLING']['BASE']) {
|
|
||||||
//Type에 따른 부품서비스 정의
|
|
||||||
$this->getPartService($serverPartEntity->getType())->unSetServerPart($serverPartEntity, []);
|
|
||||||
//서버연결정보 식제
|
|
||||||
parent::delete($serverPartEntity);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: //DISK,IP,SWITCH,CS,SOFTWARE,OS등은 모두 회수처리
|
|
||||||
$this->getPartService($serverPartEntity->getType())->unSetServerPart($serverPartEntity, []);
|
|
||||||
//서버연결정보 식제
|
|
||||||
parent::delete($serverPartEntity);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $serverEntity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,13 +5,12 @@ namespace App\Services\Equipment;
|
|||||||
use App\Entities\Customer\ServiceEntity;
|
use App\Entities\Customer\ServiceEntity;
|
||||||
use App\Entities\Equipment\ServerEntity;
|
use App\Entities\Equipment\ServerEntity;
|
||||||
use App\Helpers\Equipment\ServerHelper;
|
use App\Helpers\Equipment\ServerHelper;
|
||||||
use App\Interfaces\Customer\ServiceInterface;
|
|
||||||
use App\Models\Equipment\ServerModel;
|
use App\Models\Equipment\ServerModel;
|
||||||
use App\Services\Customer\ServiceService;
|
use App\Services\Customer\ServiceService;
|
||||||
use App\Services\Equipment\EquipmentService;
|
use App\Services\Equipment\EquipmentService;
|
||||||
use App\Services\Equipment\ServerPartService;
|
use App\Services\Equipment\ServerPartService;
|
||||||
|
|
||||||
class ServerService extends EquipmentService implements ServiceInterface
|
class ServerService extends EquipmentService
|
||||||
{
|
{
|
||||||
private ?ServiceService $_serviceService = null;
|
private ?ServiceService $_serviceService = null;
|
||||||
private ?ServerPartService $_serverPartService = null;
|
private ?ServerPartService $_serverPartService = null;
|
||||||
@ -122,6 +121,49 @@ class ServerService extends EquipmentService implements ServiceInterface
|
|||||||
// dd($totalCounts);
|
// dd($totalCounts);
|
||||||
return $totalCounts;
|
return $totalCounts;
|
||||||
}
|
}
|
||||||
|
//서비스정보 설정
|
||||||
|
final public function setService(string $action, ServiceEntity $serviceEntity, array $serviceFormDatas = []): ServerEntity
|
||||||
|
{
|
||||||
|
switch ($action) {
|
||||||
|
case 'create':
|
||||||
|
if (!array_key_exists('serverinfo_uid', $serviceFormDatas)) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생: 서버가 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
$entity = $this->getEntity($serviceFormDatas['serverinfo_uid']);
|
||||||
|
if (!$entity instanceof ServerEntity || $entity->getStatus() != STATUS['AVAILABLE']) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:{$serviceFormDatas['serverinfo_uid']}에 대한 서버정보를 찾을수 없거나, 사용가능 서버가 아닙니다.");
|
||||||
|
}
|
||||||
|
$formDatas = [];
|
||||||
|
//대체서버 추가용인지 확인
|
||||||
|
if (array_key_exists('type', $serviceFormDatas)) {
|
||||||
|
$formDatas['type'] = $serviceFormDatas['type'];
|
||||||
|
}
|
||||||
|
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
|
||||||
|
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
||||||
|
$formDatas['status'] = STATUS['OCCUPIED'];
|
||||||
|
$entity = parent::modify($entity, $formDatas);
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
if (!array_key_exists('serverinfo_uid', $serviceFormDatas)) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생: 서버가 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
$entity = $this->getEntity($serviceFormDatas['serverinfo_uid']);
|
||||||
|
if (!$entity instanceof ServerEntity) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:해지 할 서버정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
$formDatas = [];
|
||||||
|
$formDatas['clientinfo_uid'] = null;
|
||||||
|
$formDatas['serviceinfo_uid'] = null;
|
||||||
|
$formDatas['format_at'] = date("Y-m-d");
|
||||||
|
$formDatas['status'] = STATUS['AVAILABLE'];
|
||||||
|
$entity = parent::modify($entity, $formDatas);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:{$action}은 정의되지 않은 작업입니다.");
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
//기본 기능부분
|
//기본 기능부분
|
||||||
//FieldForm관련용
|
//FieldForm관련용
|
||||||
public function getFormOption(string $field, $options = []): array
|
public function getFormOption(string $field, $options = []): array
|
||||||
@ -136,24 +178,6 @@ class ServerService extends EquipmentService implements ServiceInterface
|
|||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
public function setFormData(string $field, array $requestDatas, array $formDatas): array
|
|
||||||
{
|
|
||||||
switch ($field) {
|
|
||||||
case 'CPU':
|
|
||||||
case 'RAM':
|
|
||||||
$formDatas[$field] = $requestDatas[$field] ?? null;
|
|
||||||
$formDatas["{$field}_cnt"] = $requestDatas["{$field}_cnt"] ?? null;
|
|
||||||
break;
|
|
||||||
case 'DISK':
|
|
||||||
$formDatas[$field] = $requestDatas[$field] ?? null;
|
|
||||||
$formDatas["{$field}_cnt"] = $requestDatas["{$field}_cnt"] ?? null;
|
|
||||||
$formDatas["{$field}_extra"] = $requestDatas["{$field}_extra"] ?? null;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$formDatas = parent::setFormData($field, $requestDatas, $formDatas);
|
|
||||||
}
|
|
||||||
return $formDatas;
|
|
||||||
}
|
|
||||||
public function create(array $formDatas): ServerEntity
|
public function create(array $formDatas): ServerEntity
|
||||||
{
|
{
|
||||||
$entity = parent::create($formDatas);
|
$entity = parent::create($formDatas);
|
||||||
@ -179,7 +203,13 @@ class ServerService extends EquipmentService implements ServiceInterface
|
|||||||
throw new \Exception("서비스중이 서버는 삭제하실수 없습니다.");
|
throw new \Exception("서비스중이 서버는 삭제하실수 없습니다.");
|
||||||
}
|
}
|
||||||
//선처리작업
|
//선처리작업
|
||||||
$entity = $this->getServerPartService()->unsetServer($entity, []);;
|
//서비스가 연결되어 있고 대체서버가 아니면, 서비스정보수정(청구액수정)
|
||||||
|
if ($entity->getServiceInfoUID() !== null && $entity->getType() !== "alternative") {
|
||||||
|
$serviceEntity = $this->getServiceService()->getEntity($entity->getServiceInfoUID());
|
||||||
|
$this->getServiceService()->setAmount($serviceEntity);
|
||||||
|
}
|
||||||
|
//서버파트정보해지
|
||||||
|
$this->getServerPartService()->setServer('dedete', $entity);
|
||||||
return parent::delete($entity);
|
return parent::delete($entity);
|
||||||
}
|
}
|
||||||
//List 검색용
|
//List 검색용
|
||||||
@ -189,39 +219,4 @@ class ServerService extends EquipmentService implements ServiceInterface
|
|||||||
$this->getModel()->orderBy("code ASC,title ASC");
|
$this->getModel()->orderBy("code ASC,title ASC");
|
||||||
parent::setOrderBy($field, $value);
|
parent::setOrderBy($field, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeService(ServiceEntity $oldServiceEntity, ServiceEntity $serviceEntity, array $serviceDatas): ServiceEntity
|
|
||||||
{
|
|
||||||
if (!array_key_exists('serverinfo_uid', $serviceDatas)) {
|
|
||||||
throw new \Exception("신규로 지정할 서버정보가 없습니다.");
|
|
||||||
}
|
|
||||||
//기존 서버 해지(uynsetService사용)
|
|
||||||
$this->unsetService($serviceEntity, ['serverinfo_uid' => $serviceEntity->getServerEntity()->getPK()]);
|
|
||||||
//신규서버 설정(setService사용)
|
|
||||||
return $this->setService($serviceEntity, $serviceDatas);
|
|
||||||
}
|
|
||||||
public function unsetService(ServiceEntity $serviceEntity, array $serviceDatas): ServiceEntity
|
|
||||||
{
|
|
||||||
if (!array_key_exists('serverinfo_uid', $serviceDatas)) {
|
|
||||||
throw new \Exception("서비스를 해지할 서버정보가 없습니다.");
|
|
||||||
}
|
|
||||||
if ($serviceEntity->getServerEntity()->getPK() === $serviceDatas['serverinfo_uid']) {
|
|
||||||
throw new \Exception("Main으로 설정된 서버는 해지하실 수 없습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->getEntity($serviceDatas['serverinfo_uid']);
|
|
||||||
if (!$entity instanceof ServerEntity) {
|
|
||||||
throw new \Exception("{$serviceDatas['serverinfo_uid']}에 대한 서버정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
//서버정보설정
|
|
||||||
$formDatas = [];
|
|
||||||
$formDatas['clientinfo_uid'] = null;
|
|
||||||
$formDatas['serviceinfo_uid'] = null;
|
|
||||||
$formDatas['format_at'] = date("Y-m-d");
|
|
||||||
$formDatas['status'] = STATUS['AVAILABLE'];
|
|
||||||
$entity = parent::modify($entity, $formDatas);
|
|
||||||
//서버파트정보 회수처리 호출
|
|
||||||
$this->getServerPartService()->unsetServer($entity, []);
|
|
||||||
return $serviceEntity;
|
|
||||||
}
|
|
||||||
//서버파트관련 작업
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,41 +52,4 @@ class CPUService extends PartService implements ServerPartInterface
|
|||||||
$this->getModel()->orderBy('title ASC');
|
$this->getModel()->orderBy('title ASC');
|
||||||
parent::setOrderBy($field, $value);
|
parent::setOrderBy($field, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//서버파트관련 작업
|
|
||||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
//부품정보가져오기
|
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
|
||||||
if (!$entity instanceof CPUEntity) {
|
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
||||||
if ($entity->getStock() < $serverPartEntity->getCnt()) {
|
|
||||||
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
|
||||||
}
|
|
||||||
$entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
|
|
||||||
return $serverPartEntity->setPartEntity($entity);
|
|
||||||
}
|
|
||||||
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
|
|
||||||
//수정 전 부품연결정보관련 정보처리 갯수,파트가 달라졌을경우 (회수 -> 사용 처리)
|
|
||||||
//기존것 회수 처리
|
|
||||||
if ($oldServerPartEntity->getCnt() != $serverPartEntity->getCnt() || $oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
|
||||||
$this->unsetServerPart($oldServerPartEntity, $serverPartDatas);
|
|
||||||
}
|
|
||||||
//신규것 사용처리
|
|
||||||
return $this->setServerPart($serverPartEntity, $serverPartDatas);
|
|
||||||
}
|
|
||||||
public function unsetServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
//부품정보가져오기
|
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
|
||||||
if (!$entity instanceof CPUEntity) {
|
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
$entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]);
|
|
||||||
return $serverPartEntity->setPartEntity($entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,8 +106,10 @@ class CSService extends PartService implements ServerPartInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
//서버파트관련 작업
|
//서버파트관련 작업
|
||||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
public function setServerPart(string $action, ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): CSEntity
|
||||||
{
|
{
|
||||||
|
switch ($action) {
|
||||||
|
case 'create':
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||||
@ -122,20 +124,18 @@ class CSService extends PartService implements ServerPartInterface
|
|||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
//CS정보 수정
|
//CS정보 수정
|
||||||
return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
|
$entity = parent::modify($entity, $formDatas);
|
||||||
}
|
break;
|
||||||
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
case 'modify':
|
||||||
{
|
|
||||||
|
|
||||||
//수정 전 부품연결정보관련 정보처리 파트정보가 달라졌을경우 (회수 -> 사용 처리)
|
//수정 전 부품연결정보관련 정보처리 파트정보가 달라졌을경우 (회수 -> 사용 처리)
|
||||||
|
//기존것 회수 처리
|
||||||
if ($oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
if ($oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
||||||
$this->unsetServerPart($oldServerPartEntity, $serverPartDatas);
|
$this->setServerPart('delete', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
}
|
}
|
||||||
//신규것 사용처리
|
//신규것 사용처리
|
||||||
return $this->setServerPart($serverPartEntity, $serverPartDatas);
|
$entity = $this->setServerPart('create', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
}
|
break;
|
||||||
public function unsetServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
case 'delete':
|
||||||
{
|
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
$formDatas['clientinfo_uid'] = null;
|
$formDatas['clientinfo_uid'] = null;
|
||||||
$formDatas['serviceinfo_uid'] = null;
|
$formDatas['serviceinfo_uid'] = null;
|
||||||
@ -150,6 +150,9 @@ class CSService extends PartService implements ServerPartInterface
|
|||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
//CS정보 수정
|
//CS정보 수정
|
||||||
return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
|
$entity = parent::modify($entity, $formDatas);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,11 +56,13 @@ class DISKService extends PartService implements ServerPartInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
//서버파트관련 작업
|
//서버파트관련 작업
|
||||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
public function setServerPart(string $action, ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): mixed
|
||||||
{
|
{
|
||||||
|
switch ($action) {
|
||||||
|
case 'create':
|
||||||
//부품정보가져오기
|
//부품정보가져오기
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
||||||
if (!$entity instanceof DISKEntity) {
|
if (!$entity) {
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||||
@ -68,26 +70,29 @@ class DISKService extends PartService implements ServerPartInterface
|
|||||||
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
||||||
}
|
}
|
||||||
$entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
|
$entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
|
||||||
return $serverPartEntity->setPartEntity($entity);
|
break;
|
||||||
}
|
case 'modify':
|
||||||
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
//수정 전 부품연결정보관련 정보처리 갯수,파트가 달라졌을경우 (회수 -> 사용 처리)
|
//수정 전 부품연결정보관련 정보처리 갯수,파트가 달라졌을경우 (회수 -> 사용 처리)
|
||||||
//기존것 회수 처리
|
//기존것 회수 처리
|
||||||
if ($oldServerPartEntity->getCnt() != $serverPartEntity->getCnt() || $oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
if ($oldServerPartEntity->getCnt() != $serverPartEntity->getCnt() || $oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
||||||
$this->unsetServerPart($oldServerPartEntity, $serverPartDatas);
|
$this->setServerPart('delete', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
}
|
}
|
||||||
//신규것 사용처리
|
//신규것 사용처리
|
||||||
return $this->setServerPart($serverPartEntity, $serverPartDatas);
|
$entity = $this->setServerPart('create', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
}
|
break;
|
||||||
public function unsetServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
case 'delete':
|
||||||
{
|
|
||||||
//부품정보가져오기
|
//부품정보가져오기
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
||||||
if (!$entity instanceof DISKEntity) {
|
if (!$entity) {
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||||
|
if ($entity->getStock() < $serverPartEntity->getCnt()) {
|
||||||
|
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
||||||
|
}
|
||||||
$entity = parent::modify($entity, ['format' => $entity->getFormat() + $serverPartEntity->getCnt()]);
|
$entity = parent::modify($entity, ['format' => $entity->getFormat() + $serverPartEntity->getCnt()]);
|
||||||
return $serverPartEntity->setPartEntity($entity);
|
break;
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,8 +121,10 @@ class IPService extends PartService implements ServerPartInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
//서버파트관련 작업
|
//서버파트관련 작업
|
||||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
public function setServerPart(string $action, ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): IPEntity
|
||||||
{
|
{
|
||||||
|
switch ($action) {
|
||||||
|
case 'create':
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||||
@ -137,27 +139,22 @@ class IPService extends PartService implements ServerPartInterface
|
|||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
//IP정보 수정
|
//IP정보 수정
|
||||||
return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
|
$entity = parent::modify($entity, $formDatas);
|
||||||
}
|
break;
|
||||||
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
case 'modify':
|
||||||
{
|
|
||||||
|
|
||||||
//수정 전 부품연결정보관련 정보처리 파트정보가 달라졌을경우 (회수 -> 사용 처리)
|
//수정 전 부품연결정보관련 정보처리 파트정보가 달라졌을경우 (회수 -> 사용 처리)
|
||||||
//기존것 회수 처리
|
//기존것 회수 처리
|
||||||
if ($oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
if ($oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
||||||
$this->unsetServerPart($oldServerPartEntity, $serverPartDatas);
|
$this->setServerPart('delete', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
}
|
}
|
||||||
//신규것 사용처리
|
//신규것 사용처리
|
||||||
return $this->setServerPart($serverPartEntity, $serverPartDatas);
|
$entity = $this->setServerPart('create', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
}
|
break;
|
||||||
public function unsetServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
case 'delete':
|
||||||
{
|
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
$formDatas['clientinfo_uid'] = null;
|
$formDatas['clientinfo_uid'] = null;
|
||||||
$formDatas['serviceinfo_uid'] = null;
|
$formDatas['serviceinfo_uid'] = null;
|
||||||
$formDatas['serverinfo_uid'] = null;
|
$formDatas['serverinfo_uid'] = null;
|
||||||
//기존 고객정보 기록용
|
|
||||||
$formDatas['old_clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
|
||||||
$formDatas['status'] = STATUS['AVAILABLE'];
|
$formDatas['status'] = STATUS['AVAILABLE'];
|
||||||
if (!array_key_exists('status', $formDatas)) {
|
if (!array_key_exists('status', $formDatas)) {
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: IP상태가 설정되지 않았습니다.");
|
throw new \Exception(__METHOD__ . "에서 오류발생: IP상태가 설정되지 않았습니다.");
|
||||||
@ -168,6 +165,9 @@ class IPService extends PartService implements ServerPartInterface
|
|||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
//IP정보 수정
|
//IP정보 수정
|
||||||
return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
|
$entity = parent::modify($entity, $formDatas);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,41 +52,4 @@ class OSService extends PartService implements ServerPartInterface
|
|||||||
$this->getModel()->orderBy('title ASC');
|
$this->getModel()->orderBy('title ASC');
|
||||||
parent::setOrderBy($field, $value);
|
parent::setOrderBy($field, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//서버파트관련 작업
|
|
||||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
//부품정보가져오기
|
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
|
||||||
if (!$entity instanceof OSEntity) {
|
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
||||||
if ($entity->getStock() < $serverPartEntity->getCnt()) {
|
|
||||||
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
|
||||||
}
|
|
||||||
$entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
|
|
||||||
return $serverPartEntity->setPartEntity($entity);
|
|
||||||
}
|
|
||||||
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
|
|
||||||
//수정 전 부품연결정보관련 정보처리 갯수,파트가 달라졌을경우 (회수 -> 사용 처리)
|
|
||||||
//기존것 회수 처리
|
|
||||||
if ($oldServerPartEntity->getCnt() != $serverPartEntity->getCnt() || $oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
|
||||||
$this->unsetServerPart($oldServerPartEntity, $serverPartDatas);
|
|
||||||
}
|
|
||||||
//신규것 사용처리
|
|
||||||
return $this->setServerPart($serverPartEntity, $serverPartDatas);
|
|
||||||
}
|
|
||||||
public function unsetServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
//부품정보가져오기
|
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
|
||||||
if (!$entity instanceof OSEntity) {
|
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
$entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]);
|
|
||||||
return $serverPartEntity->setPartEntity($entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Part;
|
namespace App\Services\Part;
|
||||||
|
|
||||||
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
use App\Helpers\CommonHelper;
|
use App\Helpers\CommonHelper;
|
||||||
use App\Models\CommonModel;
|
use App\Models\CommonModel;
|
||||||
use App\Services\CommonService;
|
use App\Services\CommonService;
|
||||||
@ -13,4 +14,45 @@ abstract class PartService extends CommonService
|
|||||||
parent::__construct($model, $helper);
|
parent::__construct($model, $helper);
|
||||||
$this->addClassName('Part');
|
$this->addClassName('Part');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//서버파트관련 작업
|
||||||
|
public function setServerPart(string $action, ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): mixed
|
||||||
|
{
|
||||||
|
switch ($action) {
|
||||||
|
case 'create':
|
||||||
|
//부품정보가져오기
|
||||||
|
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
||||||
|
if (!$entity) {
|
||||||
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
||||||
|
}
|
||||||
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||||
|
if ($entity->getStock() < $serverPartEntity->getCnt()) {
|
||||||
|
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
||||||
|
}
|
||||||
|
$entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
|
||||||
|
break;
|
||||||
|
case 'modify':
|
||||||
|
//수정 전 부품연결정보관련 정보처리 갯수,파트가 달라졌을경우 (회수 -> 사용 처리)
|
||||||
|
//기존것 회수 처리
|
||||||
|
if ($oldServerPartEntity->getCnt() != $serverPartEntity->getCnt() || $oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
||||||
|
$this->setServerPart('delete', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
|
}
|
||||||
|
//신규것 사용처리
|
||||||
|
$entity = $this->setServerPart('create', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
//부품정보가져오기
|
||||||
|
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
||||||
|
if (!$entity) {
|
||||||
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
||||||
|
}
|
||||||
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||||
|
if ($entity->getStock() < $serverPartEntity->getCnt()) {
|
||||||
|
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
||||||
|
}
|
||||||
|
$entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,41 +52,4 @@ class RAMService extends PartService implements ServerPartInterface
|
|||||||
$this->getModel()->orderBy('title ASC');
|
$this->getModel()->orderBy('title ASC');
|
||||||
parent::setOrderBy($field, $value);
|
parent::setOrderBy($field, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//서버파트관련 작업
|
|
||||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
//부품정보가져오기
|
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
|
||||||
if (!$entity instanceof RAMEntity) {
|
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
||||||
if ($entity->getStock() < $serverPartEntity->getCnt()) {
|
|
||||||
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
|
||||||
}
|
|
||||||
parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
|
|
||||||
return $serverPartEntity->setPartEntity($entity);
|
|
||||||
}
|
|
||||||
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
|
|
||||||
//수정 전 부품연결정보관련 정보처리 갯수,파트가 달라졌을경우 (회수 -> 사용 처리)
|
|
||||||
//기존것 회수 처리
|
|
||||||
if ($oldServerPartEntity->getCnt() != $serverPartEntity->getCnt() || $oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
|
||||||
$this->unsetServerPart($oldServerPartEntity, $serverPartDatas);
|
|
||||||
}
|
|
||||||
//신규것 사용처리
|
|
||||||
return $this->setServerPart($serverPartEntity, $serverPartDatas);
|
|
||||||
}
|
|
||||||
public function unsetServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
//부품정보가져오기
|
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
|
||||||
if (!$entity instanceof RAMEntity) {
|
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]);
|
|
||||||
return $serverPartEntity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,41 +52,4 @@ class SOFTWAREService extends PartService implements ServerPartInterface
|
|||||||
$this->getModel()->orderBy('title ASC');
|
$this->getModel()->orderBy('title ASC');
|
||||||
parent::setOrderBy($field, $value);
|
parent::setOrderBy($field, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//서버파트관련 작업
|
|
||||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
//부품정보가져오기
|
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
|
||||||
if (!$entity instanceof SOFTWAREEntity) {
|
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
||||||
if ($entity->getStock() < $serverPartEntity->getCnt()) {
|
|
||||||
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
|
|
||||||
}
|
|
||||||
$entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
|
|
||||||
return $serverPartEntity->setPartEntity($entity);
|
|
||||||
}
|
|
||||||
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
|
|
||||||
//수정 전 부품연결정보관련 정보처리 갯수,파트가 달라졌을경우 (회수 -> 사용 처리)
|
|
||||||
//기존것 회수 처리
|
|
||||||
if ($oldServerPartEntity->getCnt() != $serverPartEntity->getCnt() || $oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
|
||||||
$this->unsetServerPart($oldServerPartEntity, $serverPartDatas);
|
|
||||||
}
|
|
||||||
//신규것 사용처리
|
|
||||||
return $this->setServerPart($serverPartEntity, $serverPartDatas);
|
|
||||||
}
|
|
||||||
public function unsetServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
||||||
{
|
|
||||||
//부품정보가져오기
|
|
||||||
$entity = $this->getEntity($serverPartEntity->getPartUID());
|
|
||||||
if (!$entity instanceof SOFTWAREEntity) {
|
|
||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
|
|
||||||
}
|
|
||||||
$entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]);
|
|
||||||
return $serverPartEntity->setPartEntity($entity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,8 +91,10 @@ class SWITCHService extends PartService implements ServerPartInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
//서버파트관련 작업
|
//서버파트관련 작업
|
||||||
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
public function setServerPart(string $action, ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): SWITCHEntity
|
||||||
{
|
{
|
||||||
|
switch ($action) {
|
||||||
|
case 'create':
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||||
@ -107,21 +109,18 @@ class SWITCHService extends PartService implements ServerPartInterface
|
|||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다.");
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
//SWITCH정보 수정
|
//SWITCH정보 수정
|
||||||
return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
|
$entity = parent::modify($entity, $formDatas);
|
||||||
}
|
break;
|
||||||
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
case 'modify':
|
||||||
{
|
|
||||||
|
|
||||||
//수정 전 부품연결정보관련 정보처리 파트정보가 달라졌을경우 (회수 -> 사용 처리)
|
//수정 전 부품연결정보관련 정보처리 파트정보가 달라졌을경우 (회수 -> 사용 처리)
|
||||||
//기존것 회수 처리
|
//기존것 회수 처리
|
||||||
if ($oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
if ($oldServerPartEntity->getPartUID() !== $serverPartEntity->getPartUID()) {
|
||||||
$this->unsetServerPart($oldServerPartEntity, $serverPartDatas);
|
$this->setServerPart('delete', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
}
|
}
|
||||||
//신규것 사용처리
|
//신규것 사용처리
|
||||||
return $this->setServerPart($serverPartEntity, $serverPartDatas);
|
$entity = $this->setServerPart('create', $oldServerPartEntity, $serverPartEntity, $serverPartDatas);
|
||||||
}
|
break;
|
||||||
public function unsetServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
case 'delete':
|
||||||
{
|
|
||||||
$formDatas = [];
|
$formDatas = [];
|
||||||
$formDatas['clientinfo_uid'] = null;
|
$formDatas['clientinfo_uid'] = null;
|
||||||
$formDatas['serviceinfo_uid'] = null;
|
$formDatas['serviceinfo_uid'] = null;
|
||||||
@ -136,6 +135,9 @@ class SWITCHService extends PartService implements ServerPartInterface
|
|||||||
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다.");
|
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다.");
|
||||||
}
|
}
|
||||||
//SWITCH정보 수정
|
//SWITCH정보 수정
|
||||||
return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
|
$entity = parent::modify($entity, $formDatas);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ 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\Helpers\PaymentHelper;
|
use App\Helpers\PaymentHelper;
|
||||||
use App\Interfaces\Customer\ServiceInterface;
|
|
||||||
use App\Models\PaymentModel;
|
use App\Models\PaymentModel;
|
||||||
use App\Services\CommonService;
|
use App\Services\CommonService;
|
||||||
use App\Services\Customer\ClientService;
|
use App\Services\Customer\ClientService;
|
||||||
@ -14,7 +13,7 @@ use App\Services\Customer\ServiceService;
|
|||||||
use App\Services\Equipment\ServerPartService;
|
use App\Services\Equipment\ServerPartService;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
|
|
||||||
class PaymentService extends CommonService implements ServiceInterface
|
class PaymentService extends CommonService
|
||||||
{
|
{
|
||||||
private ?UserService $_userService = null;
|
private ?UserService $_userService = null;
|
||||||
private ?ClientService $_clientService = null;
|
private ?ClientService $_clientService = null;
|
||||||
@ -117,10 +116,78 @@ class PaymentService extends CommonService implements ServiceInterface
|
|||||||
}
|
}
|
||||||
return $unPaids;
|
return $unPaids;
|
||||||
}
|
}
|
||||||
//결제금액설정
|
//서비스정보 설정
|
||||||
final public function setAmount(PaymentEntity $entity, int $amount): PaymentEntity
|
final public function setService(string $action, ServiceEntity $serviceEntity, array $serviceFormDatas = []): PaymentEntity
|
||||||
{
|
{
|
||||||
return parent::modify($entity, ['amount' => $amount]);
|
switch ($action) {
|
||||||
|
case 'create':
|
||||||
|
$formDatas = [];
|
||||||
|
$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'] = $serviceEntity->getBillingAt();
|
||||||
|
$entity = parent::create($formDatas);
|
||||||
|
break;
|
||||||
|
case 'modify':
|
||||||
|
$entity = $serviceEntity->getPaymentEntity();
|
||||||
|
if (!$entity instanceof PaymentEntity) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:결제정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
$formDatas = [];
|
||||||
|
$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'] = $serviceEntity->getBillingAt();
|
||||||
|
$entity = parent::modify($entity, $formDatas);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:{$action}은 정의되지 않은 작업입니다.");
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
final public function setServerPart(string $action, ServerPartEntity $serverPartEntity, array $servicePartFormDatas = []): PaymentEntity
|
||||||
|
{
|
||||||
|
switch ($action) {
|
||||||
|
case 'create':
|
||||||
|
$formDatas = [];
|
||||||
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||||
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||||
|
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); //서버연결정보 수정시에 필요함
|
||||||
|
//타이틀은 기타의 경우 직접작성한 제목을 등록하고 아닌경우는 Part의 Title을 사용한다.
|
||||||
|
$formDatas['title'] = $serverPartEntity->getPartEntity()->getTitle();
|
||||||
|
$formDatas['amount'] = $serverPartEntity->getTotalAmount(); //단가*cnt
|
||||||
|
$formDatas['billing'] = $serverPartEntity->getBilling();
|
||||||
|
//당일결체일로 설정
|
||||||
|
$formDatas['billing_at'] = date("Y-m-d");
|
||||||
|
$entity = parent::create($formDatas);
|
||||||
|
break;
|
||||||
|
case 'modify':
|
||||||
|
$entity = $serverPartEntity->getPaymentEntity();
|
||||||
|
if (!$entity instanceof PaymentEntity) {
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:결제정보를 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
$formDatas = [];
|
||||||
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||||
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||||
|
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); //서버연결정보 수정시에 필요함
|
||||||
|
//타이틀은 기타의 경우 직접작성한 제목을 등록하고 아닌경우는 Part의 Title을 사용한다.
|
||||||
|
$formDatas['title'] = $serverPartEntity->getPartEntity()->getTitle();
|
||||||
|
$formDatas['amount'] = $serverPartEntity->getTotalAmount(); //단가*cnt
|
||||||
|
$formDatas['billing'] = $serverPartEntity->getBilling();
|
||||||
|
$entity = parent::modify($entity, $formDatas);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception(__METHOD__ . "에서 오류발생:{$action}은 정의되지 않은 작업입니다.");
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
//기본 기능부분
|
//기본 기능부분
|
||||||
//FieldForm관련용
|
//FieldForm관련용
|
||||||
@ -157,31 +224,4 @@ class PaymentService extends CommonService implements ServiceInterface
|
|||||||
$this->getModel()->orderBy('billing_at ASC');
|
$this->getModel()->orderBy('billing_at ASC');
|
||||||
parent::setOrderBy($field, $value);
|
parent::setOrderBy($field, $value);
|
||||||
}
|
}
|
||||||
public function changeService(ServiceEntity $oldServiceEntity, ServiceEntity $serviceEntity, array $serviceDatas): ServiceEntity
|
|
||||||
{
|
|
||||||
//결제정보 가져오기
|
|
||||||
$entity = $serviceEntity->getPaymentEntity();
|
|
||||||
if (!$entity instanceof PaymentEntity) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 서비스정보[{$serviceEntity->getPK()}]에 해당하는 결제정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
//미납상태확인
|
|
||||||
if ($entity->getStatus() !== STATUS['UNPAID']) {
|
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: 완료된 결제는 수정이 불가합니다.");
|
|
||||||
}
|
|
||||||
$formDatas = [];
|
|
||||||
$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'] = $serviceEntity->getBillingAt();
|
|
||||||
//필수정보처리 후 결제정보수정 후 서비스정보 Entity에 결제정보 설정
|
|
||||||
return $serviceEntity->setPaymentEntity($this->getModel()->modify($entity, $formDatas));
|
|
||||||
}
|
|
||||||
public function unsetService(ServiceEntity $serviceEntity, array $serviceDatas): ServiceEntity
|
|
||||||
{
|
|
||||||
//아무것도 하지 않는다.
|
|
||||||
return $serviceEntity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user