dbmsv2_init...1

This commit is contained in:
choi.jh 2025-09-24 14:02:59 +09:00
parent 174297e404
commit 2dc1419880
19 changed files with 150 additions and 133 deletions

View File

@ -369,9 +369,11 @@ define('LAYOUTS', [
],
]);
//List의 Page당 갯수
define('DEFAULT_LIST_PERPAGE', $_ENV['LIST_PERPAGE'] ?? $_SERVER['LIST_PERPAGE'] ?? 20);
define("SITES", [
"prime" => "PRIME",
"itsolution" => "ITSOLUTION",
"gdidc" => "GDIDC",
]);
//STATUS
define("STATUS", [
'AVAILABLE' => "available",
@ -390,6 +392,9 @@ define("STATUS_ICONS", [
'AVAILABLE' => "",
'NOT_AVAILABLE' => "x."
]);
//List의 Page당 갯수
define('DEFAULT_LIST_PERPAGE', $_ENV['LIST_PERPAGE'] ?? $_SERVER['LIST_PERPAGE'] ?? 20);
//서버 관련
define("SERVER", []);
//서비스 관련

View File

@ -100,7 +100,7 @@ class ClientController extends CustomerController
if (!$entity instanceof ClientEntity) {
throw new \Exception("{$uid}에 해당하는 고객정보를 찾을수 없습니다.");
}
$this->totalCounts = $this->getService()->getServiceService()->getTotalCountsByType(['clientinfo_uid' => $entity->getPK()]);
$this->totalCounts = $this->getService()->getServiceService()->getTotalCountsBySite(['clientinfo_uid' => $entity->getPK()]);
$this->totalAmounts = $this->getService()->getServiceService()->getTotalAmounts([
'clientinfo_uid' => $entity->getPK(),
'status' => STATUS['AVAILABLE']

View File

@ -69,7 +69,7 @@ class Home extends AdminController
$this->getService()->setFormRules();
$this->getService()->setFormOptions();
//Total 서버 현황
$this->totalCounts = $this->getService()->getTotalCountsByType();
$this->totalCounts = $this->getService()->getTotalCountsBySite();
//interval을 기준으로 최근 신규 서비스정보 가져오기
$this->interval = intval($this->request->getVar('interval') ?? SERVICE['NEW_INTERVAL']);
$this->newServiceEntities = $this->getService()->getEntitiesByNewService($this->interval);

View File

@ -602,4 +602,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2025-09-24 11:00:23
-- Dump completed on 2025-09-24 11:30:07

View File

@ -80,6 +80,9 @@ class ServiceHelper extends CustomerHelper
$value = "<a href=\"/admin/customer/client/detail/{$value}\">" . $viewDatas['control']['field_optons'][$field][$value]->getTitle() . "</a>";
}
break;
case 'amount':
$value = number_format($value) . "";
break;
case 'billing_at':
if (array_key_exists('unPaids', $viewDatas)) {
if (array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids'])) {

View File

@ -35,17 +35,19 @@ class PaymentHelper extends CommonHelper
$action = "";
break;
case 'modify':
$oldBatchJobUids = old("batchjob_uids", null);
$oldBatchJobUids = is_array($oldBatchJobUids) ? $oldBatchJobUids : [$oldBatchJobUids];
$action = form_checkbox([
"id" => "checkbox_uid_{$viewDatas['entity']->getPK()}",
"name" => "batchjob_uids[]",
"value" => $viewDatas['entity']->getPK(),
"class" => "batchjobuids_checkboxs",
"checked" => in_array($viewDatas['entity']->getPK(), $oldBatchJobUids)
]);
if ($this->getMyAuth()->isAccessRole(['security'])) {
$action = parent::getListButton($action, $label, $viewDatas, $extras);
} else {
$oldBatchJobUids = old("batchjob_uids", null);
$oldBatchJobUids = is_array($oldBatchJobUids) ? $oldBatchJobUids : [$oldBatchJobUids];
$action = form_checkbox([
"id" => "checkbox_uid_{$viewDatas['entity']->getPK()}",
"name" => "batchjob_uids[]",
"value" => $viewDatas['entity']->getPK(),
"class" => "batchjobuids_checkboxs",
"checked" => in_array($viewDatas['entity']->getPK(), $oldBatchJobUids)
]);
$action .= $label;
}
break;
case 'delete':

View File

@ -17,11 +17,7 @@ return [
'created_at' => "등록일",
'deleted_at' => "삭제일",
],
"SITE" => [
"prime" => "PRIME",
"itsolution" => "ITSOLUTION",
"gdidc" => "GDIDC",
],
"SITE" => SITES,
"ROLE" => [
"user" => "일반회원",
"vip" => "VIP회원",

View File

@ -21,11 +21,7 @@ return [
'created_at' => "신청일",
'deleted_at' => "삭제일",
],
"SITE" => [
"prime" => "PRIME",
"itsolution" => "ITSOLUTION",
"gdidc" => "GDIDC",
],
"SITE" => SITES,
"LOCATION" => [
"chiba" => "치바",
"tokyo" => "도쿄",

View File

@ -35,6 +35,7 @@ return [
"STATUS" => [
STATUS['AVAILABLE'] => "사용가능",
STATUS['OCCUPIED'] => "서비스중",
STATUS['TERMINATED'] => "서비스해지",
STATUS['FORBIDDEN'] => "사용불가",
],
];

View File

@ -46,7 +46,8 @@ class ServerService extends ParentService implements ServiceInterface
$formDatas = [];
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE'];
$formDatas['format_at'] = date("Y-m-d");
$formDatas['status'] = STATUS['TERMINATED'];
$entity = $this->action_process($serviceEntity, $formDatas);
//서비스정보 Entity에 서버정보 설정
return $serviceEntity->setServerEntity($entity);

View File

@ -59,8 +59,8 @@ class ServiceService extends CustomerService
'type',
'clientinfo_uid',
'serverinfo_uid',
'billing_at',
'amount',
'billing_at',
'status',
'start_at',
'updated_at',
@ -144,36 +144,51 @@ class ServiceService extends CustomerService
return $this->getEntities(sprintf("start_at >= NOW()-INTERVAL {$interval} DAY AND status = '%s'", $status));
}
//서비스 방식에 따른 서비스별 Count
final public function getTotalCountsByType(array $where = []): array
final public function getTotalCountsBySite(array $where = []): array
{
$totalCounts = [
'chiba_total' => 0,
'tokyo_total' => 0,
'all_total' => 0,
'normal' => ['chiba' => 0, 'tokyo' => 0, 'total' => 0],
'defence' => ['chiba' => 0, 'tokyo' => 0, 'total' => 0],
'dedicated' => ['chiba' => 0, 'tokyo' => 0, 'total' => 0],
'vpn' => ['chiba' => 0, 'tokyo' => 0, 'total' => 0],
'event' => ['chiba' => 0, 'tokyo' => 0, 'total' => 0],
'test' => ['chiba' => 0, 'tokyo' => 0, 'total' => 0],
'alternative' => ['chiba' => 0, 'tokyo' => 0, 'total' => 0],
];
$rows = $this->getModel()->groupBy('type')->select("type,
$rows = $this->getModel()->groupBy(['site', 'type'])->select("site,type,
COUNT(CASE WHEN location = 'chiba' THEN 1 END) AS chiba,
COUNT(CASE WHEN location = 'tokyo' THEN 1 END) AS tokyo,
COUNT(CASE WHEN location IN ('chiba', 'tokyo') THEN 1 END) AS total")
COUNT(CASE WHEN location IN ('chiba', 'tokyo') THEN 1 END) AS summary")
->where($where)
->get()->getResult();
// dd($rows);
$totalCounts = [
'normal' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'defence' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'dedicated' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'vpn' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'event' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'test' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'alternative' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0]
];
foreach ($rows as $row) {
$totalCounts[$row->type] = [
'chiba' => $row->chiba,
'tokyo' => $row->tokyo,
'total' => $row->total,
];
$totalCounts['chiba_total'] += $row->chiba;
$totalCounts['tokyo_total'] += $row->tokyo;
// echo "site:{$row->site},type:{$row->type}";
if (!array_key_exists($row->site, $totalCounts)) {
$totalCounts[$row->site] = [
'chiba_summary' => 0,
'tokyo_summary' => 0,
'all_summary' => 0,
'normal' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'defence' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'dedicated' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'vpn' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'event' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'test' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
'alternative' => ['chiba' => 0, 'tokyo' => 0, 'summary' => 0],
];
}
if (!array_key_exists($row->type, $totalCounts[$row->site])) {
$totalCounts[$row->site][$row->type] = [];
}
$totalCounts[$row->type]['chiba'] += $totalCounts[$row->site][$row->type]['chiba'] = $row->chiba;
$totalCounts[$row->type]['tokyo'] += $totalCounts[$row->site][$row->type]['tokyo'] = $row->tokyo;
$totalCounts[$row->type]['summary'] += $totalCounts[$row->site][$row->type]['summary'] = $row->summary;
$totalCounts[$row->site]['chiba_summary'] += $row->chiba;
$totalCounts[$row->site]['tokyo_summary'] += $row->tokyo;
$totalCounts[$row->site]['all_summary'] = $totalCounts[$row->site]['chiba_summary'] + $totalCounts[$row->site]['tokyo_summary'];
}
$totalCounts['all_total'] = $totalCounts['chiba_total'] + $totalCounts['tokyo_total'];
// dd($totalCounts);
return $totalCounts;
}
//서비스별 총 금액
@ -204,14 +219,14 @@ class ServiceService extends CustomerService
if (!$entity instanceof ServiceEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생:[{$uid}]에 대한 서비스정보를 찾을수 없습니다.");
}
$total_amount = $entity->getRack() + $entity->getLine() + $entity->getServerEntity()->getPrice(); //기본:상면비+회선비+서버금액(price)+서버파트연결(월비용)
$summary_amount = $entity->getRack() + $entity->getLine() + $entity->getServerEntity()->getPrice(); //기본:상면비+회선비+서버금액(price)+서버파트연결(월비용)
//해당 서비스(서버) 관련 결제방식(Billing)이 Month인 ServerPart 전체를 다시 검사하여 월청구액을 합산한다.
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getServerEntity()->getPK()]) as $serverPartEntity) {
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) { //월비용일때만 적용
$total_amount += $serverPartEntity->getCaculatedAmount(); //단가*Cnt
$summary_amount += $serverPartEntity->getCaculatedAmount(); //단가*Cnt
}
}
return $total_amount;
return $summary_amount;
}
//기본 기능부분
//FieldForm관련용

View File

@ -21,7 +21,8 @@ class ServerPartService extends ParentService implements ServerInterface
//create와 같은 작업임
public function modifyServer(ServerEntity $serverEntity): ServerEntity
{
return $this->createServer($serverEntity);
//아무것도 하지 않음
return $serverEntity;
}
public function deleteServer(ServerEntity $serverEntity): ServerEntity
{

View File

@ -7,7 +7,7 @@ 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()
@ -29,17 +29,16 @@ class ServiceService extends ParentService implements ServerInterface
//아무것도 하지 않음
return $serverEntity;
}
//create와 같은 작업임
public function modifyServer(ServerEntity $serverEntity): ServerEntity
{
return $this->createServer($serverEntity);
$this->action_process($serverEntity);
return $serverEntity;
}
//create와 같은 작업임
public function deleteServer(ServerEntity $serverEntity): ServerEntity
{
if ($serverEntity->getServiceInfoUID() !== null || $serverEntity->getStatus() === STATUS['OCCUPIED']) {
throw new \Exception("서비스중이 서버는 삭제하실수 없습니다.");
}
return $this->createServer($serverEntity);
return $serverEntity;
}
}

View File

@ -7,7 +7,7 @@ use App\Entities\PaymentEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\PaymentService as ParentService;
//이 클래스는 일회성일때만 실행된다.
////서버연결정보 추가나 변경,삭제시 일회성일 경우 실행됨
class PaymentService extends ParentService implements ServerPartInterface
{
public function __construct()
@ -51,6 +51,10 @@ class PaymentService extends ParentService implements ServerPartInterface
if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 서버파트연결정보{$serverPartEntity->getPK()}]에 해당하는 결제정보를 찾을수 없습니다.");
}
//미납상태확인
if ($entity->getStatus() !== STATUS['UNPAID']) {
throw new \Exception(__METHOD__ . "에서 오류발생: 완료된 결제는 수정이 불가합니다.");
}
//필수정보처리 후 FormData 가져오기
$formDatas = $this->action_process($serverPartEntity);
//결제정보수정

View File

@ -7,7 +7,7 @@ use App\Entities\Equipment\ServerPartEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\Customer\ServiceService as ParentService;
//서버연결정보 추가나 변경,삭제시 가격이 변한경우 서비스의 가격을 변경하기 위함.
class ServiceService extends ParentService implements ServerPartInterface
{
public function __construct()

View File

@ -299,8 +299,8 @@ class ServerPartService extends EquipmentService
//삭제
public function delete(mixed $entity): ServerPartEntity
{
//선처리작업
$entity = $this->action_process($entity, __FUNCTION__ . 'ServerPart');
return parent::delete($entity);
$entity = parent::delete($entity);
//서비스금액 관련때문에 후처리작업
return $this->action_process($entity, __FUNCTION__ . 'ServerPart');
}
}

View File

@ -26,7 +26,6 @@ class ServerService extends EquipmentService
"title",
"price",
"manufactur_at",
"format_at",
];
}
public function getFormFilters(): array
@ -129,7 +128,6 @@ class ServerService extends EquipmentService
//수정
public function modify(mixed $entity, array $formDatas): ServerEntity
{
$entity->getServerService()->deleteService($entity);
//서버정보 수정
$entity = parent::modify($entity, $formDatas);
//후처리작업

View File

@ -50,10 +50,10 @@
서버정보<div class="float-end rounded border border-primary" style="cursor:pointer;" onclick="copyServerPartsToClipboard()">All COPY</div>
</th>
<th class="index_head_short_column">
<?= $viewDatas['service']->getHelper()->getListLabel('billing_at', lang("{$viewDatas['class_path']}.label.billing_at"), $viewDatas) ?>
<?= $viewDatas['service']->getHelper()->getListLabel('amount', lang("{$viewDatas['class_path']}.label.amount"), $viewDatas) ?>
</th>
<th class="index_head_short_column">
<?= $viewDatas['service']->getHelper()->getListLabel('amount', lang("{$viewDatas['class_path']}.label.amount"), $viewDatas) ?>
<?= $viewDatas['service']->getHelper()->getListLabel('billing_at', lang("{$viewDatas['class_path']}.label.billing_at"), $viewDatas) ?>
</th>
<th class="index_head_short_column">
<?= $viewDatas['service']->getHelper()->getListLabel('status', lang("{$viewDatas['class_path']}.label.status"), $viewDatas) ?>
@ -90,10 +90,10 @@
]) ?>
</td>
<td nowrap>
<?= $viewDatas['service']->getHelper()->getFieldView('billing_at', $entity->billing_at, $viewDatas) ?>
<?= $viewDatas['service']->getHelper()->getFieldView('amount', $entity->amount, $viewDatas) ?>
</td>
<td nowrap>
<?= $viewDatas['service']->getHelper()->getFieldView('amount', $entity->amount, $viewDatas) ?>
<?= $viewDatas['service']->getHelper()->getFieldView('billing_at', $entity->billing_at, $viewDatas) ?>
</td>
<td nowrap>
<?= $viewDatas['service']->getHelper()->getFieldView('status', $entity->status, $viewDatas) ?>

View File

@ -9,71 +9,67 @@
</div>
<div style="border-left: 1px solid black; border-right: 1px solid black; padding:20px;">
<table class="table table-bordered table-hover align-middle">
<thead>
<tr class="text-center">
<th rowspan="2">고객명</th>
<th colspan="2">일반</th>
<th colspan="2">방어</th>
<th colspan="2">전용</th>
<th colspan="2">대체</th>
<th colspan="3">테스트</th>
<th colspan="3">합계</th>
</tr>
<tr class="text-center">
<th>도쿄</th>
<th>치바</th>
<th>도쿄</th>
<th>치바</th>
<th>도쿄</th>
<th>치바</th>
<th>도쿄</th>
<th>치바</th>
<th>도쿄</th>
<th>치바</th>
<th>합계</th>
<th>도쿄</th>
<th>치바</th>
<th>합계</th>
</tr>
<?php foreach (SITES as $key => $label): ?>
<tr class="text-center">
<th rowspan="2">고객명</th>
<th colspan="2">일반</th>
<th colspan="2">방어</th>
<th colspan="2">전용</th>
<th colspan="2">대체</th>
<th colspan="3">테스트</th>
<th colspan="3">합계</th>
<td><?= $label ?></td>
<td><?= $viewDatas['totalCounts'][$key]['normal']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['normal']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['defence']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['defence']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['dedicated']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['dedicated']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['alternative']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['alternative']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['test']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['test']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['test']['summary'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['tokyo_summary'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['chiba_summary'] ?></td>
<td><?= $viewDatas['totalCounts'][$key]['all_summary'] ?></td>
</tr>
<tr class="text-center">
<th>도쿄</th>
<th>치바</th>
<th>도쿄</th>
<th>치바</th>
<th>도쿄</th>
<th>치바</th>
<th>도쿄</th>
<th>치바</th>
<th>도쿄</th>
<th>치바</th>
<th>합계</th>
<th>도쿄</th>
<th>치바</th>
<th>합계</th>
</tr>
</thead>
<tbody>
<tr class="text-center">
<td>PRIME</td>
<td><?= $viewDatas['totalCounts']['normal']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts']['normal']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts']['defence']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts']['defence']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts']['dedicated']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts']['dedicated']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts']['alternative']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts']['alternative']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts']['test']['tokyo'] ?></td>
<td><?= $viewDatas['totalCounts']['test']['chiba'] ?></td>
<td><?= $viewDatas['totalCounts']['test']['total'] ?></td>
<td><?= $viewDatas['totalCounts']['tokyo_total'] ?></td>
<td><?= $viewDatas['totalCounts']['chiba_total'] ?></td>
<td><?= $viewDatas['totalCounts']['all_total'] ?></td>
</tr>
</tbody>
<tfoot class="table-light fw-bold">
<tr class="text-center">
<td>총합계</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</tfoot>
<?php endforeach ?>
<tr class="text-center">
<td>총합계</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
</div>
<div class="layout_footer"></div>