dbms_init...1

This commit is contained in:
choi.jh 2025-06-20 11:10:39 +09:00
parent d9869afa24
commit 1d33896294
11 changed files with 194 additions and 16 deletions

View File

@ -225,7 +225,12 @@ abstract class CommonController extends BaseController
{
LogCollector::debug($message);
$this->getMyLogService()->save($this->getService(), __FUNCTION__, $this->getMyAuth(), $message);
return redirect()->back()->withInput()->with('error', $message);
// echo $this->request->getMethod();
// exit;
if ($this->request->getMethod() === 'POST') {
return redirect()->back()->withInput()->with('error', $message);
}
return redirect()->to($this->getMyAuth()->popPreviousUrl())->with('error', $message);
}
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{
@ -265,6 +270,7 @@ abstract class CommonController extends BaseController
{
try {
//각 Field 초기화
// $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
$this->initAction(__FUNCTION__);
//FieldRule정의
foreach ($this->getFormFields() as $field) {
@ -324,6 +330,7 @@ abstract class CommonController extends BaseController
{
try {
//각 Field 초기화
// $this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
$this->initAction(__FUNCTION__);
//FieldRule정의
foreach ($this->getFormFields() as $field) {
@ -670,13 +677,13 @@ abstract class CommonController extends BaseController
{
try {
//각 Field 초기화
$this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
$this->initAction(__FUNCTION__);
//FieldRule정의
foreach ($this->getIndexFields() as $field) {
$this->setFieldRule($field, $this->getFormFieldRule($this->getAction(), $field));
}
// 현재 URL을 스택에 저장
$this->getMyAuth()->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
helper(['form']);
$this->entities = $this->index_process();
return $this->getResultSuccess();

View File

@ -13,4 +13,37 @@ class AccountHelper extends CustomerHelper
parent::__construct($request);
$this->setTitleField(AccountModel::TITLE);
}
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
{
switch ($field) {
case 'amount':
$value = number_format($value) . "";
break;
default:
if (in_array($field, $viewDatas['control']['filter_fields'])) {
$value = $viewDatas['control']['filter_optons'][$field][$value]->getTitle();
}
break;
}
if (is_array($value)) {
echo __METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다";
exit;
}
return $value;
}
public function getListButton(string $action, array $viewDatas, array $extras = []): string
{
switch ($action) {
case 'modify':
$action = $viewDatas['entity']->getPK();
break;
case 'delete':
$action = "";
break;
default:
$action = parent::getListButton($action, $viewDatas, $extras);
break;
}
return $action;
}
}

View File

@ -13,4 +13,37 @@ class CouponHelper extends CustomerHelper
parent::__construct($request);
$this->setTitleField(CouponModel::TITLE);
}
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
{
switch ($field) {
case 'amount':
$value = number_format($value) . "";
break;
default:
if (in_array($field, $viewDatas['control']['filter_fields'])) {
$value = $viewDatas['control']['filter_optons'][$field][$value]->getTitle();
}
break;
}
if (is_array($value)) {
echo __METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다";
exit;
}
return $value;
}
public function getListButton(string $action, array $viewDatas, array $extras = []): string
{
switch ($action) {
case 'modify':
$action = $viewDatas['entity']->getPK();
break;
case 'delete':
$action = "";
break;
default:
$action = parent::getListButton($action, $viewDatas, $extras);
break;
}
return $action;
}
}

View File

@ -13,4 +13,38 @@ class PointHelper extends CustomerHelper
parent::__construct($request);
$this->setTitleField(field: PointModel::TITLE);
}
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
{
switch ($field) {
case 'amount':
$value = number_format($value) . "";
break;
default:
if (in_array($field, $viewDatas['control']['filter_fields'])) {
$value = $viewDatas['control']['filter_optons'][$field][$value]->getTitle();
}
break;
}
if (is_array($value)) {
echo __METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다";
exit;
}
return $value;
}
public function getListButton(string $action, array $viewDatas, array $extras = []): string
{
switch ($action) {
case 'modify':
$action = $viewDatas['entity']->getPK();
break;
case 'delete':
$action = "";
break;
default:
$action = parent::getListButton($action, $viewDatas, $extras);
break;
}
return $action;
}
}

View File

@ -42,7 +42,7 @@ class AccountService extends CustomerService
//기본 기능부분
//고객예치금처리
private function setBalance(array $formDatas): ClientEntity
private function setBalance(array $formDatas): void
{
//account_balance 체크
$entity = $this->getClientService()->getEntity($formDatas['clientinfo_uid']);
@ -50,12 +50,12 @@ class AccountService extends CustomerService
throw new \Exception("{$formDatas['clientinfo_uid']}에 대한 고객정보를 찾을수 없습니다.");
}
$amount = intval($formDatas['amount']);
// dd($formDatas);
if ($formDatas['status'] === DEFAULTS['STATUS']) { //입금, 쿠폰추가
$entity = $this->getClientService()->deposit($entity, 'account_balance', $amount);
} else { // 출금, 쿠폰사용
$entity = $this->getClientService()->withdrawal($entity, 'account_balance', $amount);
}
return $entity;
}
public function create(array $formDatas, mixed $entity = null): AccountEntity
{

View File

@ -41,18 +41,60 @@ class ClientService extends CustomerService
//압금(쿠폰:추가)처리
public function deposit(ClientEntity $entity, string $field, int $amount): ClientEntity
{
if ($amount < 0) {
throw new \Exception("입금액 , 쿠폰 추가갯수가 0보다 작습니다.");
switch ($field) {
case 'account_balance':
if ($amount < 0) {
throw new \Exception("입금액이 0보다 작습니다.");
}
$amount += $entity->getAccountBalance();
break;
case 'coupon_balance':
if ($amount < 0) {
throw new \Exception("쿠폰 추가갯수가 0보다 작습니다.");
}
$amount += $entity->getCouponBalance();
break;
case 'point_balance':
if ($amount < 0) {
throw new \Exception("포인트 입금액 0보다 작습니다.");
}
$amount += $entity->getPointBalance();
break;
default:
throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다.");
}
return $this->getClientService()->modify($entity, [$field => $entity->getAccountBalance() + $amount]);
$formDatas = [$field => $amount];
// dd($formDatas);
return $this->getClientService()->modify($entity, $formDatas);
}
//출금(쿠폰:사용)처리
public function withdrawal(ClientEntity $entity, string $field, int $amount): ClientEntity
{
if ($entity->getAccountBalance() < $amount) {
throw new \Exception("잔여액,잔여 쿠폰갯수:{$entity->getAccountBalance()} < 출금액 , 사용쿠폰갯수: {$amount}보다 작습니다.");
switch ($field) {
case 'account_balance':
if ($entity->getAccountBalance() < $amount) {
throw new \Exception("예치금[{$entity->getAccountBalance()}]이 출금액:{$amount}보다 부족합니다.");
}
$amount = $entity->getAccountBalance() - $amount;
break;
case 'coupon_balance':
if ($entity->getCouponBalance() < $amount) {
throw new \Exception("쿠폰[{$entity->getCouponBalance()}]이 사용수:{$amount}보다 부족합니다.");
}
$amount = $entity->getCouponBalance() - $amount;
break;
case 'point_balance':
if ($entity->getPointBalance() < $amount) {
throw new \Exception("포인트금액[{$entity->getPointBalance()}]이 출금액:{$amount}보다 부족합니다.");
}
$amount = $entity->getPointBalance() - $amount;
break;
default:
throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다.");
// break;
}
return $this->getClientService()->modify($entity, [$field => $entity->getAccountBalance() - $amount]);
$formDatas = [$field => $amount];
return $this->getClientService()->modify($entity, $formDatas);
}
public function create(array $formDatas, mixed $entity = new ClientEntity()): ClientEntity

View File

@ -41,7 +41,7 @@ class CouponService extends CustomerService
//기본 기능부분
//고객예치금처리
private function setBalance(array $formDatas): ClientEntity
private function setBalance(array $formDatas): void
{
//coupon_balance 체크
$entity = $this->getClientService()->getEntity($formDatas['clientinfo_uid']);
@ -54,7 +54,6 @@ class CouponService extends CustomerService
} else { // 출금, 쿠폰사용
$entity = $this->getClientService()->withdrawal($entity, 'coupon_balance', $amount);
}
return $entity;
}
public function create(array $formDatas, mixed $entity = null): CouponEntity
{

View File

@ -40,7 +40,7 @@ class PointService extends CustomerService
}
//기본 기능부분
private function setBalance(array $formDatas): ClientEntity
private function setBalance(array $formDatas): void
{
//point_balance 체크
$entity = $this->getClientService()->getEntity($formDatas['clientinfo_uid']);
@ -53,7 +53,6 @@ class PointService extends CustomerService
} else { // 출금, 쿠폰사용
$entity = $this->getClientService()->withdrawal($entity, 'point_balance', $amount);
}
return $entity;
}
public function create(array $formDatas, mixed $entity = null): PointEntity
{

View File

@ -18,7 +18,7 @@
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? isset($viewDatas[$field]) ? $viewDatas[$field] : null, $viewDatas) ?>
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? array_key_exists($field, $viewDatas) ? $viewDatas[$field] : null, $viewDatas) ?>
<span><?= validation_show_error($field); ?></span>
</td>
</tr>

View File

@ -18,7 +18,7 @@
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? isset($viewDatas[$field]) ? $viewDatas[$field] : null, $viewDatas) ?>
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? array_key_exists($field, $viewDatas) ? $viewDatas[$field] : null, $viewDatas) ?>
<span><?= validation_show_error($field); ?></span>
</td>
</tr>

View File

@ -0,0 +1,31 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<?php if ($error = session('error')): echo $viewDatas['helper']->alert($error) ?><?php endif ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/js/<?= $viewDatas['layout'] ?>/form.js" referrerpolicy="origin"></script>
<script src="/assets/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
<?php foreach ($viewDatas['individualStylesheets'] as $css): ?>
<link href="/css/<?= $viewDatas['layout'] ?>/<?= $css ?>" media="screen" rel="stylesheet" type="text/css" />
<?php endforeach ?>
<?php foreach ($viewDatas['individualScripts'] as $js): ?>
<script src="/js/<?= $viewDatas['layout'] ?>/<?= $js ?>" referrerpolicy="origin"></script>
<?php endforeach ?>
<?= form_open(current_url(), ['id' => 'action_form', ...$viewDatas['forms']['attributes']], $viewDatas['forms']['hiddens']) ?>
<div class="action_form">
<table class="table table-bordered">
<?php foreach ($viewDatas['control']['form_fields'] as $field): ?>
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? $viewDatas['entity']->$field, $viewDatas) ?>
<div><?= validation_show_error($field); ?></div>
</td>
</tr>
<?php endforeach; ?>
</table>
<div class="text-center"><?= form_submit("", '수정', ["class" => "btn btn-outline btn-primary"]) ?></div>
<?= form_close(); ?>
</div>
</div>
<?= $this->endSection() ?>