dbmsv2_init...1

This commit is contained in:
choi.jh 2025-09-24 11:00:04 +09:00
parent 71992be4ac
commit d25295468d
15 changed files with 151 additions and 35 deletions

View File

@ -95,7 +95,7 @@ class ServiceController extends CustomerController
protected function index_process(array $entities = []): array protected function index_process(array $entities = []): array
{ {
//서비스별 미납 Count //서비스별 미납 Count
$this->unPaids = $this->getPaymentService()->getUnPaids('serviceinfo_uid'); $this->unPaids = $this->getPaymentService()->getUnPaids('serviceinfo_uid',);
//부모함수처리 //부모함수처리
return parent::index_process($entities); return parent::index_process($entities);
} }

View File

@ -390,7 +390,7 @@ CREATE TABLE `serverinfo` (
LOCK TABLES `serverinfo` WRITE; LOCK TABLES `serverinfo` WRITE;
/*!40000 ALTER TABLE `serverinfo` DISABLE KEYS */; /*!40000 ALTER TABLE `serverinfo` DISABLE KEYS */;
INSERT INTO `serverinfo` VALUES (17,NULL,NULL,'250922-M1','hp','HP DL360 Gen6',300000,'2025-08-31 15:00:00','0000-00-00 00:00:00','available','2025-09-22 02:24:11','2025-09-22 02:19:25',NULL),(18,NULL,NULL,'250922-M18','hp','HP DL360 Gen7',400000,'2025-09-01 15:00:00',NULL,'available',NULL,'2025-09-22 02:21:51',NULL),(19,NULL,NULL,'250922-M19','hp','HP DL360 Gen8',500000,'2025-09-02 15:00:00',NULL,'available',NULL,'2025-09-22 02:22:14',NULL),(20,NULL,NULL,'250922-M20','hp','HP DL360 Gen9',600000,'2025-09-03 15:00:00',NULL,'available',NULL,'2025-09-22 02:22:39',NULL),(21,NULL,NULL,'250922-M21','hp','HP DL360 Gen10',700000,'2025-09-04 15:00:00',NULL,'available',NULL,'2025-09-22 02:23:08',NULL),(22,NULL,NULL,'250922-M22','hp','Hitach HA3000',800000,'2025-09-05 15:00:00','0000-00-00 00:00:00','available','2025-09-22 02:23:53','2025-09-22 02:23:36',NULL); INSERT INTO `serverinfo` VALUES (17,NULL,NULL,'250922-M1','HP','HP DL360 Gen6',300000,'2025-08-31 15:00:00','0000-00-00 00:00:00','available','2025-09-22 02:24:11','2025-09-22 02:19:25',NULL),(18,NULL,NULL,'250922-M18','HP','HP DL360 Gen7',400000,'2025-09-01 15:00:00',NULL,'available',NULL,'2025-09-22 02:21:51',NULL),(19,NULL,NULL,'250922-M19','HP','HP DL360 Gen8',500000,'2025-09-02 15:00:00',NULL,'available',NULL,'2025-09-22 02:22:14',NULL),(20,NULL,NULL,'250922-M20','HP','HP DL360 Gen9',600000,'2025-09-03 15:00:00',NULL,'available',NULL,'2025-09-22 02:22:39',NULL),(21,NULL,NULL,'250922-M21','HP','HP DL360 Gen10',700000,'2025-09-04 15:00:00',NULL,'available',NULL,'2025-09-22 02:23:08',NULL),(22,NULL,NULL,'250922-M22','HP','Hitach HA3000',800000,'2025-09-05 15:00:00','0000-00-00 00:00:00','available','2025-09-22 02:23:53','2025-09-22 02:23:36',NULL);
/*!40000 ALTER TABLE `serverinfo` ENABLE KEYS */; /*!40000 ALTER TABLE `serverinfo` ENABLE KEYS */;
UNLOCK TABLES; UNLOCK TABLES;

File diff suppressed because one or more lines are too long

View File

@ -64,14 +64,17 @@ class ServiceEntity extends CustomerEntity
{ {
return $this->attributes['billing_at'] ?? ""; return $this->attributes['billing_at'] ?? "";
} }
//청구금액->기본:상면비+회선비+서버금액(price)+서버파트연결(월비용)
final public function getAmount(): int final public function getAmount(): int
{ {
return $this->attributes['amount'] ?? 0; return $this->attributes['amount'] ?? 0;
} }
//상면비
final public function getRack(): int final public function getRack(): int
{ {
return $this->attributes['rack'] ?? 0; return $this->attributes['rack'] ?? 0;
} }
//회선비
final public function getLine(): int final public function getLine(): int
{ {
return $this->attributes['line'] ?? 0; return $this->attributes['line'] ?? 0;

View File

@ -57,6 +57,10 @@ class ServerPartEntity extends EquipmentEntity
{ {
return $this->getPartEntity() !== null ? $this->getPartEntity()->getPrice() : 0; return $this->getPartEntity() !== null ? $this->getPartEntity()->getPrice() : 0;
} }
public function getCaculatedAmount(): int
{
return $this->getAmount() * $this->getCnt();
}
public function getType(): string public function getType(): string
{ {

View File

@ -86,6 +86,21 @@ class ServerPartHelper extends EquipmentHelper
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
{ {
switch ($field) { switch ($field) {
case 'Server':
if (array_key_exists('serverEntity', $viewDatas)) {
$value = form_label(
$value,
$field,
[
"data-src" => "/admin/equipment/server/modify/{$viewDatas['serverEntity']->getPK()}?ActionTemplate=popup",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
"class" => "btn btn-sm btn-outline btn-circle",
"target" => "_self",
]
);
}
break;
case 'CPU': case 'CPU':
case 'RAM': case 'RAM':
case 'DISK': case 'DISK':

View File

@ -6,7 +6,7 @@ use App\Entities\Equipment\ServerEntity;
interface ServerInterface extends EquipmentInterface interface ServerInterface extends EquipmentInterface
{ {
public function setServer(ServerPartEntity $serverPartEntity): ServerPartEntity; public function createServer(ServerEntity $serverEntity): ServerEntity;
public function modifServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity; public function modifyServer(ServerEntity $serverEntity): ServerEntity;
public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity; public function deleteServer(ServerEntity $serverEntity): ServerEntity;
} }

View File

@ -204,16 +204,15 @@ class ServiceService extends CustomerService
if (!$entity instanceof ServiceEntity) { if (!$entity instanceof ServiceEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생:[{$uid}]에 대한 서비스정보를 찾을수 없습니다."); throw new \Exception(__METHOD__ . "에서 오류발생:[{$uid}]에 대한 서비스정보를 찾을수 없습니다.");
} }
$total_amount = $entity->getAmount(); //기본:상면비+회선비+서버금액(price) $total_amount = $entity->getRack() + $entity->getLine() + $entity->getServerEntity()->getPrice(); //기본:상면비+회선비+서버금액(price)+서버파트연결(월비용)
//해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart 전체를 다시 검사하여 월청구액을 합산한다. //해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart 전체를 다시 검사하여 월청구액을 합산한다.
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getServerEntity()->getPK()]) as $serverPartEntity) { foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getServerEntity()->getPK()]) as $serverPartEntity) {
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) { if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) { //월비용일때만 적용
$total_amount += $serverPartEntity->getAmount(); $total_amount += $serverPartEntity->getCaculatedAmount(); //단가*Cnt
} }
} }
return $total_amount; return $total_amount;
} }
//기본기능
//기본 기능부분 //기본 기능부분
//FieldForm관련용 //FieldForm관련용
public function getFormOption(string $field, array $options = []): array public function getFormOption(string $field, array $options = []): array

View File

@ -0,0 +1,34 @@
<?php
namespace App\Services\Equipment\Server;
use App\Entities\Equipment\ServerEntity;
use App\Services\Equipment\ServerPartService as ParentService;
use App\Interfaces\Equipment\ServerInterface;
class ServerPartService extends ParentService implements ServerInterface
{
public function __construct()
{
parent::__construct();
}
public function createServer(ServerEntity $serverEntity): ServerEntity
{
//아무것도 하지 않음
return $serverEntity;
}
//create와 같은 작업임
public function modifyServer(ServerEntity $serverEntity): ServerEntity
{
return $this->createServer($serverEntity);
}
public function deleteServer(ServerEntity $serverEntity): ServerEntity
{
//기존 ServerPart정보 삭제
foreach ($this->getEntities(['serverinfo_uid' => $serverEntity->getPK()]) as $serverPartEntity) {
parent::delete($serverPartEntity);
}
return $serverEntity;
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace App\Services\Equipment\Server;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
use App\Interfaces\Equipment\ServerInterface;
use App\Services\Customer\ServiceService as ParentService;
class ServiceService extends ParentService implements ServerInterface
{
public function __construct()
{
parent::__construct();
}
private function action_process(ServerEntity $serverEntity): ServiceEntity
{
//Service Entity 가져오기
$entity = $this->getEntity($serverEntity->getServiceInfoUID());
if (!$entity instanceof ServiceEntity) {
throw new \Exception("[{$serverEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
}
//서비스금액은 modify 함수내에서 재계산을 하므로 여기서는 modify만 호출함
return parent::modify($entity, []);
}
public function createServer(ServerEntity $serverEntity): ServerEntity
{
//아무것도 하지 않음
return $serverEntity;
}
//create와 같은 작업임
public function modifyServer(ServerEntity $serverEntity): ServerEntity
{
return $this->createServer($serverEntity);
}
//create와 같은 작업임
public function deleteServer(ServerEntity $serverEntity): ServerEntity
{
if ($serverEntity->getServiceInfoUID() !== null || $serverEntity->getStatus() === STATUS['OCCUPIED']) {
throw new \Exception("서비스중이 서버는 삭제하실수 없습니다.");
}
return $this->createServer($serverEntity);
}
}

View File

@ -7,13 +7,13 @@ use App\Entities\PaymentEntity;
use App\Interfaces\Equipment\ServerPartInterface; use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\PaymentService as ParentService; use App\Services\PaymentService as ParentService;
//이 클래스는 일회성일때만 실행된다.
class PaymentService extends ParentService implements ServerPartInterface class PaymentService extends ParentService implements ServerPartInterface
{ {
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
} }
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): array private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): array
{ {
if ($serverPartEntity->getServiceInfoUID() === null) { if ($serverPartEntity->getServiceInfoUID() === null) {
@ -29,7 +29,7 @@ class PaymentService extends ParentService implements ServerPartInterface
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); //서버연결정보 수정시에 필요함 $formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); //서버연결정보 수정시에 필요함
//타이틀은 기타의 경우 직접작성한 제목을 등록하고 아닌경우는 Part의 Title을 사용한다. //타이틀은 기타의 경우 직접작성한 제목을 등록하고 아닌경우는 Part의 Title을 사용한다.
$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->getCaculatedAmount(); //단가*cnt
$formDatas['billing'] = $serverPartEntity->getBilling(); $formDatas['billing'] = $serverPartEntity->getBilling();
return $formDatas; return $formDatas;
} }
@ -46,10 +46,10 @@ class PaymentService extends ParentService implements ServerPartInterface
} }
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{ {
//미납상태의 결제정보 가져오기 //결제정보 가져오기
$entity = $this->getEntity(['serverpartinfo_uid' => $serverPartEntity->getPK(), 'status' => STATUS['UNPAID']]); $entity = $serverPartEntity->getPaymentEntity();
if (!$entity instanceof PaymentEntity) { if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: {$serverPartEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다."); throw new \Exception(__METHOD__ . "에서 오류발생: 서버파트연결정보{$serverPartEntity->getPK()}]에 해당하는 결제정보를 찾을수 없습니다.");
} }
//필수정보처리 후 FormData 가져오기 //필수정보처리 후 FormData 가져오기
$formDatas = $this->action_process($serverPartEntity); $formDatas = $this->action_process($serverPartEntity);

View File

@ -3,10 +3,10 @@
namespace App\Services\Equipment; namespace App\Services\Equipment;
use App\Entities\Equipment\ServerEntity; use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Helpers\Equipment\ServerHelper; use App\Helpers\Equipment\ServerHelper;
use App\Models\Equipment\ServerModel; use App\Models\Equipment\ServerModel;
use App\Services\Customer\ServiceService; use App\Services\Equipment\Server\ServiceService;
use App\Services\Equipment\Server\ServerPartService;
use App\Services\Equipment\EquipmentService; use App\Services\Equipment\EquipmentService;
class ServerService extends EquipmentService class ServerService extends EquipmentService
@ -78,7 +78,6 @@ class ServerService extends EquipmentService
} }
return $this->_serverPartService; return $this->_serverPartService;
} }
//partEntity 정보 추가 //partEntity 정보 추가
protected function getEntity_process(mixed $entity): ServerEntity protected function getEntity_process(mixed $entity): ServerEntity
{ {
@ -87,6 +86,7 @@ class ServerService extends EquipmentService
} }
return $entity; return $entity;
} }
//기본 기능부분
//FieldForm관련용 //FieldForm관련용
public function getFormOption(string $field, $options = []): array public function getFormOption(string $field, $options = []): array
{ {
@ -118,14 +118,29 @@ class ServerService extends EquipmentService
} }
return $formDatas; return $formDatas;
} }
//Action 기능
private function action_process(ServerEntity $entity, string $action): ServerEntity
{
//서비스정보수정(청구액수정)
$entity = $this->getServiceService()->$action($entity);
$entity = $this->getServerPartService()->$action($entity);
return $entity;
}
//수정
public function modify(mixed $entity, array $formDatas): ServerEntity
{
$entity->getServerService()->deleteService($entity);
//서버정보 수정
$entity = parent::modify($entity, $formDatas);
//후처리작업
return $this->action_process($entity, __FUNCTION__ . 'Server');
}
//삭제 //삭제
public function delete(mixed $entity): ServerEntity public function delete(mixed $entity): ServerEntity
{ {
//기존 ServerPart정보 삭제 $entity = parent::delete($entity);
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $serverPartEntity) { //후처리작업
$this->getServerPartService()->delete($serverPartEntity); return $this->action_process($entity, __FUNCTION__ . 'Server');
}
return parent::delete($entity);
} }
//List 검색용 //List 검색용
//OrderBy 처리 //OrderBy 처리

View File

@ -102,12 +102,11 @@ class PaymentService extends CommonService
return $this->_serverPartService; return $this->_serverPartService;
} }
//당일 기준으로 총 미납건수, 금액 //총 미납건수, 금액
final public function getUnPaids(string $group, array $where = []): array final public function getUnPaids(string $group, array $where = []): array
{ {
$rows = $this->getModel()->groupBy($group) $rows = $this->getModel()->groupBy($group)
->select("{$group},COUNT(uid) as cnt, SUM(amount) as amount") ->select("{$group},COUNT(uid) as cnt, SUM(amount) as amount")
->where(['billing_at <=' => date('Y-m-d')])
->where(['status' => STATUS['UNPAID']]) ->where(['status' => STATUS['UNPAID']])
->where($where) ->where($where)
->get()->getResult(); ->get()->getResult();

View File

@ -10,7 +10,7 @@
<?php endforeach ?> <?php endforeach ?>
<?php endforeach ?> <?php endforeach ?>
<?php endforeach ?> <?php endforeach ?>
<?php $view_htmls = [!$serverPartCellDatas['serverEntity'] ? "" : $serverPartCellDatas['serverEntity']->getCode()] ?> <?php $view_htmls = [$serverPartCellDatas['service']->getHelper()->getFieldView('Server', $serverPartCellDatas['serverEntity']->getCode(), $serverPartCellDatas)] ?>
<?php foreach ($htmls as $type => $datas): ?> <?php foreach ($htmls as $type => $datas): ?>
<?php $view_htmls[] = $serverPartCellDatas['service']->getHelper()->getListButton($type, '', $serverPartCellDatas) . implode(",", $datas) ?> <?php $view_htmls[] = $serverPartCellDatas['service']->getHelper()->getListButton($type, '', $serverPartCellDatas) . implode(",", $datas) ?>
<?php endforeach ?> <?php endforeach ?>

View File

@ -6,7 +6,7 @@
<?php $serverPartCellDatas['entity'] = $entity ?> <?php $serverPartCellDatas['entity'] = $entity ?>
<?php $htmls[$type][] = [ <?php $htmls[$type][] = [
'view' => $serverPartCellDatas['service']->getHelper()->getFieldView($type, $entity->getPK(), $serverPartCellDatas), 'view' => $serverPartCellDatas['service']->getHelper()->getFieldView($type, $entity->getPK(), $serverPartCellDatas),
'amount' => $entity->getAmount() * $entity->getCnt() 'amount' => $entity->getCaculatedAmount()
] ?> ] ?>
<?php endforeach ?> <?php endforeach ?>
<?php endforeach ?> <?php endforeach ?>