dbmsv2 init...1
This commit is contained in:
parent
090a01de92
commit
3d7ff7bbfb
@ -7,10 +7,19 @@ use App\Services\Customer\ServiceService;
|
||||
|
||||
class ServiceCell extends CustomerCell
|
||||
{
|
||||
|
||||
private ?PaymentService $_paymentService = null;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(new ServiceService());
|
||||
}
|
||||
final public function getPaymentService(): PaymentService
|
||||
{
|
||||
if (!$this->_paymentService) {
|
||||
$this->_paymentService = new PaymentService();
|
||||
}
|
||||
return $this->_paymentService;
|
||||
}
|
||||
|
||||
public function detail(array $params): string
|
||||
{
|
||||
@ -19,14 +28,25 @@ class ServiceCell extends CustomerCell
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
$entities = $this->getService()->getEntities(['clientinfo_uid' => $params['userinfo_uid']]);
|
||||
$unPaids = [];
|
||||
$entities = [];
|
||||
foreach ($this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid']]) as $entity) {
|
||||
if (!array_key_exists($entity->getPK(), $unPaids)) {
|
||||
$unPaids[$entity->getPK()] = ['cnt' => 0, 'amount' => 0];
|
||||
}
|
||||
foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid', ['serviceinfo_uid' => $entity->getPK()]) as $unPaid) {
|
||||
$unPaids[$entity->getPK()]['cnt'] += $unPaid->cnt;
|
||||
$unPaids[$entity->getPK()]['amount'] += $unPaid->amount;
|
||||
}
|
||||
$entities[] = $entity;
|
||||
}
|
||||
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
|
||||
return view('cells/service/' . $template, [
|
||||
'serviceCellDatas' => [
|
||||
'control' => $this->getService()->getControlDatas(),
|
||||
'service' => $this->getService(),
|
||||
'entities' => $entities,
|
||||
'paymentService' => new PaymentService()
|
||||
'unPaids' => $unPaids
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
@ -117,6 +117,7 @@ class ClientController extends CustomerController
|
||||
'clientinfo_uid' => $entity->getPK(),
|
||||
'status' => STATUS['AVAILABLE']
|
||||
]);
|
||||
//서비스별 미납 Count
|
||||
$this->unPaids = $this->getService()->getPaymentService()->getUnPaids('clientinfo_uid', [
|
||||
'clientinfo_uid' => $entity->getPK()
|
||||
]);
|
||||
|
||||
@ -91,12 +91,7 @@ class ServiceController extends CustomerController
|
||||
protected function index_process(array $entities = []): array
|
||||
{
|
||||
//서비스별 미납 Count
|
||||
$unpaids = ['count' => 0, 'amount' => 0];
|
||||
foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid') as $row) {
|
||||
$unpaids[$row->serviceinfo_uid]['count'] = $row->cnt;
|
||||
$unpaids[$row->serviceinfo_uid]['amount'] = $row->amount;
|
||||
};
|
||||
$this->unpaids = $unpaids;
|
||||
$this->unPaids = $this->getPaymentService()->getUnPaids('serviceinfo_uid');
|
||||
//부모함수처리
|
||||
return parent::index_process($entities);
|
||||
}
|
||||
|
||||
@ -77,14 +77,13 @@ class Home extends AdminController
|
||||
$this->newServiceCount = count($this->newServiceEntities);
|
||||
//서비스별 미납 Count
|
||||
$totalUnPaidCount = 0;
|
||||
$unpaids = ['count' => 0, 'amount' => 0];
|
||||
foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid') as $row) {
|
||||
$unpaids[$row->serviceinfo_uid]['count'] = $row->cnt;
|
||||
$unpaids[$row->serviceinfo_uid]['amount'] = $row->amount;
|
||||
$totalUnPaidCount += $row->cnt;
|
||||
};
|
||||
$this->unpaids = $unpaids;
|
||||
$totalUnPaidAmount = 0;
|
||||
foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid') as $unPaid) {
|
||||
$totalUnPaidCount += $unPaid->cnt;
|
||||
$totalUnPaidAmount += $unPaid->amount;
|
||||
}
|
||||
$this->totalUnPaidCount = $totalUnPaidCount;
|
||||
$this->totalUnPaidAmount = $totalUnPaidAmount;
|
||||
helper(['form']);
|
||||
return $this->getResultSuccess();
|
||||
}
|
||||
|
||||
@ -17,11 +17,6 @@ abstract class CommonEntity extends Entity
|
||||
parent::__construct($data);
|
||||
}
|
||||
|
||||
final public function __call($name, $arguments): string
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getPK(): int|string
|
||||
{
|
||||
$field = constant("static::PK");
|
||||
|
||||
@ -18,15 +18,16 @@ class PaymentHelper extends CustomerHelper
|
||||
case "countdown": //결제일Countdown
|
||||
$value = $viewDatas['entity']->getCountDueAt();
|
||||
break;
|
||||
case 'item_uid':
|
||||
//ItemType에 따라 필터옵션에서 Title을 가져옴
|
||||
$value = $viewDatas['control']['field_optons'][$viewDatas['entity']->getItemType()][$value]->getTitle();
|
||||
break;
|
||||
case 'serviceinfo_uid':
|
||||
case 'clientinfo_uid':
|
||||
case 'billing_method':
|
||||
$value = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) && $viewDatas['control']['field_optons'][$field][$value] ? $viewDatas['control']['field_optons'][$field][$value]->getTitle() : "";
|
||||
break;
|
||||
case 'billing':
|
||||
case 'pay':
|
||||
case 'status':
|
||||
$value = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) && $viewDatas['control']['field_optons'][$field][$value] ? $viewDatas['control']['field_optons'][$field][$value] : "";
|
||||
break;
|
||||
default:
|
||||
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
@ -40,7 +41,6 @@ class PaymentHelper extends CustomerHelper
|
||||
{
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
case 'batchjob':
|
||||
case 'batchjob_delete':
|
||||
$action = "";
|
||||
break;
|
||||
|
||||
@ -79,7 +79,11 @@ class ServiceHelper extends CustomerHelper
|
||||
case 'billing_at':
|
||||
if (array_key_exists('unPaids', $viewDatas)) {
|
||||
if (array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids'])) {
|
||||
$value .= "<div><a href=\"/admin/customer/payment?={$viewDatas['entity']->getPK()}\">미지급: <span style=\"color:red;\">" . $viewDatas['unPaids'][$viewDatas['entity']->getPK()] . "</span>개</a></div>";
|
||||
foreach ($viewDatas['unPaids'] as $unPaid) {
|
||||
if ($unPaid->serviceinfo_uid = $viewDatas['entity']->getPK()) {
|
||||
$value .= "<div><a href=\"/admin/customer/payment?={$viewDatas['entity']->getPK()}\">미지급: <span style=\"color:red;\">" . $unPaid->cnt . "개,총 " . number_format($unPaid->amount) . "원</span></a></div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
5
app/Interfaces/Customer/CustomerInterFace.php
Normal file
5
app/Interfaces/Customer/CustomerInterFace.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces\Customer;
|
||||
|
||||
interface CustomerInterFace {}
|
||||
5
app/Interfaces/Equipment/EquipmentInterFace.php
Normal file
5
app/Interfaces/Equipment/EquipmentInterFace.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces\Equipment;
|
||||
|
||||
interface EquipmentInterFace {}
|
||||
10
app/Interfaces/Equipment/ServerPartInterFace.php
Normal file
10
app/Interfaces/Equipment/ServerPartInterFace.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interfaces\Equipment;
|
||||
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
|
||||
interface ServerPartInterface extends EquipmentInterFace
|
||||
{
|
||||
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): mixed;
|
||||
}
|
||||
@ -14,6 +14,7 @@ class ServerPartModel extends EquipmentModel
|
||||
protected $returnType = ServerPartEntity::class;
|
||||
protected $allowedFields = [
|
||||
"part_uid",
|
||||
"clientinfo_uid",
|
||||
"serverinfo_uid",
|
||||
"serviceinfo_uid",
|
||||
"type",
|
||||
@ -39,6 +40,7 @@ class ServerPartModel extends EquipmentModel
|
||||
case "amount":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Entities\FormOptionEntity;
|
||||
use App\Models\CommonModel;
|
||||
use App\Helpers\CommonHelper;
|
||||
|
||||
|
||||
@ -3,10 +3,12 @@
|
||||
namespace App\Services\Customer;
|
||||
|
||||
use App\Entities\Customer\PaymentEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Helpers\Customer\PaymentHelper;
|
||||
use App\Interfaces\Equipment\ServerPartInterFace;
|
||||
use App\Models\Customer\PaymentModel;
|
||||
|
||||
class PaymentService extends CustomerService
|
||||
class PaymentService extends CustomerService implements ServerPartInterFace
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
@ -38,6 +40,7 @@ class PaymentService extends CustomerService
|
||||
{
|
||||
return [
|
||||
'clientinfo_uid',
|
||||
"serviceinfo_uid",
|
||||
'billing',
|
||||
'pay',
|
||||
'status',
|
||||
@ -48,6 +51,7 @@ class PaymentService extends CustomerService
|
||||
{
|
||||
return [
|
||||
'clientinfo_uid',
|
||||
"serviceinfo_uid",
|
||||
'billing',
|
||||
'title',
|
||||
'amount',
|
||||
@ -61,11 +65,12 @@ class PaymentService extends CustomerService
|
||||
}
|
||||
public function getBatchjobFields(): array
|
||||
{
|
||||
return ['clientinfo_uid', 'billing', 'pay', 'status'];
|
||||
return ['pay', 'status'];
|
||||
}
|
||||
public function getBatchjobButtons(): array
|
||||
{
|
||||
return [
|
||||
'batchjob' => '일괄 결제 ',
|
||||
'invoice' => '청구서 발행',
|
||||
];
|
||||
}
|
||||
@ -89,6 +94,24 @@ class PaymentService extends CustomerService
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
//서비스 설정
|
||||
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): PaymentEntity
|
||||
{
|
||||
if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME']) {
|
||||
if ($serverPartEntity->getServiceInfoUID() === null) {
|
||||
throw new \Exception("일회성 부품 추가는 서비스정보가 정의된 후에만 가능합니다.");
|
||||
}
|
||||
}
|
||||
$formDatas = [];
|
||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
||||
$formDatas['title'] = sprintf("[%s] 일회성 추가", $serverPartEntity->getPartEntity()->getTitle());
|
||||
$formDatas['amount'] = $serverPartEntity->getAmount();
|
||||
$formDatas['billing'] = $serverPartEntity->getBilling();
|
||||
$formDatas['billing_at'] = date("Y-m-d"); //일회성은 지급일이 당일기준처리
|
||||
return $this->create($formDatas);
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
||||
@ -99,13 +122,12 @@ class PaymentService extends CustomerService
|
||||
//총 미납건수, 금액
|
||||
public function getUnPaids(string $group, array $where = []): array
|
||||
{
|
||||
$rows = $this->getModel()->groupBy($group)
|
||||
->select("COUNT(uid) as cnt, SUM(amount) as amount")
|
||||
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();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
//생성
|
||||
@ -113,7 +135,6 @@ class PaymentService extends CustomerService
|
||||
{
|
||||
// 관리자 UID는 현재 인증된 사용자로 설정
|
||||
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
||||
dd($formDatas);
|
||||
return parent::create($formDatas);
|
||||
}
|
||||
//수정
|
||||
|
||||
@ -199,22 +199,6 @@ class ServiceService extends CustomerService
|
||||
return $this->getModel()->query($sql, [$billing_at, $status]);
|
||||
}
|
||||
//기본기능
|
||||
|
||||
//서버정보 상태설정용
|
||||
private function setServer_process(ServiceEntity $entity, mixed $serverinfo_uid, string $status): ServiceEntity
|
||||
{
|
||||
//서버경우 서비스중으로 설정
|
||||
$serverEntity = $this->getServerService()->getEntity($serverinfo_uid);
|
||||
if (!($serverEntity instanceof ServerEntity)) {
|
||||
throw new \Exception("{$serverinfo_uid}에 해당하는 서버정보를 찾을수없습니다.");
|
||||
}
|
||||
//서버정보 상태수정
|
||||
$serverEntity = $this->getServerService()->modify(
|
||||
$serverEntity,
|
||||
['serviceEntity' => $entity, 'status' => $status],
|
||||
);
|
||||
return $entity->setServerEntity($serverEntity);
|
||||
}
|
||||
//생성
|
||||
public function create(array $formDatas): ServiceEntity
|
||||
{
|
||||
@ -222,11 +206,11 @@ class ServiceService extends CustomerService
|
||||
throw new \Exception("서버가 지정되지 않았습니다.");
|
||||
}
|
||||
$entity = parent::create($formDatas);
|
||||
return $this->setServer_process(
|
||||
return $entity->setServerEntity($this->getServerService()->setService(
|
||||
$entity,
|
||||
$formDatas['serverinfo_uid'],
|
||||
STATUS['OCCUPIED']
|
||||
);
|
||||
));
|
||||
}
|
||||
//수정
|
||||
public function modify(mixed $entity, array $formDatas): ServiceEntity
|
||||
@ -236,7 +220,7 @@ class ServiceService extends CustomerService
|
||||
}
|
||||
//기존서버정보 사용가능으로 설정
|
||||
if ($entity->getServerInfoUID() && $entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) {
|
||||
$entity = $this->setServer_process(
|
||||
$entity = $this->getServerService()->setService(
|
||||
$entity,
|
||||
$entity->getServerEntity()->getPK(),
|
||||
STATUS['AVAILABLE']
|
||||
@ -246,7 +230,7 @@ class ServiceService extends CustomerService
|
||||
$entity = parent::modify($entity, $formDatas);
|
||||
//신규서버정보 사용중으로 설정
|
||||
if ($entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) {
|
||||
$entity = $this->setServer_process(
|
||||
$entity = $this->getServerService()->setService(
|
||||
$entity,
|
||||
$formDatas['serverinfo_uid'],
|
||||
STATUS['OCCUPIED']
|
||||
@ -258,7 +242,7 @@ class ServiceService extends CustomerService
|
||||
public function delete(mixed $entity): ServiceEntity
|
||||
{
|
||||
//기존서버정보 사용가능으로 설정
|
||||
$entity = $this->setServer_process(
|
||||
$entity = $this->getServerService()->setService(
|
||||
$entity,
|
||||
$entity->getServerEntity()->getPK(),
|
||||
STATUS['AVAILABLE']
|
||||
@ -269,7 +253,6 @@ class ServiceService extends CustomerService
|
||||
public function history(mixed $entity, array $formDatas): ServiceEntity
|
||||
{
|
||||
//서비스 정보수정
|
||||
$entity = $this->getModel()->modify($entity, $formDatas);
|
||||
return $entity;
|
||||
return $this->getModel()->modify($entity, $formDatas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\Entities\Equipment\CSEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Helpers\Equipment\CSHelper;
|
||||
use App\Interfaces\Equipment\ServerPartInterface;
|
||||
use App\Models\Equipment\CSModel;
|
||||
|
||||
class CSService extends EquipmentService
|
||||
class CSService extends EquipmentService implements ServerPartInterface
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
@ -51,6 +54,28 @@ class CSService extends EquipmentService
|
||||
return ['type', 'status'];
|
||||
}
|
||||
//기본 기능부분
|
||||
//서비스파트 설정
|
||||
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): CSEntity
|
||||
{
|
||||
$entity = $this->getEntity($uid);
|
||||
if (!($entity instanceof CSEntity)) {
|
||||
throw new \Exception("{$uid}에 해당하는 CS정보를 찾을수없습니다.");
|
||||
}
|
||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||
$formDatas = [];
|
||||
if ($status === STATUS['AVAILABLE']) {
|
||||
//사용가능
|
||||
$formDatas['clientinfo_uid'] = null;
|
||||
$formDatas['serviceinfo_uid'] = null;
|
||||
$formDatas['serverinfo_uid'] = null;
|
||||
} else {
|
||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
||||
}
|
||||
$formDatas['status'] = $status;
|
||||
return $this->modify($entity, $formDatas);
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\Entities\Equipment\IPEntity;
|
||||
use App\Entities\Equipment\LineEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Helpers\Equipment\IPHelper;
|
||||
use App\Interfaces\Equipment\ServerPartInterface;
|
||||
use App\Models\Equipment\IPModel;
|
||||
use App\Services\Equipment\EquipmentService;
|
||||
use App\Services\Equipment\LineService;
|
||||
|
||||
class IPService extends EquipmentService
|
||||
class IPService extends EquipmentService implements ServerPartInterface
|
||||
{
|
||||
private ?LineService $_lineService = null;
|
||||
public function __construct()
|
||||
@ -78,6 +78,30 @@ class IPService extends EquipmentService
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
//서비스 설정
|
||||
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): IPEntity
|
||||
{
|
||||
$entity = $this->getEntity($uid);
|
||||
if (!($entity instanceof IPEntity)) {
|
||||
throw new \Exception("{$uid}에 해당하는 IP정보를 찾을수없습니다.");
|
||||
}
|
||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||
$formDatas = [];
|
||||
//기존IP 사용자로 고객정보 설정
|
||||
$formDatas['old_clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||
if ($status === STATUS['AVAILABLE']) {
|
||||
//사용가능
|
||||
$formDatas['clientinfo_uid'] = null;
|
||||
$formDatas['serviceinfo_uid'] = null;
|
||||
$formDatas['serverinfo_uid'] = null;
|
||||
} else {
|
||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
||||
}
|
||||
$formDatas['status'] = $status;
|
||||
return $this->modify($entity, $formDatas);
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
||||
|
||||
@ -168,67 +168,25 @@ class ServerPartService extends EquipmentService
|
||||
return $options;
|
||||
}
|
||||
//파트별 정보 수정작업
|
||||
private function setPart_process(ServerPartEntity $entity, mixed $part_uid, string $status): mixed
|
||||
private function setServerPart(ServerPartEntity $entity, mixed $part_uid, string $status): mixed
|
||||
{
|
||||
//Type에 따른 부품서비스 정의
|
||||
switch ($entity->getType()) {
|
||||
case 'SWITCH':
|
||||
$partService = $this->getSwitchService();
|
||||
$partEntity = $this->getSwitchService()->setServerPart($entity, $part_uid, $status);
|
||||
break;
|
||||
case 'IP':
|
||||
$partService = $this->getIPService();
|
||||
$partEntity = $this->getIPService()->setServerPart($entity, $part_uid, $status);
|
||||
break;
|
||||
case 'CS':
|
||||
$partService = $this->getCSService();
|
||||
$partEntity = $this->getCSService()->setServerPart($entity, $part_uid, $status);
|
||||
break;
|
||||
default:
|
||||
$partService = $this->getPartService();
|
||||
break;
|
||||
}
|
||||
//부품정보가져오기
|
||||
$partEntity = $partService->getEntity($part_uid);
|
||||
if (!$partEntity) {
|
||||
throw new \Exception(__METHOD__ . "에서 오류:{$part_uid}에 해닫하는 {$entity->getType()}정보가 없습니다.");
|
||||
}
|
||||
$formDatas = [];
|
||||
switch ($entity->getType()) {
|
||||
case 'IP':
|
||||
//기존IP 사용자로 고객정보 설정
|
||||
$formDatas['old_clientinfo_uid'] = $partEntity->getClientInfoUID();
|
||||
case 'SWITCH':
|
||||
case 'CS':
|
||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||
if ($status === STATUS['AVAILABLE']) {
|
||||
//사용가능
|
||||
$formDatas['clientinfo_uid'] = null;
|
||||
$formDatas['serviceinfo_uid'] = null;
|
||||
$formDatas['serverinfo_uid'] = null;
|
||||
} else {
|
||||
$formDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
||||
$formDatas['serviceinfo_uid'] = $entity->getServiceInfoUID();
|
||||
$formDatas['serverinfo_uid'] = $entity->getServerInfoUID();
|
||||
}
|
||||
$formDatas['part_uid'] = $part_uid;
|
||||
$formDatas['status'] = $status;
|
||||
$partEntity = $partService->modify($partEntity, $formDatas);
|
||||
break;
|
||||
throw new \Exception(__METHOD__ . "에서 오류발생: {$entity->getType()}은 지정되지 않은 부품파트입니다.");
|
||||
// break;
|
||||
}
|
||||
return $partEntity;
|
||||
}
|
||||
//일회성 결제 추가 처리
|
||||
private function setPayment_process(ServerPartEntity $entity): PaymentEntity
|
||||
{
|
||||
$formDatas = [];
|
||||
$formDatas['clientinfo_uid'] = $entity->getClientInfoUID();
|
||||
$formDatas['serviceinfo_uid'] = $entity->getServiceInfoUID();
|
||||
$formDatas['serverinfo_uid'] = $entity->getServerInfoUID();
|
||||
$formDatas['title'] = sprintf("부품정보 [%s]에 대한 일회성 추가", $entity->getPartEntity()->getTitle());
|
||||
$formDatas['amount'] = $entity->getAmount();
|
||||
$formDatas['billing'] = $entity->getBilling();
|
||||
$formDatas['billing_at'] = date("Y-m-d"); //일회성은 지급일이 당일기준처리
|
||||
return $this->getPaymentService()->create($formDatas);
|
||||
}
|
||||
|
||||
//부품연결정보생성
|
||||
public function create(array $formDatas): ServerPartEntity
|
||||
{
|
||||
@ -251,27 +209,20 @@ class ServerPartService extends EquipmentService
|
||||
$entity = parent::create($formDatas);
|
||||
//부품연결정보에 부품정보 정의
|
||||
$entity = $entity->setPartEntity(
|
||||
$this->setPart_process($entity, $formDatas['part_uid'], STATUS['OCCUPIED'])
|
||||
$this->setServerPart($entity, $formDatas['part_uid'], STATUS['OCCUPIED'])
|
||||
);
|
||||
//일회성인경우 결제정보에 추가한다.
|
||||
if ($entity->getBilling() === PAYMENT['BILLING']['ONETIME']) {
|
||||
$paymentEntity = $this->setPayment_process($entity);
|
||||
}
|
||||
$this->getPaymentService()->setServerPart($entity, 0, "");
|
||||
return $entity;
|
||||
}
|
||||
//수정
|
||||
public function modify(mixed $entity, array $formDatas): ServerPartEntity
|
||||
{
|
||||
//서버정보가져오기
|
||||
$serverEntity = null;
|
||||
if (array_key_exists('serverEntity', $formDatas)) {
|
||||
$serverEntity = $formDatas['serverEntity'];
|
||||
} else {
|
||||
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||
throw new \Exception("서버 정보가 지정되지 않았습니다.");
|
||||
}
|
||||
$serverEntity = $this->getServerService()->getEntity($formDatas['serverinfo_uid']);
|
||||
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||
throw new \Exception("서버 정보가 지정되지 않았습니다.");
|
||||
}
|
||||
$serverEntity = $this->getServerService()->getEntity($formDatas['serverinfo_uid']);
|
||||
if (!($serverEntity instanceof ServerEntity)) {
|
||||
throw new \Exception("서버 정보가 지정되지 않았습니다.");
|
||||
}
|
||||
@ -280,21 +231,20 @@ class ServerPartService extends EquipmentService
|
||||
$formDatas["serverinfo_uid"] = $serverEntity->getPK();
|
||||
//기존 Part_UID와 신규 Part_UID가 다르면 기존 Part정보 사용가능으로 변경
|
||||
if ($entity->getPartUID() != $formDatas['part_uid']) {
|
||||
$this->setPart_process($entity, $entity->getPartUID(), STATUS['AVAILABLE']);
|
||||
$this->setServerPart($entity, $entity->getPartUID(), STATUS['AVAILABLE']);
|
||||
}
|
||||
//기존 정보변경
|
||||
$entity = parent::modify($entity, $formDatas);
|
||||
//부품연결정보에 부품정보 정의
|
||||
return $entity->setPartEntity($this->setPart_process(
|
||||
$entity,
|
||||
$formDatas['part_uid'],
|
||||
STATUS['OCCUPIED']
|
||||
));
|
||||
return $entity->setPartEntity(
|
||||
$this->setServerPart($entity, $formDatas['part_uid'], STATUS['OCCUPIED'])
|
||||
);
|
||||
}
|
||||
//삭제
|
||||
public function delete(mixed $entity): ServerPartEntity
|
||||
{
|
||||
$this->setPart_process($entity, $entity->getPartUID(), STATUS['AVAILABLE']);
|
||||
//부품연결정보에 부품정보 정의
|
||||
$this->setServerPart($entity, $entity->getPartUID(), STATUS['AVAILABLE']);
|
||||
return parent::delete($entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,19 +121,28 @@ class ServerService extends EquipmentService
|
||||
throw new \Exception("Server코드[{$formDatas['code']}의 형식이 맞지않습니다");
|
||||
}
|
||||
}
|
||||
//Service별 수정
|
||||
//서비스 설정
|
||||
public function setService(ServiceEntity $serviceEntity, mixed $uid, string $status): ServerEntity
|
||||
{
|
||||
$entity = $this->getEntity($uid);
|
||||
if (!($entity instanceof ServerEntity)) {
|
||||
throw new \Exception("{$uid}에 해당하는 서버정보를 찾을수없습니다.");
|
||||
}
|
||||
$formDatas = [];
|
||||
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
|
||||
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
||||
$formDatas['status'] = $status;
|
||||
//서버정보 상태수정
|
||||
return $this->modify($entity, $formDatas);
|
||||
}
|
||||
// 수정
|
||||
public function modify(mixed $entity, array $formDatas): ServerEntity
|
||||
{
|
||||
//서비스정보가져오기
|
||||
$serviceEntity = null;
|
||||
if (array_key_exists('serviceEntity', $formDatas)) {
|
||||
$serviceEntity = $formDatas['serviceEntity'];
|
||||
} else {
|
||||
if (!array_key_exists('serviceinfo_uid', $formDatas)) {
|
||||
throw new \Exception("서비스 정보가 지정되지 않았습니다.");
|
||||
}
|
||||
$serviceEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']);
|
||||
if (!array_key_exists('serviceinfo_uid', $formDatas)) {
|
||||
throw new \Exception("서비스 정보가 지정되지 않았습니다.");
|
||||
}
|
||||
$serviceEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']);
|
||||
if ($serviceEntity instanceof ServiceEntity) {
|
||||
//서비스상태에 따라
|
||||
if ($formDatas['status'] === STATUS['AVAILABLE']) {
|
||||
|
||||
@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Entities\Equipment\SwitchEntity;
|
||||
use App\Helpers\Equipment\SwitchHelper;
|
||||
use App\Interfaces\Equipment\ServerPartInterface;
|
||||
use App\Models\Equipment\SwitchModel;
|
||||
use App\Services\Equipment\EquipmentService;
|
||||
|
||||
class SwitchService extends EquipmentService
|
||||
class SwitchService extends EquipmentService implements ServerPartInterface
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
@ -48,15 +50,27 @@ class SwitchService extends EquipmentService
|
||||
}
|
||||
//기본 기능부분
|
||||
//FieldForm관련용
|
||||
//상태변경
|
||||
public function setStatus(string $code, string $status): SwitchEntity
|
||||
//서비스파트 설정
|
||||
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): SwitchEntity
|
||||
{
|
||||
//code의 경우 사용가능/사용중으로 설정작업
|
||||
$entity = $this->getEntity($code);
|
||||
if (!$entity) {
|
||||
throw new \Exception("{$code}에 대한 Switch Port정보를 찾을수 없습니다.");
|
||||
$entity = $this->getEntity($uid);
|
||||
if (!($entity instanceof SwitchEntity)) {
|
||||
throw new \Exception("{$uid}에 해당하는 스위치정보를 찾을수없습니다.");
|
||||
}
|
||||
return $this->getModel()->modify($entity, ['status' => $status]);
|
||||
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
||||
$formDatas = [];
|
||||
if ($status === STATUS['AVAILABLE']) {
|
||||
//사용가능
|
||||
$formDatas['clientinfo_uid'] = null;
|
||||
$formDatas['serviceinfo_uid'] = null;
|
||||
$formDatas['serverinfo_uid'] = null;
|
||||
} else {
|
||||
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
||||
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
||||
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
||||
}
|
||||
$formDatas['status'] = $status;
|
||||
return $this->modify($entity, $formDatas);
|
||||
}
|
||||
//List 검색용
|
||||
//OrderBy 처리
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<?= form_close() ?>
|
||||
<?= view_cell("\App\Cells\Customer\ServiceCell::detail", ['userinfo_uid' => $viewDatas['entity']->getPK()]) ?>
|
||||
<?= view_cell("\App\Cells\Customer\ServiceCell::detail", ['clientinfo_uid' => $viewDatas['entity']->getPK()]) ?>
|
||||
</div>
|
||||
<!-- index_body -->
|
||||
</div>
|
||||
|
||||
@ -132,7 +132,7 @@
|
||||
<i class="fa fa-support fa-5x"></i>
|
||||
</div>
|
||||
<div class="col-8 text-end">
|
||||
<div class="huge"><?= $viewDatas['totalUnPaidCount'] ?></div>
|
||||
<div class="huge"><?= number_format($viewDatas['totalUnPaidCount']) ?>건/<?= number_format($viewDatas['totalUnPaidAmount']) ?>원</div>
|
||||
<div><?= date("Y-m-d") ?> 금일 기준 미납 서비스</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
</style>
|
||||
<?php foreach ($serviceCellDatas['entities'] as $entity): ?>
|
||||
<?php $serviceCellDatas['entity'] = $entity ?>
|
||||
<?php $unpaids = $serviceCellDatas['paymentService']->getUnPaids('serviceinfo_uid', ['serviceinfo_uid' => $entity->getPK()]) ?>
|
||||
<div class="rounded border border-gray p-2 mt-3">
|
||||
<table class="table table-bordered table-hover table-striped">
|
||||
<tr class="text-center">
|
||||
@ -59,7 +58,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="fw-bold">미납금</th>
|
||||
<td class="amount-red"><?= array_key_exists('amount', $unpaids) ? number_format($unpaids['amount']) : 0 ?>원</td>
|
||||
<td class="amount-red">총: <?= $serviceCellDatas['unPaids'][$entity->getPK()]['cnt'] ?>건,<?= number_format($serviceCellDatas['unPaids'][$entity->getPK()]['amount']) ?>원</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="text-center"><a href="/admin/customer/payment?clientinfo_uid=<?= $entity->getClientInfoUID() ?>"><button class="btn btn-success">결제내역</button></a></td>
|
||||
|
||||
@ -12,6 +12,6 @@
|
||||
<a href="/admin/customer/service"><?= ICONS['SERVICE'] ?> 서비스내역</a>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<a href="/admin/customer/payment?status=default"><?= ICONS['PAYMENT'] ?> 결제내역</a>
|
||||
<a href="/admin/customer/payment?status=<?= STATUS['UNPAID'] ?>"><?= ICONS['PAYMENT'] ?> 결제내역</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -11,7 +11,7 @@
|
||||
<span class="nav-link active" aria-current="page" style="cursor:pointer;"><a href="/admin/customer/service">서비스현황</a></span>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<span class="nav-link active" aria-current="page" style="cursor:pointer;"><a href="/admin/customer/payment">결제현황</a></span>
|
||||
<span class="nav-link active" aria-current="page" style="cursor:pointer;"><a href="/admin/customer/payment?status=<?= STATUS['UNPAID'] ?>">결제현황</a></span>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<span class="nav-link active" aria-current="page" style="cursor:pointer;"><a href="/admin/equipment/server">서버현황</a></span>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user