dbmsv4 init...3

This commit is contained in:
최준흠 2025-12-17 16:40:51 +09:00
parent ddb5b4f924
commit ce3a3d0424
10 changed files with 21 additions and 11 deletions

View File

@ -24,10 +24,9 @@ abstract class CommonEntity extends Entity
$field = constant("static::TITLE"); $field = constant("static::TITLE");
return $this->attributes[$field] ?? ""; return $this->attributes[$field] ?? "";
} }
final public function getTitleByFormat(string $format, array $fields): string public function getCustomTitle(): string
{ {
$parameters = array_map(fn($field) => $this->attributes[$field], $fields); return $this->getTitle();
return sprintf($format, ...$parameters);
} }
public function getStatus(): string public function getStatus(): string
{ {

View File

@ -25,6 +25,10 @@ class ServerPartEntity extends EquipmentEntity
return $this->attributes['serviceinfo_uid'] ?? null; return $this->attributes['serviceinfo_uid'] ?? null;
} }
//기본기능용 //기본기능용
public function getCustomTitle(): string
{
return sprintf("%s*%d개[%s]", $this->getTitle(), $this->getCnt(), $this->getExtra());
}
public function getCalculatedAmount(): int public function getCalculatedAmount(): int
{ {
return $this->getAmount() * $this->getCnt(); return $this->getAmount() * $this->getCnt();

View File

@ -27,7 +27,7 @@ abstract class PartEntity extends CommonEntity
//기본기능용 //기본기능용
public function getCustomTitle(mixed $title = null): string public function getCustomTitle(mixed $title = null): string
{ {
return sprintf("%s %s원", $title ? $title : $this->getTitle(), number_format($this->getPrice() . "")); return sprintf("%s %s원", $title ? $title : $this->getTitle(), number_format($this->getPrice()));
} }
final public function getPrice(): int final public function getPrice(): int
{ {

View File

@ -22,6 +22,10 @@ class PaymentEntity extends CommonEntity
return $this->attributes['serviceinfo_uid'] ?? null; return $this->attributes['serviceinfo_uid'] ?? null;
} }
//기본기능 //기본기능
public function getCustomTitle(): string
{
return sprintf("%s %s [%s]", $this->getTitle(), $this->getAmount(), $this->getBillingAt());
}
public function getBilling(): string public function getBilling(): string
{ {
return $this->attributes['billing']; return $this->attributes['billing'];

View File

@ -21,6 +21,7 @@ class ServerPartModel extends EquipmentModel
"title", "title",
"type", "type",
"billing", "billing",
"billing_at",
"amount", "amount",
"cnt", "cnt",
"extra", "extra",

View File

@ -254,7 +254,7 @@ class ServerService extends EquipmentService
if (!$serviceEntity instanceof ServiceEntity) { if (!$serviceEntity instanceof ServiceEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getServiceInfoUID()}에 해당하는 서비스정보을 찾을수 없습니다."); throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getServiceInfoUID()}에 해당하는 서비스정보을 찾을수 없습니다.");
} }
service('customer_serviceservice')->updateAmount($entity); service('customer_serviceservice')->updateAmount($serviceEntity);
} }
return $entity; return $entity;
} }

View File

@ -23,7 +23,7 @@ abstract class PartType1Service extends PartService
$entity = $this->getPartEntityByServerPart($serverPartEntity); $entity = $this->getPartEntityByServerPart($serverPartEntity);
//파트정보의 사용가능한 갯수 , 사용갯수 비교 //파트정보의 사용가능한 갯수 , 사용갯수 비교
if ($entity->getAvailable() < $serverPartEntity->getCnt()) { if ($entity->getAvailable() < $serverPartEntity->getCnt()) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 현재 사용가능 갯수[{$entity->getAvailable()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 현재 {$entity->getTitle()}사용가능 갯수[{$entity->getAvailable()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
} }
$formDatas['used'] = $entity->getUsed() + $serverPartEntity->getCnt(); $formDatas['used'] = $entity->getUsed() + $serverPartEntity->getCnt();
return parent::modify_process($entity, $formDatas); return parent::modify_process($entity, $formDatas);
@ -35,7 +35,7 @@ abstract class PartType1Service extends PartService
$entity = $this->getPartEntityByServerPart($serverPartEntity); $entity = $this->getPartEntityByServerPart($serverPartEntity);
//파트정보의 사용된 갯수 , 회수용 갯수 비교 //파트정보의 사용된 갯수 , 회수용 갯수 비교
if ($entity->getUsed() < $serverPartEntity->getCnt()) { if ($entity->getUsed() < $serverPartEntity->getCnt()) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 현재 사용된 갯수[{$entity->getUsed()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 현재 {$entity->getTitle()}사용된 갯수[{$entity->getUsed()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
} }
$formDatas['used'] = $entity->getUsed() - $serverPartEntity->getCnt(); $formDatas['used'] = $entity->getUsed() - $serverPartEntity->getCnt();
return parent::modify_process($entity, $formDatas); return parent::modify_process($entity, $formDatas);

View File

@ -342,12 +342,13 @@ class PaymentService extends CommonService
} }
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID(); $formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas["clientinfo_uid"] = $serverPartEntity->getClientInfoUID(); $formDatas["clientinfo_uid"] = $serverPartEntity->getClientInfoUID();
$formDatas["serverpartinfo_uid"] = $serverPartEntity->getPK();
$formDatas['amount'] = $serverPartEntity->getAmount(); $formDatas['amount'] = $serverPartEntity->getAmount();
$formDatas['billing'] = $formDatas['billing'] ?? PAYMENT['BILLING']['ONETIME']; $formDatas['billing'] = $formDatas['billing'] ?? PAYMENT['BILLING']['ONETIME'];
$formDatas['billing_at'] = $serverPartEntity->getBillingAt(); $formDatas['billing_at'] = $serverPartEntity->getBillingAt();
$formDatas['pay'] = $formDatas['pay'] ?? PAYMENT['PAY']['ACCOUNT']; $formDatas['pay'] = $formDatas['pay'] ?? PAYMENT['PAY']['ACCOUNT'];
$formDatas['status'] = $formDatas['status'] ?? STATUS['UNPAID']; $formDatas['status'] = $formDatas['status'] ?? STATUS['UNPAID'];
$formDatas['title'] = sprintf("%s 일회성비용", $formDatas['title'] ?? $serverPartEntity->getTitle()); $formDatas['title'] = sprintf("%s 일회성비용", $formDatas['title'] ?? $serverPartEntity->getCustomTitle());
return $formDatas; return $formDatas;
} }
public function createByServerPart(ServerPartEntity $serverPartEntity): PaymentEntity public function createByServerPart(ServerPartEntity $serverPartEntity): PaymentEntity
@ -356,6 +357,7 @@ class PaymentService extends CommonService
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스정보가 정의되지 않아 일회성 상품을 설정하실수 없습니다."); throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스정보가 정의되지 않아 일회성 상품을 설정하실수 없습니다.");
} }
$formDatas = $this->getFormDatasFromServerPart($serverPartEntity); $formDatas = $this->getFormDatasFromServerPart($serverPartEntity);
$this->action_init_process('create', $formDatas);
return parent::create_process($formDatas); return parent::create_process($formDatas);
} }
public function modifyByServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity): PaymentEntity public function modifyByServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity): PaymentEntity
@ -367,7 +369,7 @@ class PaymentService extends CommonService
$entity = $this->getEntity([ $entity = $this->getEntity([
'serverpartinfo_uid' => $oldServerPartEntity->getPK(), 'serverpartinfo_uid' => $oldServerPartEntity->getPK(),
'serviceinfo_uid' => $oldServerPartEntity->getServiceInfoUID(), 'serviceinfo_uid' => $oldServerPartEntity->getServiceInfoUID(),
'billing' => PAYMENT['BILLING']['ONETIME'], 'billing' => $oldServerPartEntity->getBilling(),
'billing_at' => $oldServerPartEntity->getBillingAt(), 'billing_at' => $oldServerPartEntity->getBillingAt(),
'status' => STATUS['UNPAID'] 'status' => STATUS['UNPAID']
]); ]);

View File

@ -8,7 +8,7 @@
<?php foreach ($partCellDatas['entities'] as $entity): ?> <?php foreach ($partCellDatas['entities'] as $entity): ?>
<?php $partCellDatas['entity'] = $entity; ?> <?php $partCellDatas['entity'] = $entity; ?>
<tr> <tr>
<td class="text-end text-nowrap"><?= $partCellDatas['helper']->getListButton('modify', $entity->getTitle(), $partCellDatas) ?><< /td> <td class="text-end text-nowrap"><?= $partCellDatas['helper']->getListButton('modify', $entity->getTitle(), $partCellDatas) ?></td>
<td class="text-center text-nowrap"><?= $entity->getUsed() ?></td> <td class="text-center text-nowrap"><?= $entity->getUsed() ?></td>
<td class="text-center text-nowrap"><?= $entity->getAvailable() ?></td> <td class="text-center text-nowrap"><?= $entity->getAvailable() ?></td>
<td class="text-center text-nowrap"><?= $entity->getStock() ?></td> <td class="text-center text-nowrap"><?= $entity->getStock() ?></td>

View File

@ -18,7 +18,7 @@
<th class="text-end m-0 p-0" width="15%"><?= $serverPartCellDatas['helper']->getListButton($type, '', $serverPartCellDatas) ?></th> <th class="text-end m-0 p-0" width="15%"><?= $serverPartCellDatas['helper']->getListButton($type, '', $serverPartCellDatas) ?></th>
<td class="text-start m-0 p-0"> <td class="text-start m-0 p-0">
<?php foreach ($htmls[$type] as $html): ?> <?php foreach ($htmls[$type] as $html): ?>
<?= $html['view'] ?>[<?= number_format($html['amount']) ?>원]<a href="/admin/equipment/serverpart/delete/<?= $html['entity']->getPK() ?>">❌</a><BR> <?= $html['view'] ?>[<?= number_format($html['amount']) ?>원]<?= $html['entity']->getBilling() == PAYMENT['BILLING']['BASE'] ? "" : "<a href=\"/admin/equipment/serverpart/delete/{$html['entity']->getPK()}\">❌</a>" ?><BR>
<?php endforeach ?> <?php endforeach ?>
</td> </td>
</tr> </tr>