dbmsv2 init...1

This commit is contained in:
choi.jh 2025-09-18 17:17:11 +09:00
parent 97762c858b
commit 9bd48d3f00
29 changed files with 427 additions and 279 deletions

View File

@ -2,7 +2,7 @@
namespace App\Cells\Customer;
use App\Services\Customer\PaymentService;
use App\Services\PaymentService;
use App\Services\Customer\ServiceService;
class ServiceCell extends CustomerCell

View File

@ -240,6 +240,7 @@ define('ICONS', [
'SERVER_ITEM_SOFTWARE' => '<i class="bi bi-window-sidebar"></i>',
'SERVER_ITEM_IP' => '<i class="bi bi-globe2"></i>',
'SERVER_ITEM_CS' => '<i class="bi bi-shield-check"></i>',
'SERVER_ITEM_ETC' => '<i class="bi bi-patch-question"></i>',
]);
//메신저 아이콘
define('MESSENGER_ICONS', [
@ -398,9 +399,9 @@ define("SERVICE", [
//서버파트 관련
define("SERVERPART", [
"CNT_RANGE" => array_combine(range(1, 10), range(1, 10)),
"SERVER_PARTTYPES" => ['CPU', 'RAM', 'DISK'],
"SERVICE_PARTTYPES" => ['SWITCH', 'IP', 'OS', 'SOFTWARE', 'CS'],
"ALL_PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS', 'DB', 'SOFTWARE', 'SWITCH', 'IP', 'CS'],
"SERVER_PARTTYPES" => ['CPU', 'RAM', 'DISK', 'ETC'],
"SERVICE_PARTTYPES" => ['SWITCH', 'IP', 'OS', 'SOFTWARE', 'CS', 'ETC'],
"ALL_PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS', 'DB', 'SOFTWARE', 'SWITCH', 'IP', 'CS', 'ETC'],
]);
//결제 관련
define("PAYMENT", [

View File

@ -3,12 +3,12 @@
namespace App\Controllers\Admin\Customer;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\PaymentEntity;
use App\Entities\PaymentEntity;
use App\Entities\Customer\ServiceEntity;
use App\Libraries\LogCollector;
use App\Services\Customer\ClientService;
use App\Services\Customer\PaymentService;
use App\Services\PaymentService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;

View File

@ -3,7 +3,7 @@
namespace App\Controllers\Admin\Customer;
use App\Entities\Customer\ServiceEntity;
use App\Services\Customer\PaymentService;
use App\Services\PaymentService;
use App\Services\Customer\ServiceService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;

View File

@ -2,9 +2,8 @@
namespace App\Controllers\Admin;
use App\Helpers\HomeHelper;
use App\Services\Customer\ServiceService;
use App\Services\Customer\PaymentService;
use App\Services\PaymentService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;

View File

@ -3,7 +3,7 @@
namespace App\Controllers\CLI;
use App\Controllers\BaseController;
use App\Entities\Customer\PaymentEntity;
use App\Entities\PaymentEntity;
use App\Entities\Customer\ServiceEntity;
use App\Services\Customer\ServiceService;
use CodeIgniter\HTTP\RequestInterface;

View File

@ -4,8 +4,8 @@
"settings": {
"width": 3000,
"height": 3000,
"scrollTop": -1655.4768,
"scrollLeft": -167,
"scrollTop": -660.4768,
"scrollLeft": -1800,
"zoomLevel": 0.76,
"show": 511,
"database": 4,
@ -604,6 +604,7 @@
"s1Az-lXWK0NlVQqFEEK8o",
"8mPFhDdUY8QLPvc8rNw1B",
"vxhl-9RMNJ8zU9oqzEWo8",
"d4HxTQuDbI7SN2qBS84s2",
"vbPIGWHquXROtCfId6RVF",
"FhnUrn_dOrdhaBe_P3ty-",
"SA3xJ9nRW8EWDCFoMjnj3",
@ -631,6 +632,7 @@
"8mPFhDdUY8QLPvc8rNw1B",
"LRN5qjIRZ18UOhqFbBLuo",
"vxhl-9RMNJ8zU9oqzEWo8",
"d4HxTQuDbI7SN2qBS84s2",
"vbPIGWHquXROtCfId6RVF",
"FhnUrn_dOrdhaBe_P3ty-",
"SA3xJ9nRW8EWDCFoMjnj3",
@ -651,7 +653,7 @@
"color": ""
},
"meta": {
"updateAt": 1756951965260,
"updateAt": 1758175481304,
"createAt": 1748484896313
}
},
@ -8386,6 +8388,26 @@
"updateAt": 1758087660022,
"createAt": 1758087641569
}
},
"d4HxTQuDbI7SN2qBS84s2": {
"id": "d4HxTQuDbI7SN2qBS84s2",
"tableId": "QCNA57Pi6A9dJDgybxS5v",
"name": "serverpartinfo_uid",
"comment": "서버파트연결정보",
"dataType": "INT",
"default": "",
"options": 0,
"ui": {
"keys": 0,
"widthName": 97,
"widthComment": 98,
"widthDataType": 60,
"widthDefault": 60
},
"meta": {
"updateAt": 1758175486130,
"createAt": 1758175348505
}
}
},
"relationshipEntities": {
@ -8465,7 +8487,7 @@
"s1Az-lXWK0NlVQqFEEK8o"
],
"x": 2338.5336,
"y": 618.633,
"y": 624.633,
"direction": 1
},
"meta": {
@ -8717,7 +8739,7 @@
"8mPFhDdUY8QLPvc8rNw1B"
],
"x": 2338.5336,
"y": 802.633,
"y": 820.633,
"direction": 1
},
"meta": {
@ -8772,8 +8794,8 @@
"columnIds": [
"vxhl-9RMNJ8zU9oqzEWo8"
],
"x": 2649.0336,
"y": 894.633,
"x": 2657.5336,
"y": 918.633,
"direction": 8
},
"meta": {

File diff suppressed because one or more lines are too long

View File

@ -24,7 +24,7 @@ class ServerPartEntity extends EquipmentEntity
//기본기능용
public function getPartUID(): int
{
return $this->attributes['part_uid'] ?? 0;
return intval($this->attributes['part_uid']) ?? 0;
}
public function getType(): string
{

View File

@ -1,15 +1,27 @@
<?php
namespace App\Entities\Customer;
namespace App\Entities;
use App\Models\Customer\PaymentModel;
use App\Models\PaymentModel;
use DateTime;
class PaymentEntity extends CustomerEntity
class PaymentEntity extends CommonEntity
{
const PK = PaymentModel::PK;
const TITLE = PaymentModel::TITLE;
const DEFAULT_STATUS = STATUS['UNPAID'];
final public function getUserUID(): int|null
{
return $this->attributes['user_uid'];
}
final public function getClientInfoUID(): int|null
{
return $this->attributes['clientinfo_uid'] ?? null;
}
final public function getServiceInfoUID(): int|null
{
return $this->attributes['serviceinfo_uid'] ?? null;
}
public function getBilling(): string
{
return $this->attributes['billing'] ?? "";

View File

@ -31,7 +31,7 @@ class ServiceHelper extends CustomerHelper
}
}
foreach ($attributes as $attribute_name => $attribute_value) {
$attribute = sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value());
$attribute .= sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value());
}
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? STATUS_ICONS['NOT_AVAILABLE'] : STATUS_ICONS['AVAILABLE'];
$label .= $option_value->getCustomTitle();

View File

@ -32,7 +32,7 @@ class ServerPartHelper extends EquipmentHelper
// }
// }
foreach ($attributes as $attribute_name => $attribute_value) {
$attribute = sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value());
$attribute .= sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value());
}
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? STATUS_ICONS['NOT_AVAILABLE'] : STATUS_ICONS['AVAILABLE'];
$label .= $option_value->getCustomTitle();
@ -53,8 +53,8 @@ class ServerPartHelper extends EquipmentHelper
switch ($field) {
case 'part_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')";
$attributes = ['data-price' => 'getPrice'];
$extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price'); document.querySelector('input[name=\'title\']').value = this.options[this.selectedIndex].getAttribute('data-title')";
$attributes = ['data-title' => 'getTitle', 'data-price' => 'getPrice'];
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
break;
case 'extra':
@ -83,8 +83,9 @@ class ServerPartHelper extends EquipmentHelper
case 'SWITCH':
case 'IP':
case 'CS':
case 'ETC':
//파트 Entity
$title = $viewDatas['entity']->getPartEntity()->getTitle();
$title = $field === 'ETC' ? $viewDatas['entity']->getTitle() : $viewDatas['entity']->getPartEntity()->getTitle();
$title .= $viewDatas['entity']->getCnt() > 1 ? "*" . $viewDatas['entity']->getCnt() . "" : "";
$title .= $viewDatas['entity']->getExtra() !== "" ? "[" . $viewDatas['entity']->getExtra() . "]" : "";
if (array_key_exists('return', $extras) && $extras['return'] == 'onlyText') {
@ -125,6 +126,7 @@ class ServerPartHelper extends EquipmentHelper
case 'OS':
case 'DB':
case 'SOFTWARE':
case 'ETC':
$extras = [
"class" => "btn btn-sm btn-outline btn-circle",
"target" => "_self",

View File

@ -1,10 +1,10 @@
<?php
namespace App\Helpers\Customer;
namespace App\Helpers;
use App\Models\Customer\PaymentModel;
use App\Models\PaymentModel;
class PaymentHelper extends CustomerHelper
class PaymentHelper extends CommonHelper
{
public function __construct()
{

View File

@ -6,5 +6,5 @@ use App\Entities\Equipment\ServerPartEntity;
interface ServerPartInterface extends EquipmentInterface
{
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): mixed;
public function setServerPart(ServerPartEntity $serverPartEntity, array $formDatas): ServerPartEntity;
}

View File

@ -6,9 +6,10 @@ return [
'clientinfo_uid' => "고객번호",
'serviceinfo_uid' => "서비스번호",
'serverinfo_uid' => "서버번호",
'title' => "제목",
'type' => "항목형식",
'billing' => "결제방식",
'amount' => "제공",
'amount' => "제공",
'cnt' => "갯수",
'extra' => "추가정보",
'updated_at' => "수정일",
@ -30,6 +31,7 @@ return [
"SWITCH" => "스위치",
"IP" => "IP",
"CS" => "CS",
"ETC" => "기타",
],
"EXTRA" => [
'DISK' => [

View File

@ -8,7 +8,7 @@ class ServerPartModel extends EquipmentModel
{
const TABLE = "serverpartinfo";
const PK = "uid";
const TITLE = "uid";
const TITLE = "title";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
protected $returnType = ServerPartEntity::class;
@ -17,6 +17,7 @@ class ServerPartModel extends EquipmentModel
"clientinfo_uid",
"serverinfo_uid",
"serviceinfo_uid",
"title",
"type",
"billing",
"amount",
@ -34,16 +35,17 @@ class ServerPartModel extends EquipmentModel
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
}
switch ($field) {
case "part_uid":
case "serverinfo_uid":
case "cnt":
case "amount":
$rule = "required|numeric";
break;
case "part_uid":
case "clientinfo_uid":
case "serviceinfo_uid":
$rule = "permit_empty|numeric";
break;
case "title":
case "type":
case "billing":
$rule = "required|trim|string";

View File

@ -1,11 +1,10 @@
<?php
namespace App\Models\Customer;
namespace App\Models;
use App\Entities\Customer\PaymentEntity;
use App\Libraries\LogCollector;
use App\Entities\PaymentEntity;
class PaymentModel extends CustomerModel
class PaymentModel extends CommonModel
{
const TABLE = "payment";
const PK = "uid";
@ -17,6 +16,7 @@ class PaymentModel extends CustomerModel
"user_uid",
"clientinfo_uid",
"serviceinfo_uid",
"serverpartinfo_uid",
"title",
"amount",
"billing",
@ -41,6 +41,9 @@ class PaymentModel extends CustomerModel
case "amount":
$rule = "required|numeric";
break;
case "serverpartinfo_uid":
$rule = "permit_empty|numeric";
break;
case "title":
case "billing":
case "status":

View File

@ -5,9 +5,11 @@ namespace App\Services\Customer;
use App\Entities\Customer\ClientEntity;
use App\Helpers\Customer\ClientHelper;
use App\Models\Customer\ClientModel;
use App\Services\PaymentService;
class ClientService extends CustomerService
{
private ?PaymentService $_paymentService = null;
public function __construct()
{
parent::__construct(new ClientModel(), new ClientHelper());
@ -51,6 +53,13 @@ class ClientService extends CustomerService
{
return ['site', 'role', 'status'];
}
final public function getPaymentService(): PaymentService
{
if (!$this->_paymentService) {
$this->_paymentService = new PaymentService();
}
return $this->_paymentService;
}
//기본 기능부분
//압금(쿠폰:추가)처리

View File

@ -8,11 +8,9 @@ use App\Helpers\CommonHelper;
use App\Models\CommonModel;
use App\Services\CommonService;
use App\Services\Customer\ClientService;
use App\Services\Customer\PaymentService;
use App\Services\Equipment\ServerService;
use App\Services\Equipment\SwitchService;
use App\Services\UserService;
use CodeIgniter\Model;
abstract class CustomerService extends CommonService
{
@ -21,7 +19,6 @@ abstract class CustomerService extends CommonService
private ?ServiceService $_serviceService = null;
private ?ServerService $_serverService = null;
private ?SwitchService $_switchService = null;
private ?PaymentService $_paymentServiceService = null;
private $_equipmentService = [];
protected function __construct(CommonModel $model, CommonHelper $helper)
@ -50,20 +47,6 @@ abstract class CustomerService extends CommonService
}
return $this->_serviceService;
}
final public function getPaymentService(): PaymentService
{
if (!$this->_paymentServiceService) {
$this->_paymentServiceService = new PaymentService();
}
return $this->_paymentServiceService;
}
final public function getSwitchService(): SwitchService
{
if (!$this->_switchService) {
$this->_switchService = new SwitchService();
}
return $this->_switchService;
}
final public function getServerService(): ServerService
{
if (!$this->_serverService) {

View File

@ -1,129 +0,0 @@
<?php
namespace App\Services\Customer;
use App\Entities\Customer\PaymentEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Helpers\Customer\PaymentHelper;
use App\Models\Customer\PaymentModel;
class PaymentService extends CustomerService
{
public function __construct()
{
parent::__construct(new PaymentModel(), new PaymentHelper());
$this->addClassName('Payment');
}
public function getModelClass(): PaymentModel
{
return new PaymentModel();
}
public function getEntityClass(): PaymentEntity
{
return new PaymentEntity();
}
public function getFormFields(): array
{
return [
"clientinfo_uid",
"serviceinfo_uid",
"title",
"amount",
"billing",
"billing_at",
"pay",
"status",
];
}
public function getFormFilters(): array
{
return [
'clientinfo_uid',
"serviceinfo_uid",
'billing',
'pay',
'status',
'user_uid',
];
}
public function getIndexFields(): array
{
return [
'clientinfo_uid',
"serviceinfo_uid",
'billing',
'title',
'amount',
'billing_at',
'pay',
'status',
'updated_at',
'countdown',
'user_uid',
];
}
public function getBatchjobFields(): array
{
return ['pay', 'status'];
}
public function getBatchjobButtons(): array
{
return [
'batchjob' => '일괄 결제 ',
'invoice' => '청구서 발행',
];
}
//기본 기능부분
//FieldForm관련용
public function getFormOption(string $field, array $options = []): array
{
switch ($field) {
case 'user_uid':
$options = $this->getUserService()->getEntities();
break;
case 'clientinfo_uid':
$options = $this->getClientService()->getEntities();
break;
case 'serviceinfo_uid':
$options = $this->getServiceService()->getEntities();
break;
default:
$options = parent::getFormOption($field, $options);
break;
}
return $options;
}
//List 검색용
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->getModel()->orderBy('billing_at ASC');
parent::setOrderBy($field, $value);
}
//총 미납건수, 금액
public function getUnPaids(string $group, array $where = []): array
{
return $this->getModel()->groupBy($group)
->select("serviceinfo_uid,COUNT(uid) as cnt, SUM(amount) as amount")
->where(['billing_at <=' => date('Y-m-d')])
->where(['status' => STATUS['UNPAID']])
->where($where)
->get()->getResult();
}
//생성
public function create(array $formDatas): PaymentEntity
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
return parent::create($formDatas);
}
//수정
public function modify(mixed $entity, array $formDatas): PaymentEntity
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
return parent::modify($entity, $formDatas);
}
}

View File

@ -3,19 +3,21 @@
namespace App\Services\Customer;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\PaymentEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\UserEntity;
use App\Entities\PaymentEntity;
use App\Helpers\Customer\ServiceHelper;
use App\Models\Customer\ServiceModel;
use App\Services\Equipment\ServerService;
use App\Traits\IPTrait;
use App\Services\PaymentService;
class ServiceService extends CustomerService
{
use IPTrait;
private ?ServerService $_serverService = null;
private ?PaymentService $_paymentService = null;
public function __construct()
{
parent::__construct(new ServiceModel(), new ServiceHelper());
@ -117,6 +119,13 @@ class ServiceService extends CustomerService
}
return $entity->setServerEntity($serverEntity);
}
final public function getPaymentService(): PaymentService
{
if (!$this->_paymentService) {
$this->_paymentService = new PaymentService();
}
return $this->_paymentService;
}
//기본 기능부분
public function getFormOption(string $field, array $options = []): array
{
@ -209,22 +218,14 @@ class ServiceService extends CustomerService
$entity = parent::create($formDatas);
$entity = $entity->setServerEntity($this->getServerService()->setService($entity, $formDatas['serverinfo_uid'], STATUS['OCCUPIED']));
// 결제정보에 추가한다.
$paymentDatas = [];
$paymentDatas['clientinfo_uid'] = $entity->getClientInfoUID();
$paymentDatas['serviceinfo_uid'] = $entity->getPK();
$paymentDatas['serverinfo_uid'] = $entity->getServerInfoUID();
$paymentDatas['title'] = sprintf("[%s] 서비스", $entity->getServerEntity()->getTitle());
$paymentDatas['amount'] = $entity->getAmount();
$paymentDatas['billing'] = PAYMENT['BILLING']['MONTH'];
$paymentDatas['billing_at'] = $entity->getBillingAt();
$this->getPaymentService()->create($paymentDatas);
$this->getPaymentService()->service($entity);
return $entity;
}
//수정
public function modify(mixed $entity, array $formDatas): ServiceEntity
{
if (!array_key_exists('serverinfo_uid', $formDatas)) {
throw new \Exception("신규 서버가 지정되지 않았습니다.");
throw new \Exception("서버가 지정되지 않았습니다.");
}
//기존서버정보 사용가능으로 설정
if ($entity->getServerInfoUID() && $entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) {
@ -250,7 +251,7 @@ class ServiceService extends CustomerService
$paymentDatas['clientinfo_uid'] = $entity->getClientInfoUID();
$paymentDatas['serviceinfo_uid'] = $entity->getPK();
$paymentDatas['serverinfo_uid'] = $entity->getServerInfoUID();
$paymentDatas['title'] = sprintf("[%s] 서비스", $entity->getServerEntity()->getTitle());
$paymentDatas['title'] = $entity->getServerEntity()->getTitle();
$paymentDatas['amount'] = $entity->getAmount();
$paymentDatas['billing'] = PAYMENT['BILLING']['MONTH'];
$paymentDatas['billing_at'] = $entity->getBillingAt();

View File

@ -55,15 +55,21 @@ class CSService extends EquipmentService implements ServerPartInterface
}
//기본 기능부분
//서비스파트 설정
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): CSEntity
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{
$entity = $this->getEntity($uid);
if (!array_key_exists('part_uid', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
}
if (!array_key_exists('status', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
}
$entity = $this->getEntity($serverPartDatas['part_uid']);
if (!($entity instanceof CSEntity)) {
throw new \Exception("{$uid}에 해당하는 CS정보를 찾을수없습니다.");
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 CS정보를 찾을수없습니다.");
}
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
$formDatas = [];
if ($status === STATUS['AVAILABLE']) {
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) {
//사용가능
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
@ -73,8 +79,8 @@ class CSService extends EquipmentService implements ServerPartInterface
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
}
$formDatas['status'] = $status;
return $this->modify($entity, $formDatas);
$formDatas['status'] = $serverPartDatas['status'];
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
}
//List 검색용
//OrderBy 처리

View File

@ -79,17 +79,22 @@ class IPService extends EquipmentService implements ServerPartInterface
return $options;
}
//서비스 설정
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): IPEntity
//서비스파트 설정
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{
$entity = $this->getEntity($uid);
if (!array_key_exists('part_uid', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
}
if (!array_key_exists('status', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
}
$entity = $this->getEntity($serverPartDatas['part_uid']);
if (!($entity instanceof IPEntity)) {
throw new \Exception("{$uid}에 해당하는 IP정보를 찾을수없습니다.");
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 IP정보를 찾을수없습니다.");
}
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
$formDatas = [];
//기존IP 사용자로 고객정보 설정
$formDatas['old_clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
if ($status === STATUS['AVAILABLE']) {
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) {
//사용가능
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
@ -99,8 +104,8 @@ class IPService extends EquipmentService implements ServerPartInterface
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
}
$formDatas['status'] = $status;
return $this->modify($entity, $formDatas);
$formDatas['status'] = $serverPartDatas['status'];
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
}
//List 검색용
//OrderBy 처리

View File

@ -49,24 +49,31 @@ class PartService extends EquipmentService implements ServerPartInterface
//기본 기능부분
//FieldForm관련용
//서비스파트 설정
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): PartEntity
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{
$entity = $this->getEntity($uid);
if (!array_key_exists('part_uid', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
}
if (!array_key_exists('status', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
}
//부품정보가져오기
$entity = $this->getEntity($serverPartDatas['part_uid']);
if (!($entity instanceof PartEntity)) {
throw new \Exception("{$uid}에 해당하는 부품정보를 찾을수없습니다.");
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 부품정보를 찾을수없습니다.");
}
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
$formDatas = [];
if ($status === STATUS['AVAILABLE']) { //해지된 부품 재고수를 처리
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) { //해지된 부품 재고수를 처리
$formDatas['stock'] = $entity->getStock() + $serverPartEntity->getCnt();
}
if ($status === STATUS['OCCUPIED']) { //추가된 부품 재고수를 처리
if ($serverPartDatas['status'] === STATUS['OCCUPIED']) { //추가된 부품 재고수를 처리
if ($entity->getStock() < $serverPartEntity->getCnt()) {
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
}
$formDatas['stock'] = $entity->getStock() - $serverPartEntity->getCnt();
}
return $this->modify($entity, $formDatas);
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
}
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void

View File

@ -2,12 +2,12 @@
namespace App\Services\Equipment;
use App\Services\Equipment\EquipmentService;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Helpers\Equipment\ServerPartHelper;
use App\Models\Equipment\ServerPartModel;
use App\Services\Customer\PaymentService;
use App\Services\Equipment\EquipmentService;
use App\Services\PaymentService;
class ServerPartService extends EquipmentService
{
@ -28,6 +28,7 @@ class ServerPartService extends EquipmentService
"type",
"billing",
"part_uid",
"title",
"cnt",
"extra",
"amount",
@ -111,20 +112,29 @@ class ServerPartService extends EquipmentService
throw new \Exception(__METHOD__ . "에서 형식오류:ServicePartEntity만 허용됩니다.");
}
switch ($entity->getType()) {
case 'CPU':
case 'RAM':
case 'DISK':
case 'OS':
case 'DB':
case 'SOFTWARE':
$partService = $this->getPartService();
$entity->setPartEntity($partService->getEntity($entity->getPartUID()));
break;
case 'SWITCH':
$partService = $this->getSwitchService();
$entity->setPartEntity($partService->getEntity($entity->getPartUID()));
break;
case 'IP':
$partService = $this->getIPService();
$entity->setPartEntity($partService->getEntity($entity->getPartUID()));
break;
case 'CS':
$partService = $this->getCSService();
break;
default:
$partService = $this->getPartService();
$entity->setPartEntity($partService->getEntity($entity->getPartUID()));
break;
}
return $entity->setPartEntity($partService->getEntity($entity->getPartUID()));
return $entity;
}
//기본 기능부분
// FieldForm관련용
@ -152,6 +162,9 @@ class ServerPartService extends EquipmentService
case 'CS':
$partOptions[$partType] = $this->getCSService()->getEntities();
break;
default:
$partOptions[$partType] = [];
break;
}
}
$options = $partOptions;
@ -166,25 +179,30 @@ class ServerPartService extends EquipmentService
}
return $options;
}
//파트별 정보 수정작업
private function setServerPart(ServerPartEntity $entity, mixed $part_uid, string $status): mixed
//파트별정보 설정
private function setServerPart(ServerPartEntity $entity, array $formDatas): ServerPartEntity
{
//Type에 따른 부품서비스 정의
switch ($entity->getType()) {
case 'CPU':
case 'RAM':
case 'DISK':
case 'OS':
case 'DB':
case 'SOFTWARE':
$entity = $this->getPartService()->setServerPart($entity, $formDatas);
break;
case 'SWITCH':
$partEntity = $this->getSwitchService()->setServerPart($entity, $part_uid, $status);
$entity = $this->getSwitchService()->setServerPart($entity, $formDatas);
break;
case 'IP':
$partEntity = $this->getIPService()->setServerPart($entity, $part_uid, $status);
$entity = $this->getIPService()->setServerPart($entity, $formDatas);
break;
case 'CS':
$partEntity = $this->getCSService()->setServerPart($entity, $part_uid, $status);
break;
default: //CPU/RAM/DISK/OS/DB/SOFTWARE
$partEntity = $this->getPartService()->setServerPart($entity, $part_uid, $status);
$entity = $this->getCSService()->setServerPart($entity, $formDatas);
break;
}
return $partEntity;
return $entity;
}
//부품연결정보생성
public function create(array $formDatas): ServerPartEntity
@ -202,31 +220,15 @@ class ServerPartService extends EquipmentService
if (!($serverEntity instanceof ServerEntity)) {
throw new \Exception("서버 정보가 지정되지 않았습니다.");
}
//생성작업
$formDatas["clientinfo_uid"] = $serverEntity->getClientInfoUID();
$formDatas["serviceinfo_uid"] = $serverEntity->getServiceInfoUID();
$formDatas["serverinfo_uid"] = $serverEntity->getPK();
$entity = parent::create($formDatas);
//부품연결정보에 부품정보 정의
$entity = $entity->setPartEntity(
$this->setServerPart($entity, $formDatas['part_uid'], STATUS['OCCUPIED'])
);
//기본 부품이 아닌경우 결제정보에 추가한다.
if ($entity->getBilling() !== PAYMENT['BILLING']['BASE']) {
if ($entity->getBilling() === PAYMENT['BILLING']['ONETIME']) {
if ($entity->getServiceInfoUID() === null) {
throw new \Exception("일회성 부품 추가는 서비스정보가 정의된 후에만 가능합니다.");
}
}
$paymentDatas = [];
$paymentDatas['clientinfo_uid'] = $entity->getClientInfoUID();
$paymentDatas['serviceinfo_uid'] = $entity->getServiceInfoUID();
$paymentDatas['serverinfo_uid'] = $entity->getServerInfoUID();
$paymentDatas['title'] = sprintf("[%s] 부품정보", $entity->getPartEntity()->getTitle());
$paymentDatas['amount'] = $entity->getAmount();
$paymentDatas['billing'] = $entity->getBilling();
$paymentDatas['billing_at'] = date("Y-m-d"); //일회성은 지급일이 당일기준처리
$this->getPaymentService()->create($paymentDatas);
}
//부품정보 설정
$entity = $this->setServerPart($entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
//결제관련정보 설정
$entity = $this->getPaymentService()->setServerPart($entity);
return $entity;
}
//수정
@ -240,26 +242,28 @@ class ServerPartService extends EquipmentService
if (!($serverEntity instanceof ServerEntity)) {
throw new \Exception("서버 정보가 지정되지 않았습니다.");
}
//부품연결정보에 부품정보가 변경된 경우(기존것은 AVAILABLE로 변경)
if ($entity->getPartUID() != $formDatas['part_uid']) {
$entity = $this->setServerPart($entity, ['part_uid' => $entity->getPartUID(), 'status' => STATUS['AVAILABLE']]);
}
//수정작업
$formDatas["clientinfo_uid"] = $serverEntity->getClientInfoUID();
$formDatas["serviceinfo_uid"] = $serverEntity->getServiceInfoUID();
$formDatas["serverinfo_uid"] = $serverEntity->getPK();
//기존 Part_UID와 신규 Part_UID가 다르면 기존 Part정보 사용가능으로 변경
if ($entity->getPartUID() != $formDatas['part_uid']) {
$this->setServerPart($entity, $entity->getPartUID(), STATUS['AVAILABLE']);
}
//기존 정보변경
$entity = parent::modify($entity, $formDatas);
//부품연결정보에 부품정보 정의
//부품연결정보에 부품정보가 변경된 경우 OCCUPIED로 변경
if ($entity->getPartUID() != $formDatas['part_uid']) {
$entity->setPartEntity($this->setServerPart($entity, $formDatas['part_uid'], STATUS['OCCUPIED']));
$entity = $this->setServerPart($entity, ['part_uid' => $formDatas['part_uid'], 'status' => STATUS['OCCUPIED']]);
}
//결제관련정보 정의
$entity = $this->getPaymentService()->setServerPart($entity, ['action' => __FUNCTION__]);
return $entity;
}
//삭제
public function delete(mixed $entity): ServerPartEntity
{
//부품연결정보에 부품정보 정의
$this->setServerPart($entity, $entity->getPartUID(), STATUS['AVAILABLE']);
$entity = $this->setServerPart($entity, ['part_uid' => $entity->getPartUID(), 'status' => STATUS['AVAILABLE']]);
return parent::delete($entity);
}
}

View File

@ -51,15 +51,22 @@ class SwitchService extends EquipmentService implements ServerPartInterface
//기본 기능부분
//FieldForm관련용
//서비스파트 설정
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): SwitchEntity
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{
$entity = $this->getEntity($uid);
if (!($entity instanceof SwitchEntity)) {
throw new \Exception("{$uid}에 해당하는 스위치정보를 찾을수없습니다.");
if (!array_key_exists('part_uid', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
}
if (!array_key_exists('status', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
}
$entity = $this->getEntity($serverPartDatas['part_uid']);
if (!($entity instanceof SwitchEntity)) {
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 스위치정보를 찾을수없습니다.");
}
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
$formDatas = [];
if ($status === STATUS['AVAILABLE']) {
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) {
//사용가능
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
@ -69,8 +76,8 @@ class SwitchService extends EquipmentService implements ServerPartInterface
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
}
$formDatas['status'] = $status;
return $this->modify($entity, $formDatas);
$formDatas['status'] = $serverPartDatas['status'];
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
}
//List 검색용
//OrderBy 처리

View File

@ -0,0 +1,206 @@
<?php
namespace App\Services;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\PaymentEntity;
use App\Helpers\PaymentHelper;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Models\PaymentModel;
use App\Services\Customer\ClientService;
use App\Services\Customer\ServiceService;
use App\Services\UserService;
class PaymentService extends CommonService implements ServerPartInterface
{
private ?UserService $_userService = null;
private ?ClientService $_clientService = null;
private ?ServiceService $_serviceService = null;
public function __construct()
{
parent::__construct(new PaymentModel(), new PaymentHelper());
$this->addClassName('Payment');
}
final public function getFormFields(): array
{
return [
"clientinfo_uid",
"serviceinfo_uid",
"title",
"amount",
"billing",
"billing_at",
"pay",
"status",
];
}
final public function getFormFilters(): array
{
return [
'clientinfo_uid',
"serviceinfo_uid",
'billing',
'pay',
'status',
'user_uid',
];
}
final public function getIndexFields(): array
{
return [
'clientinfo_uid',
"serviceinfo_uid",
'billing',
'title',
'amount',
'billing_at',
'pay',
'status',
'updated_at',
'countdown',
'user_uid',
];
}
final public function getBatchjobFields(): array
{
return ['pay', 'status'];
}
final public function getBatchjobButtons(): array
{
return [
'batchjob' => '일괄 결제 ',
'invoice' => '청구서 발행',
];
}
final public function getClientService(): ClientService
{
if (!$this->_clientService) {
$this->_clientService = new ClientService();
}
return $this->_clientService;
}
final public function getUSerService(): UserService
{
if (!$this->_userService) {
$this->_userService = new UserService();
}
return $this->_userService;
}
final public function getServiceService(): ServiceService
{
if (!$this->_serviceService) {
$this->_serviceService = new ServiceService();
}
return $this->_serviceService;
}
//기본 기능부분
//FieldForm관련용
final public function getFormOption(string $field, array $options = []): array
{
switch ($field) {
case 'user_uid':
$options = $this->getUserService()->getEntities();
break;
case 'clientinfo_uid':
$options = $this->getClientService()->getEntities();
break;
case 'serviceinfo_uid':
$options = $this->getServiceService()->getEntities();
break;
default:
$options = parent::getFormOption($field, $options);
break;
}
return $options;
}
//List 검색용
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->getModel()->orderBy('billing_at ASC');
parent::setOrderBy($field, $value);
}
//총 미납건수, 금액
final public function getUnPaids(string $group, array $where = []): array
{
return $this->getModel()->groupBy($group)
->select("serviceinfo_uid,COUNT(uid) as cnt, SUM(amount) as amount")
->where(['billing_at <=' => date('Y-m-d')])
->where(['status' => STATUS['UNPAID']])
->where($where)
->get()->getResult();
}
//생성
public function create(array $formDatas): PaymentEntity
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
return parent::create($formDatas);
}
//수정
public function modify(mixed $entity, array $formDatas): PaymentEntity
{
// 관리자 UID는 현재 인증된 사용자로 설정
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
return parent::modify($entity, $formDatas);
}
//서버연결정보용 등록
public function setServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): ServerPartEntity
{
if ($serverPartEntity->getServiceInfoUID() === null) {
throw new \Exception("서비스정보가 정의된 후에만 가능합니다.");
}
//Service Entity 가져오기
$serviceEntity = $this->getServiceService()->getEntity($serverPartEntity->getServiceInfoUID());
if (!$serviceEntity) {
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
}
//수정인경우 기존 결제정보 가져오기
if (array_key_exists('action', $formDatas) && $formDatas['action'] === 'modify') {
$entity = $this->getEntity(['serverpartinfo_uid' => $serverPartEntity->getPK()]);
if (!$entity instanceof PaymentEntity) {
throw new \Exception("{$serverPartEntity->getPK()}에 해당하는 결제정보를 찾을수 없습니다.");
}
}
//월비용인경우 서비스 제공가에 서버연결정보 제공가 합산금액으로 설정
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['MONTH']) {
$formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
$formDatas['amount'] = $serviceEntity->getAmount() + $serverPartEntity->getAmount();
$this->getServiceService()->modify($serviceEntity, $formDatas);
}
//일회성인경우
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME']) {
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['serverpartinfo_uid'] = $serverPartEntity->getPK();
$formDatas['title'] = $serverPartEntity->getType() === 'ETC' ? $serverPartEntity->getTitle() : $serverPartEntity->getPartEntity()->getTitle();
$formDatas['amount'] = $serverPartEntity->getAmount();
$formDatas['billing'] = $serverPartEntity->getBilling();
if (array_key_exists('action', $formDatas) && $formDatas['action'] === 'modify') {
$this->modify($entity, $formDatas);
} else {
//생성일때만 지급기한일 설정
$formDatas['billing_at'] = $serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME'] ? date("Y-m-d") : $serviceEntity->getBillingAT();
$this->create($formDatas);
}
}
return $serverPartEntity;
}
//서비스정보용 등록
public function service(ServiceEntity $serviceEntity, array $formDatas = []): ServiceEntity
{
$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();
$this->create($formDatas);
return $serviceEntity;
}
}

View File

@ -4,7 +4,10 @@
<?php foreach ($serverPartCellDatas['entities'][$type] as $entities): ?>
<?php foreach ($entities as $entity): ?>
<?php $serverPartCellDatas['entity'] = $entity ?>
<?php $htmls[$type][] = $serverPartCellDatas['service']->getHelper()->getFieldView($type, $entity->getPK(), $serverPartCellDatas) ?>
<?php $htmls[$type][] = [
'view' => $serverPartCellDatas['service']->getHelper()->getFieldView($type, $entity->getPK(), $serverPartCellDatas),
'amount' => $entity->getAmount() * $entity->getCnt()
] ?>
<?php endforeach ?>
<?php endforeach ?>
<?php endforeach ?>
@ -12,7 +15,8 @@
<?php foreach ($serverPartCellDatas['types'] as $type): ?>
<tr class="m-0 p-0">
<th class="text-end m-0 p-0" width="15%"><?= $serverPartCellDatas['service']->getHelper()->getListButton($type, '', $serverPartCellDatas) ?></th>
<td class="text-start m-0 p-0"><?= implode(",", $htmls[$type]) ?></td>
<td class="text-start m-0 p-0"><?php foreach ($htmls[$type] as $html): ?><?= $html['view'] ?>[<?= number_format($html['amount']) ?>원]<BR><?php endforeach ?></td>
</td>
</tr>
<?php endforeach ?>
</table>