dbmsv2 init...1

This commit is contained in:
choi.jh 2025-09-10 20:23:18 +09:00
parent 740a8ce897
commit 7fb1a2b1d7
9 changed files with 154 additions and 88 deletions

19
app/Cells/CommonCell.php Normal file
View File

@ -0,0 +1,19 @@
<?php
namespace App\Cells;
use App\Services\CommonService;
abstract class CommonCell
{
protected $_service = null;
protected function __construct(CommonService $service)
{
$this->_service = $service;
}
final public function getService(): mixed
{
return $this->_service;
}
}

View File

@ -0,0 +1,15 @@
<?php
namespace App\Cells\Customer;
use App\Cells\CommonCell;
use App\Services\CommonService;
abstract class CustomerCell extends CommonCell
{
protected function __construct(CommonService $service)
{
parent::__construct($service);
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Cells\Customer;
use App\Services\Customer\PaymentService;
use App\Services\Customer\ServiceService;
class ServiceCell extends CustomerCell
{
public function __construct()
{
parent::__construct(new ServiceService());
}
public function detail(array $params): string
{
$this->getService()->setAction(__FUNCTION__);
$this->getService()->setFormFields();
$this->getService()->setFormFilters();
$this->getService()->setFormRules();
$this->getService()->setFormOptions();
$entities = $this->getService()->getEntities(['clientinfo_uid' => $params['userinfo_uid']]);
return view('cells/service/detail', [
'cellDatas' => [
'control' => $this->getService()->getControlDatas(),
'service' => $this->getService(),
'entities' => $entities,
'paymentService' => new PaymentService()
]
]);
}
}

View File

@ -118,8 +118,6 @@ class ClientController extends CustomerController
$this->serviceEntities = $this->getService()->getServiceService()->getEntities(['clientinfo_uid' => $entity->getPK()]);
$this->entity = $entity;
helper(['form']);
$this->serviceService = new ServiceService();
$this->serverServicer = new ServerService();
return $this->getResultSuccess();
} catch (\Exception $e) {
return $e->getMessage();

View File

@ -62,4 +62,8 @@ class ServiceEntity extends CustomerEntity
{
return $this->attributes['amount'] ?? 0;
}
public function getHistory(): string
{
return $this->attributes['history'] ?? "";
}
}

View File

@ -100,17 +100,11 @@ class PaymentService extends CustomerService
public function getUnPaids(string $group, array $where = []): array
{
$rows = $this->getModel()->groupBy($group)
->select("{$group}, COUNT(uid) as cnt, SUM(amount) as amount")
->select("COUNT(uid) as cnt, SUM(amount) as amount")
->where(['billing_at <=' => date('Y-m-d')])
->where(['status' => STATUS['UNPAID']])
->where($where)
->get()->getResult();
$unpaids = [];
foreach ($rows as $row) {
$unpaids[$row->$group] = [];;
$unpaids[$row->$group]['count'] = $row->cnt;
$unpaids[$row->$group]['amount'] = $row->amount;
}
return $unpaids;
return $rows;
}
}

View File

@ -199,6 +199,8 @@ class ServiceService extends CustomerService
) WHERE billing_at = ? AND status = ?";
return $this->getModel()->query($sql, [$billing_at, $status]);
}
//기본기능
//서버정보 상태설정용
private function setServer_process(ServiceEntity $entity, mixed $serverinfo_uid, string $status): ServiceEntity
{

View File

@ -55,7 +55,6 @@
<td><?= $viewDatas['entity']->getAccountBalance() ?></td>
<td><?= array_key_exists($viewDatas['entity']->getPK(), $viewDatas['totalAmounts']) ? number_format($viewDatas['totalAmounts'][$viewDatas['entity']->getPK()]) : 0 ?></td>
<td><?= array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids']) ? number_format($viewDatas['unPaids'][$viewDatas['entity']->getPK()]['amount']) : 0 ?></td>
</td>
</tr>
</table>
</div>
@ -70,64 +69,7 @@
<button class="btn btn-primary">저장</button>
</div>
</div>
<?php foreach ($viewDatas['serviceEntities'] as $serviceEntity): ?>
<div class="row align-items-end rounded border border-gray p-2 mt-3">
<table class="table table-bordered table-hover table-striped">
<tr class="text-center">
<th><a href="#">[상세정보]</a></th>
<th>사이트</th>
<th>위치</th>
<th>형식</th>
<th>CPU</th>
<th>메모리</th>
<th>저장장치</th>
<th>OS</th>
<th>SOFTWARE</th>
<th>IP주소</th>
<th>CS</th>
<th>결제처리</th>
</tr>
<tr class="text-center">
<td rowspan="4">
<div><?= $serviceEntity->getCode() ?></div>
<div><?= $serviceEntity->getServerEntity()->getCode() ?></div>
</td>
<td><?= $viewDatas['serviceService']->getHelper()->getFieldView('site', $serviceEntity->getSite(), $viewDatas) ?></td>
<td><?= $viewDatas['serviceService']->getHelper()->getFieldView('location', $serviceEntity->getLocation(), $viewDatas) ?></td>
<td><?= $viewDatas['serviceService']->getHelper()->getFieldView('type', $serviceEntity->getType(), $viewDatas) ?></td>
<td>CPU</td>
<td>메모리</td>
<td>저장장치</td>
<td>OS</td>
<th>SOFTWARE</th>
<th>IP주소</th>
<th>CS</th>
<td rowspan="4">
<table class="table">
<tr class="text-center">
<th class="text-start fw-bold">결제일</th>
<td>2025-09-11</td>
</tr>
<tr>
<th class="text-start fw-bold">결제금</th>
<td class="amount-green">500,000</td>
</tr>
<tr>
<th class="text-start fw-bold">미납금</th>
<td class="amount-red">500,000</td>
</tr>
</table>
</td>
</tr>
<tr>
<th colspan="10">서비스 비고</th>
</tr>
<tr>
<td colspan="10">서비스 비고</td>
</tr>
</table>
</div>
<?php endforeach; ?>
<?= view_cell("\App\Cells\Customer\ServiceCell::detail", ['userinfo_uid' => $viewDatas['entity']->getPK()]) ?>
</div>
<!-- index_body -->
</div>

View File

@ -0,0 +1,60 @@
<?php foreach ($cellDatas['entities'] as $entity): ?>
<?php $cellDatas['entity'] = $entity ?>
<?php $unpaids = $cellDatas['paymentService']->getUnPaids('serviceinfo_uid', ['serviceinfo_uid' => $entity->getPK()]) ?>
<div class="row align-items-end rounded border border-gray p-2 mt-3">
<table class="table table-bordered table-hover table-striped">
<tr class="text-center">
<th><a href="#">[상세정보]</a></th>
<th>사이트</th>
<th>위치</th>
<th>형식</th>
<th>CPU</th>
<th>메모리</th>
<th>저장장치</th>
<th>OS</th>
<th>SOFTWARE</th>
<th>IP주소</th>
<th>CS</th>
<th>결제처리</th>
</tr>
<tr class="text-center">
<td rowspan="4">
<div><?= $entity->getCode() ?></div>
<div><?= $entity->getServerEntity()->getCode() ?></div>
</td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('site', $entity->getSite(), $cellDatas) ?></td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('location', $entity->getLocation(), $cellDatas) ?></td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('type', $entity->getType(), $cellDatas) ?></td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('CPU', "", $cellDatas) ?></td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('RAM', "", $cellDatas) ?></td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('DISK', "", $cellDatas) ?></td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('OS', "", $cellDatas) ?></td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('SOFTWARE', "", $cellDatas) ?></td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('IP', "", $cellDatas) ?></td>
<td><?= $cellDatas['service']->getHelper()->getFieldView('CS', "", $cellDatas) ?></td>
<td rowspan="4">
<table class="table">
<tr class="text-center">
<th class="text-start fw-bold">결제일</th>
<td><?= $entity->getBillingAT() ?></td>
</tr>
<tr>
<th class="text-start fw-bold">결제금</th>
<td class="amount-green"><?= number_format(intval($entity->getBillingAT())) ?>원</td>
</tr>
<tr>
<th class="text-start fw-bold">미납금</th>
<td class="amount-red"><?= array_key_exists('amount', $unpaids) ? number_format($unpaids['amount']) : 0 ?>원</td>
</tr>
</table>
</td>
</tr>
<tr>
<th colspan="10">서비스 비고</th>
</tr>
<tr>
<td colspan="10"><?= nl2br($entity->getHistory()) ?></td>
</tr>
</table>
</div>
<?php endforeach; ?>