dbmsv3 init...1

This commit is contained in:
choi.jh 2025-10-13 10:41:05 +09:00
parent 9f42710724
commit ead109480b
9 changed files with 89 additions and 47 deletions

View File

@ -291,6 +291,7 @@ class CommonHelper
case 'end_at': case 'end_at':
case 'updated_at': case 'updated_at':
case 'created_at': case 'created_at':
case 'deleted_at':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender';
$form = form_input($field, $value ?? "", $extras); $form = form_input($field, $value ?? "", $extras);
break; break;

View File

@ -2,4 +2,4 @@
namespace App\Interfaces\Customer; namespace App\Interfaces\Customer;
interface CustomerInterFace {} interface CustomerInterface {}

View File

@ -22,8 +22,9 @@ return [
PAYMENT['BILLING']['ONETIME'] => "일회성", PAYMENT['BILLING']['ONETIME'] => "일회성",
], ],
"PAY" => [ "PAY" => [
"account" => "예치금", PAYMENT['PAY']['ACCOUNT'] => "예치금",
"coupon" => "쿠폰", PAYMENT['PAY']['COUPON'] => "쿠폰",
PAYMENT['PAY']['POINT'] => "포인트",
], ],
"STATUS" => [ "STATUS" => [
STATUS['UNPAID'] => "미지급", STATUS['UNPAID'] => "미지급",

View File

@ -5,7 +5,7 @@ namespace App\Libraries\DBMigration\Process;
use App\Entities\Part\SWITCHEntity; use App\Entities\Part\SWITCHEntity;
use CodeIgniter\Database\BaseConnection; use CodeIgniter\Database\BaseConnection;
class SWITCHCodeProcess implements MigrationProcessInterface class SwitchCodeProcess implements MigrationProcessInterface
{ {
private $db; private $db;
public function __construct(BaseConnection $db) public function __construct(BaseConnection $db)

View File

@ -56,6 +56,9 @@ class AccountService extends CustomerService
if (!$entity instanceof ClientEntity) { if (!$entity instanceof ClientEntity) {
throw new \Exception("{$formDatas['clientinfo_uid']}에 대한 고객정보를 찾을수 없습니다."); throw new \Exception("{$formDatas['clientinfo_uid']}에 대한 고객정보를 찾을수 없습니다.");
} }
if (!array_key_exists('amount', $formDatas) || !array_key_exists('status', $formDatas)) {
throw new \Exception("입출금처리를 위한 금액과 상태값이 필요합니다.");
}
$amount = intval($formDatas['amount']); $amount = intval($formDatas['amount']);
if ($formDatas['status'] === AccountEntity::DEFAULT_STATUS) { //입금, 쿠폰추가 if ($formDatas['status'] === AccountEntity::DEFAULT_STATUS) { //입금, 쿠폰추가
$entity = $this->getClientService()->deposit($entity, 'account_balance', $amount); $entity = $this->getClientService()->deposit($entity, 'account_balance', $amount);

View File

@ -110,10 +110,9 @@ class ClientService extends CustomerService
break; break;
default: default:
throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다."); throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다.");
// break;
} }
$formDatas = [$field => $amount]; return parent::modify($entity, [$field => $amount]);
// dd($formDatas);
return parent::modify($entity, $formDatas);
} }
//출금(쿠폰:사용)처리 //출금(쿠폰:사용)처리
final public function withdrawal(ClientEntity $entity, string $field, int $amount): ClientEntity final public function withdrawal(ClientEntity $entity, string $field, int $amount): ClientEntity
@ -141,8 +140,7 @@ class ClientService extends CustomerService
throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다."); throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다.");
// break; // break;
} }
$formDatas = [$field => $amount]; return parent::modify($entity, [$field => $amount]);
return parent::modify($entity, $formDatas);
} }
//기본 기능부분 //기본 기능부분
//생성 //생성

View File

@ -2,6 +2,7 @@
namespace App\Services; namespace App\Services;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\ServiceEntity; use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerPartEntity; use App\Entities\Equipment\ServerPartEntity;
use App\Entities\PaymentEntity; use App\Entities\PaymentEntity;
@ -10,6 +11,7 @@ use App\Interfaces\Customer\ServiceInterface;
use App\Interfaces\Equipment\ServerPartInterface; use App\Interfaces\Equipment\ServerPartInterface;
use App\Models\PaymentModel; use App\Models\PaymentModel;
use App\Services\CommonService; use App\Services\CommonService;
use App\Services\Customer\AccountService;
use App\Services\Customer\ClientService; use App\Services\Customer\ClientService;
use App\Services\Customer\ServiceService; use App\Services\Customer\ServiceService;
use App\Services\Equipment\ServerPartService; use App\Services\Equipment\ServerPartService;
@ -103,7 +105,6 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa
} }
return $this->_serverPartService; return $this->_serverPartService;
} }
//총 미납건수, 금액 //총 미납건수, 금액
final public function getUnPaids(string $group, array $where = []): array final public function getUnPaids(string $group, array $where = []): array
{ {
@ -219,6 +220,40 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID(); $formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
return parent::create($formDatas); return parent::create($formDatas);
} }
//일괄처리작업(결제작업)
public function batchjob(mixed $entity, array $formDatas): mixed
{
//고객정보
$userEntity = $this->getClientService()->getEntity($entity->getClientInfoUID());
if (!$userEntity instanceof ClientEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 고객정보[{$entity->getClientInfoUID()}]를 찾을수 없습니다.");
}
if (!array_key_exists('pay', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 결제상태(pay) 정보가 없습니다.");
}
switch ($formDatas['pay']) {
case PAYMENT['PAY']['ACCOUNT']:
//예치금 출금처리
if ($userEntity->getAccountBalance() < $entity->getAmount()) {
throw new \Exception(__METHOD__ . "에서 오류발생: 고객[{$userEntity->getName()}]의 예치금이 부족합니다.({$userEntity->getAccountBalance()} < {$entity->getAmount()})");
}
break;
case PAYMENT['PAY']['COUPON']:
//쿠폰 출금처리
if ($userEntity->getCouponBalance() < 1) {
throw new \Exception(__METHOD__ . "에서 오류발생: 고객[{$userEntity->getName()}]의 쿠폰이 부족합니다.({$userEntity->getCouponBalance()} < 1)");
}
break;
case PAYMENT['PAY']['POINT']:
break;
default:
throw new \Exception(__METHOD__ . "에서 오류발생: 알수없는 결제방법(pay)입니다.");
// break;
}
//결제처리완료
$entity = parent::batchjob($entity, $formDatas);
return $entity;
}
//List 검색용 //List 검색용
//OrderBy 처리 //OrderBy 처리
final public function setOrderBy(mixed $field = null, mixed $value = null): void final public function setOrderBy(mixed $field = null, mixed $value = null): void

View File

@ -80,7 +80,7 @@
<td nowrap> <td nowrap>
<?= $viewDatas['service']->getHelper()->getFieldView('ip', $entity->ip, $viewDatas) ?> <?= $viewDatas['service']->getHelper()->getFieldView('ip', $entity->ip, $viewDatas) ?>
</td> </td>
<td nowrap> <td>
<?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [ <?= view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $entity->getPK(), 'serverinfo_uid' => $entity->getPK(),
'types' => SERVERPART['SERVER_PARTTYPES'], 'types' => SERVERPART['SERVER_PARTTYPES'],

View File

@ -1,49 +1,53 @@
/** // /public/js/admin/form.js
* 공용 초기화 함수 window.initFormModal = function (context) {
* @param {HTMLElement} context - 초기화 대상 (없으면 document 전체) const $context = context ? $(context) : $(document);
*/
function initFormJS(context) {
const root = context || document;
// Datepicker // ✅ 캘린더
if (root.querySelector(".calender")) { $context.find(".calender").datepicker({
$(root).find(".calender").datepicker({ changeYear: true,
changeYear: true, changeMonth: true,
changeMonth: true, yearRange: "-10:+0",
yearRange: "-10:+0", dateFormat: "yy-mm-dd"
dateFormat: "yy-mm-dd" });
});
}
// TinyMCE // ✅ TinyMCE
if (root.querySelector(".tinymce")) { if ($context.find(".tinymce").length) {
if (document.compatMode !== "CSS1Compat") { if (typeof tinymce !== "undefined") {
console.error("문서가 표준 모드가 아닙니다."); tinymce.remove(); // 기존 인스턴스 제거
return; tinymce.init({
selector: ".tinymce",
license_key: "gpl",
height: 250,
plugins: "advlist autolink lists link image charmap preview anchor",
toolbar: "undo redo | bold italic underline | align | link image | code fullscreen preview",
menubar: "file edit view insert format tools table help"
});
} }
tinymce.init({
selector: 'textarea.tinymce',
license_key: 'gpl',
height: 250,
plugins: 'advlist autolink lists link image charmap preview anchor',
toolbar: 'undo redo blocks fontfamily fontsize forecolor backcolor | ' +
'bold italic underline strikethrough | align numlist bullist | ' +
'link image | table media | code fullscreen preview',
menubar: 'file edit view insert format tools table help'
});
} }
// Select2 // ✅ Select2 (입력 허용)
if (root.querySelector(".select-field")) { if ($context.find(".select-field").length) {
$(root).find(".select-field").select2({ $context.find(".select-field").select2({
theme: "bootstrap-5", theme: "bootstrap-5",
tags: true, // 없는 값 입력 가능 tags: true,
allowClear: true, allowClear: true,
language: { language: {
noResults: function () { noResults: function () {
return "직접 입력 후 Enter"; return "직접 입력 후 Enter"; // 사용자 안내
} }
} }
}); });
} }
}
console.log("✅ Form initialized inside modal:", context);
};
// ✅ DOM 전체 로드 후 (페이지 최초 로드시 실행)
document.addEventListener("DOMContentLoaded", function () {
window.initFormModal(document);
});
// ✅ Modal 로드 시점에 재초기화
$(document).on("shown.bs.modal", ".modal", function (e) {
window.initFormModal(this);
});