dbmsv4 init...2

This commit is contained in:
최준흠 2025-12-08 16:51:22 +09:00
parent 191f20418c
commit 6b40f17e1d
12 changed files with 142 additions and 46 deletions

View File

@ -18,7 +18,7 @@ class PaymentCell extends CommonCell
$entities = $this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid'], 'billing' => PAYMENT['BILLING']['ONETIME'], 'status' => STATUS['UNPAID']]); $entities = $this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid'], 'billing' => PAYMENT['BILLING']['ONETIME'], 'status' => STATUS['UNPAID']]);
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__; $template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
return view('cells/payment/' . $template, [ return view('cells/payment/' . $template, [
'serviceCellDatas' => [ 'paymentCellDatas' => [
'formFilters' => $this->getService()->getFormService()->getFormFilters(), 'formFilters' => $this->getService()->getFormService()->getFormFilters(),
'formOptions' => $this->getService()->getFormService()->getFormOptions(), 'formOptions' => $this->getService()->getFormService()->getFormOptions(),
'helper' => $this->getService()->getHelper(), 'helper' => $this->getService()->getHelper(),

View File

@ -416,6 +416,16 @@ define("SITES", [
"itsolution" => "ITSOLUTION", "itsolution" => "ITSOLUTION",
"gdidc" => "GDIDC", "gdidc" => "GDIDC",
]); ]);
//사이트별 은행관련
define(
"BANKS",
[
'국민은행' => "국민은행",
"하나은행" => "하나은행",
"신한은행" => "신한은행",
"농협" => "농협",
],
);
//서비스 관련 //서비스 관련
define("SERVICE", [ define("SERVICE", [
"NEW_INTERVAL" => $_ENV['SERVICE_NEW_INTERVAL'] ?? $_SERVER['SERVICE_NEW_INTERVAL'] ?? 7, "NEW_INTERVAL" => $_ENV['SERVICE_NEW_INTERVAL'] ?? $_SERVER['SERVICE_NEW_INTERVAL'] ?? 7,

View File

@ -96,4 +96,16 @@ class PaymentController extends AdminController
return $this->action_redirect_process('error', "{$this->getTitle()}에서 청구서발행 오류:" . $e->getMessage()); return $this->action_redirect_process('error', "{$this->getTitle()}에서 청구서발행 오류:" . $e->getMessage());
} }
} }
public function paid($uid): string|RedirectResponse
{
try {
$entity = $this->service->paid($uid);
$action = __FUNCTION__;
//FormService에서 필요한 기존 데이터를 $entity에서 추출해서 넘김
$this->action_init_process($action, $entity->toArray());
return $this->modify_form_result_process($action);
} catch (\Throwable $e) {
return $this->action_redirect_process('error', "{$this->getTitle()}에서 수정폼 오류:" . $e->getMessage());
}
}
} }

File diff suppressed because one or more lines are too long

View File

@ -74,6 +74,9 @@ class PaymentHelper extends CommonHelper
"class" => "btn btn-outline btn-warning", "class" => "btn btn-outline btn-warning",
]); ]);
break; break;
case 'onetime_paid':
$action = "<a href=\"/admin/payment/paid/{$viewDatas['entity']->getPK()}\">{$label}</a>";
break;
default: default:
$action = parent::getListButton($action, $label, $viewDatas, $extras); $action = parent::getListButton($action, $label, $viewDatas, $extras);
break; break;

View File

@ -15,15 +15,9 @@ return [
'created_at' => "작성일", 'created_at' => "작성일",
'deleted_at' => "삭제일", 'deleted_at' => "삭제일",
], ],
"BANK" => [ "BANK" => [...BANKS, '결제차감' => '결제차감'],
'국민은행' => "국민은행",
"하나은행" => "하나은행",
"신한은행" => "신한은행",
"농협" => "농협",
],
"STATUS" => [ "STATUS" => [
STATUS['DEPOSIT'] => "입금", STATUS['DEPOSIT'] => "입금",
STATUS['WITHDRAWAL'] => "출금", STATUS['WITHDRAWAL'] => "출금",
STATUS['PAID'] => "결제",
], ],
]; ];

View File

@ -2,13 +2,14 @@
namespace App\Services\Customer; namespace App\Services\Customer;
use RuntimeException;
use App\Models\Customer\AccountModel;
use App\Helpers\Customer\AccountHelper;
use App\Forms\Customer\AccountForm;
use App\Entities\Customer\AccountEntity;
use App\Entities\CommonEntity;
use App\DTOs\Customer\AccountDTO; use App\DTOs\Customer\AccountDTO;
use App\Entities\CommonEntity;
use App\Entities\Customer\AccountEntity;
use App\Entities\PaymentEntity;
use App\Forms\Customer\AccountForm;
use App\Helpers\Customer\AccountHelper;
use App\Models\Customer\AccountModel;
use RuntimeException;
class AccountService extends CustomerService class AccountService extends CustomerService
{ {
@ -118,7 +119,7 @@ class AccountService extends CustomerService
protected function create_process(array $formDatas): AccountEntity protected function create_process(array $formDatas): AccountEntity
{ {
$entity = parent::create_process($formDatas); $entity = parent::create_process($formDatas);
service('customer_clientservice')->updateBalance($entity->getClientInfoUID(), 'account_balance', $entity->getAmount()); service('customer_clientservice')->updateBalance($entity->getClientInfoUID(), "예치금", PAYMENT['PAY']['ACCOUNT'], $entity->getAmount(), $entity->getStatus());
return $entity; return $entity;
} }
protected function modify_process($entity, array $formDatas): AccountEntity protected function modify_process($entity, array $formDatas): AccountEntity

View File

@ -110,14 +110,52 @@ class ClientService extends CustomerService
$this->getFormService()->setIndexFilters($indexFilter); $this->getFormService()->setIndexFilters($indexFilter);
$this->getFormService()->setBatchjobFilters($batchjobFilters); $this->getFormService()->setBatchjobFilters($batchjobFilters);
} }
final public function updateBalance(int|ClientEntity $uid, string $field, int $value): ClientEntity final public function updateBalance(int|ClientEntity $uid, string $title, string $key, int $value, string $status): ClientEntity
{ {
$entity = is_int($uid) ? $this->getEntity($uid) : $uid; $entity = is_int($uid) ? $this->getEntity($uid) : $uid;
if (!$entity instanceof ClientEntity) { if (!$entity instanceof ClientEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생: {$uid}에 해당하는 서비스정보를 찾을수 없습니다."); throw new RuntimeException(__METHOD__ . "에서 오류발생: {$uid}에 해당하는 서비스정보를 찾을수 없습니다.");
} }
//총 서비스금액 설정
$formDatas = [$field => $value]; $calculatedValue = null;
$balance = 0;
$title = "";
switch ($key) {
case PAYMENT['PAY']['ACCOUNT']:
$balance = $entity->getAccountBalance();
break;
case PAYMENT['PAY']['COUPON']:
$balance = $entity->getCouponBalance();
$title = "쿠폰";
break;
case PAYMENT['PAY']['POINT']:
$balance = $entity->getPointBalance();
$title = "포인트";
break;
}
//입금,추가 처리
if ($status === STATUS['DEPOSIT']) {
$calculatedValue = $balance - $value;
}
//출금,사용 처리
if ($status === STATUS['WITHDRAWAL']) {
if ($balance < $value) {
throw new RuntimeException(sprintf(
"%s 에서 오류발생: 고객 %s[%s]이/가 사용한 %s 금액/수[%s] 보다 작습니다.",
__METHOD__,
$title,
number_format($balance),
$title,
number_format($value)
));
}
$calculatedValue = $balance - $value;
}
if (!is_int($calculatedValue) || $calculatedValue < 0) {
throw new RuntimeException(__METHOD__ . "에서 {$title}의 계산결과 값이 NULL이거나 0보다 작은 값입니다.");
}
//balance 수정
$formDatas = ["{$key}_balance" => $calculatedValue, 'status' => $status];
$fields = array_keys($formDatas); $fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields); $this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields); $this->getFormService()->setFormRules('modify', $fields);

View File

@ -108,7 +108,7 @@ class CouponService extends CustomerService
protected function create_process(array $formDatas): CouponEntity protected function create_process(array $formDatas): CouponEntity
{ {
$entity = parent::create_process($formDatas); $entity = parent::create_process($formDatas);
service('customer_clientservice')->updateBalance($entity->getClientInfoUID(), 'coupon_balance', $entity->getCnt()); service('customer_clientservice')->updateBalance($entity->getClientInfoUID(), "쿠폰", PAYMENT['PAY']['COUPON'], $entity->getCnt(), $entity->getStatus());
return $entity; return $entity;
} }
protected function modify_process($entity, array $formDatas): CouponEntity protected function modify_process($entity, array $formDatas): CouponEntity

View File

@ -109,7 +109,7 @@ class PointService extends CustomerService
protected function create_process(array $formDatas): PointEntity protected function create_process(array $formDatas): PointEntity
{ {
$entity = parent::create_process($formDatas); $entity = parent::create_process($formDatas);
service('customer_clientservice')->updateBalance($entity->getClientInfoUID(), 'point_balance', $entity->getAmount()); service('customer_clientservice')->updateBalance($entity->getClientInfoUID(), "포인트", PAYMENT['PAY']['POINT'], $entity->getAmount(), $entity->getStatus());
return $entity; return $entity;
} }
protected function modify_process($entity, array $formDatas): PointEntity protected function modify_process($entity, array $formDatas): PointEntity

View File

@ -221,7 +221,6 @@ class PaymentService extends CommonService
if (!array_key_exists($serviceEntity->getPK(), $rows[$clientEntity->getPK()]['services'])) { if (!array_key_exists($serviceEntity->getPK(), $rows[$clientEntity->getPK()]['services'])) {
$serverEntity = service('equipment_serverservice')->getEntity($serviceEntity->getServerInfoUID()); $serverEntity = service('equipment_serverservice')->getEntity($serviceEntity->getServerInfoUID());
if (!$serverEntity instanceof ServerEntity) { if (!$serverEntity instanceof ServerEntity) {
dd($serverEntity);
throw new \Exception(__METHOD__ . "에서 오류발생:[{$serviceEntity->getServerInfoUID()}]에 대한 서버정보를 찾을 수 없습니다."); throw new \Exception(__METHOD__ . "에서 오류발생:[{$serviceEntity->getServerInfoUID()}]에 대한 서버정보를 찾을 수 없습니다.");
} }
$rows[$clientEntity->getPK()]['services'][$serviceEntity->getPK()] = [ $rows[$clientEntity->getPK()]['services'][$serviceEntity->getPK()] = [
@ -242,14 +241,44 @@ class PaymentService extends CommonService
} }
//지불 관련 //지불 관련
public function setPaid(PaymentEntity $entity, array $formDatas): PaymentEntity private function paid_process(PaymentEntity $entity): PaymentEntity
{ {
//pay방식에따른 고객 정보 처리
$formDatas = [
'clientinfo_uid' => $entity->getClientInfoUID(),
'bank' => '결제차감',
'title' => $entity->getTitle(),
'alias' => '결제차감',
'issue_at' => date('Y-m-d'),
'amount' => $entity->getAmount(),
'status' => STATUS['WITHDRAWAL'],
];
switch ($entity->getPay()) {
case PAYMENT['PAY']['ACCOUNT']:
service('customer_accountservice')->create($formDatas);
break;
case PAYMENT['PAY']['COUPON']:
service('customer_couponservice')->create($formDatas);
break;
case PAYMENT['PAY']['POINT']:
service('customer_pointservice')->create($formDatas);
break;
default:
throw new RuntimeException(__METHOD__ . "에서 오류발생: {$entity->getPay()}는 지정되지 않은 지불방식입니다.");
// break;
}
return $entity;
}
public function paid($uid): PaymentEntity
{
$entity = $this->getEntity($uid);
if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생:[{$uid}]에 대한 결제정보를 찾을 수 없습니다.");
}
//결제 완료 처리 후 추가정보 처리 //결제 완료 처리 후 추가정보 처리
$formDatas['status'] = STATUS['PAID']; $formDatas['status'] = STATUS['PAID'];
$entity = parent::modify_process($entity, $formDatas); $entity = parent::modify_process($entity, $formDatas);
//pay방식에따른 고객 정보 처리 return $this->paid_process($entity);
service('customer_client')->setBalance($entity);
return $entity;
} }
//서비스관련 //서비스관련

View File

@ -2,29 +2,38 @@
<div style="font-size:15px">미지급 1회성정보</div> <div style="font-size:15px">미지급 1회성정보</div>
<table class="table table-bordered table-hover table-striped"> <table class="table table-bordered table-hover table-striped">
<tr class="text-center"> <tr class="text-center">
<th style="width: 10px"></th>
<th style="width: 250px">서비스</th> <th style="width: 250px">서비스</th>
<th style="width: 120px">날자</th> <th>항목</th>
<th style="width: 120px">결제금액</th> <th style="width: 120px">결제금액</th>
<th style="width: 250px">항목</th> <th style="width: 100px">청구방식</th>
<th style="width: 250px">청구방식</th> <th style="width: 100px">지불방법</th>
<th style="width: 250px">지불방법</th> <th style="width: 100px">결제처리</th>
<th style="width: 250px">관리자</th> <th style="width: 170px">등록일</th>
<th style="width: 250px">결제처리</th> <th style="width: 100px">관리자</th>
</tr> </tr>
<?php foreach ($serviceCellDatas['entities'] as $entity): ?> <?php $cnt = count(value: $paymentCellDatas['entities']) ?>
<?php $serviceCellDatas['entity'] = $entity ?> <?php foreach ($paymentCellDatas['entities'] as $entity): ?>
<?php $paymentCellDatas['entity'] = $entity ?>
<tr class="text-left"> <tr class="text-left">
<td class="text-center"><?= $serviceCellDatas['helper']->getFieldView('serviceinfo_uid', $entity->getServiceInfoUID(), $serviceCellDatas) ?></td> <td><?= $cnt ?></td>
<td class="text-center"><?= $serviceCellDatas['helper']->getFieldView('create_at', $entity->getCreatedAt(), $serviceCellDatas) ?></td> <td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('serviceinfo_uid', $entity->getServiceInfoUID(), $paymentCellDatas) ?></td>
<td class="text-center"><?= $serviceCellDatas['helper']->getFieldView('amount', $entity->getAmount(), $serviceCellDatas) ?></td> <td class="text-center">
<td class="text-center"><?= $serviceCellDatas['helper']->getFieldView('title', $entity->getTitle(), $serviceCellDatas) ?></td> <?= $paymentCellDatas['helper']->getFieldView('title', $entity->getTitle(), $paymentCellDatas) ?>
<td class="text-center"><?= $serviceCellDatas['helper']->getFieldView('billing', $entity->getBilling(), $serviceCellDatas) ?></td> <div><?= $paymentCellDatas['helper']->getFieldView('content', $entity->getContent(), $paymentCellDatas) ?></div>
<td class="text-center"><?= $serviceCellDatas['helper']->getFieldView('pay', $entity->getPay(), $serviceCellDatas) ?></td> </td>
<td class="text-center"><?= $serviceCellDatas['helper']->getFieldView('user_uid', $entity->getUserUID(), $serviceCellDatas) ?></td> <td class="text-end"><?= $paymentCellDatas['helper']->getFieldView('amount', $entity->getAmount(), $paymentCellDatas) ?></td>
</tr> <td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('billing', $entity->getBilling(), $paymentCellDatas) ?></td>
<tr> <td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('pay', $entity->getPay(), $paymentCellDatas) ?></td>
<td class="text-start" colspan="8"><?= $serviceCellDatas['helper']->getFieldView('content', $entity->getTitle(), $serviceCellDatas) ?></td> <td class="text-center"><?= $paymentCellDatas['helper']->getListButton(
'onetime_paid',
$serverCellDatas['helper']->getFieldView('status', $entity->getStatus(), $paymentCellDatas),
$paymentCellDatas
) ?></td>
<td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('create_at', $entity->getCreatedAt(), $paymentCellDatas) ?></td>
<td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('user_uid', $entity->getUserUID(), $paymentCellDatas) ?></td>
</tr> </tr>
<?php $cnt-- ?>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
</div> </div>