dbmsv4 init...2

This commit is contained in:
최준흠 2025-12-09 10:53:18 +09:00
parent 2868dd5d2a
commit ca85c5a21d
38 changed files with 247 additions and 148 deletions

View File

@ -2,19 +2,22 @@
namespace Config; namespace Config;
use CodeIgniter\Config\BaseService;
use App\Services\Auth\GoogleService; use App\Services\Auth\GoogleService;
use App\Services\Auth\LocalService; use App\Services\Auth\LocalService;
use App\Services\BoardService; use App\Services\BoardService;
use App\Services\Customer\AccountService; use App\Services\MylogService;
use App\Services\PaymentService;
use App\Services\UserService;
use App\Services\Customer\ClientService; use App\Services\Customer\ClientService;
use App\Services\Customer\CouponService; use App\Services\Customer\Wallet\CouponService;
use App\Services\Customer\PointService; use App\Services\Customer\Wallet\PointService;
use App\Services\Customer\Wallet\AccountService;
use App\Services\Customer\ServiceService; use App\Services\Customer\ServiceService;
use App\Services\Equipment\LineService; use App\Services\Equipment\LineService;
use App\Services\Equipment\ServerPartService; use App\Services\Equipment\ServerPartService;
use App\Services\Equipment\ServerService; use App\Services\Equipment\ServerService;
use App\Services\Equipment\CHASSISService; use App\Services\Equipment\CHASSISService;
use App\Services\MylogService;
use App\Services\Part\CPUService; use App\Services\Part\CPUService;
use App\Services\Part\CSService; use App\Services\Part\CSService;
use App\Services\Part\DISKService; use App\Services\Part\DISKService;
@ -22,9 +25,6 @@ use App\Services\Part\IPService;
use App\Services\Part\RAMService; use App\Services\Part\RAMService;
use App\Services\Part\SOFTWAREService; use App\Services\Part\SOFTWAREService;
use App\Services\Part\SWITCHService; use App\Services\Part\SWITCHService;
use App\Services\PaymentService;
use App\Services\UserService;
use CodeIgniter\Config\BaseService;
/** /**
* Services Configuration file. * Services Configuration file.
@ -130,31 +130,31 @@ class Services extends BaseService
new \App\Models\Customer\ClientModel(), new \App\Models\Customer\ClientModel(),
); );
} }
public static function customer_accountservice($getShared = true): AccountService public static function customer_wallet_accountservice($getShared = true): AccountService
{ {
if ($getShared) { if ($getShared) {
return static::getSharedInstance(__FUNCTION__); return static::getSharedInstance(__FUNCTION__);
} }
return new AccountService( return new AccountService(
new \App\Models\Customer\AccountModel(), new \App\Models\Customer\Wallet\AccountModel(),
); );
} }
public static function customer_couponservice($getShared = true): CouponService public static function customer_wallet_couponservice($getShared = true): CouponService
{ {
if ($getShared) { if ($getShared) {
return static::getSharedInstance(__FUNCTION__); return static::getSharedInstance(__FUNCTION__);
} }
return new CouponService( return new CouponService(
new \App\Models\Customer\CouponModel(), new \App\Models\Customer\Wallet\CouponModel(),
); );
} }
public static function customer_pointservice($getShared = true): PointService public static function customer_wallet_pointservice($getShared = true): PointService
{ {
if ($getShared) { if ($getShared) {
return static::getSharedInstance(__FUNCTION__); return static::getSharedInstance(__FUNCTION__);
} }
return new PointService( return new PointService(
new \App\Models\Customer\PointModel(), new \App\Models\Customer\Wallet\PointModel(),
); );
} }
public static function customer_serviceservice($getShared = true): ServiceService public static function customer_serviceservice($getShared = true): ServiceService

View File

@ -28,7 +28,7 @@ abstract class AdminController extends CommonController
$this->addViewDatas('formRules', $this->service->getFormService()->getFormRules()); $this->addViewDatas('formRules', $this->service->getFormService()->getFormRules());
$this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters()); $this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters());
$this->addViewDatas('formOptions', $this->service->getFormService()->getFormOptions()); $this->addViewDatas('formOptions', $this->service->getFormService()->getFormOptions());
$this->addViewDatas('index_actionButtons', $this->service->getFormService()->getactionButtons()); $this->addViewDatas('index_actionButtons', $this->service->getFormService()->getActionButtons());
$this->addViewDatas('index_batchjobFields', $this->service->getFormService()->getBatchjobFilters()); $this->addViewDatas('index_batchjobFields', $this->service->getFormService()->getBatchjobFilters());
$this->addViewDatas('index_batchjobButtons', $this->service->getFormService()->getBatchjobButtons()); $this->addViewDatas('index_batchjobButtons', $this->service->getFormService()->getBatchjobButtons());
} }

View File

@ -1,18 +1,18 @@
<?php <?php
namespace App\Controllers\Admin\Customer; namespace App\Controllers\Admin\Customer\Wallet;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class AccountController extends CustomerController class AccountController extends WalletController
{ {
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
if ($this->service === null) { if ($this->service === null) {
$this->service = service('customer_accountservice'); $this->service = service('customer_wallet_accountservice');
} }
$this->addActionPaths('account'); $this->addActionPaths('account');
} }

View File

@ -1,19 +1,18 @@
<?php <?php
namespace App\Controllers\Admin\Customer; namespace App\Controllers\Admin\Customer\Wallet;
use App\Entities\Customer\CouponEntity;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class CouponController extends CustomerController class CouponController extends WalletController
{ {
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
if ($this->service === null) { if ($this->service === null) {
$this->service = service('customer_couponservice'); $this->service = service('customer_wallet_couponservice');
} }
$this->addActionPaths('coupon'); $this->addActionPaths('coupon');
} }

View File

@ -1,19 +1,18 @@
<?php <?php
namespace App\Controllers\Admin\Customer; namespace App\Controllers\Admin\Customer\Wallet;
use App\Entities\Customer\PointEntity;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class PointController extends CustomerController class PointController extends WalletController
{ {
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
if ($this->service === null) { if ($this->service === null) {
$this->service = service('customer_pointservice'); $this->service = service('customer_wallet_pointservice');
} }
$this->addActionPaths('point'); $this->addActionPaths('point');
} }

View File

@ -0,0 +1,18 @@
<?php
namespace App\Controllers\Admin\Customer\Wallet;
use App\Controllers\Admin\Customer\CustomerController;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
abstract class WalletController extends CustomerController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->addActionPaths('wallet');
}
//Index,FieldForm관련
}

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\DTOs\Customer; namespace App\DTOs\Customer\Wallet;
use App\DTOs\CommonDTO; use App\DTOs\CommonDTO;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\DTOs\Customer; namespace App\DTOs\Customer\Wallet;
use App\DTOs\CommonDTO; use App\DTOs\CommonDTO;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\DTOs\Customer; namespace App\DTOs\Customer\Wallet;
use App\DTOs\CommonDTO; use App\DTOs\CommonDTO;

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Entities\Customer; namespace App\Entities\Customer\Wallet;
use App\Models\Customer\AccountModel; use App\Models\Customer\Wallet\AccountModel;
class AccountEntity extends CustomerEntity class AccountEntity extends WalletEntity
{ {
const PK = AccountModel::PK; const PK = AccountModel::PK;
const TITLE = AccountModel::TITLE; const TITLE = AccountModel::TITLE;

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Entities\Customer; namespace App\Entities\Customer\Wallet;
use App\Models\Customer\CouponModel; use App\Models\Customer\Wallet\CouponModel;
class CouponEntity extends CustomerEntity class CouponEntity extends WalletEntity
{ {
const PK = CouponModel::PK; const PK = CouponModel::PK;
const TITLE = CouponModel::TITLE; const TITLE = CouponModel::TITLE;

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Entities\Customer; namespace App\Entities\Customer\Wallet;
use App\Models\Customer\PointModel; use App\Models\Customer\Wallet\PointModel;
class PointEntity extends CustomerEntity class PointEntity extends WalletEntity
{ {
const PK = PointModel::PK; const PK = PointModel::PK;
const TITLE = PointModel::TITLE; const TITLE = PointModel::TITLE;

View File

@ -0,0 +1,14 @@
<?php
namespace App\Entities\Customer\Wallet;
use App\Entities\Customer\CustomerEntity;
abstract class WalletEntity extends CustomerEntity
{
public function __construct(array|null $data = null)
{
parent::__construct($data);
}
}

View File

@ -100,7 +100,7 @@ abstract class CommonForm
{ {
return $this->_actionButtons = $buttons; return $this->_actionButtons = $buttons;
} }
final public function getactionButtons(): array final public function getActionButtons(): array
{ {
return $this->_actionButtons; return $this->_actionButtons;
} }

View File

@ -1,11 +0,0 @@
<?php
namespace App\Forms\Customer;
class CouponForm extends CustomerForm
{
public function __construct()
{
parent::__construct();
}
}

View File

@ -1,8 +1,8 @@
<?php <?php
namespace App\Forms\Customer; namespace App\Forms\Customer\Wallet;
class AccountForm extends CustomerForm class AccountForm extends WalletForm
{ {
public function __construct() public function __construct()
{ {

View File

@ -0,0 +1,31 @@
<?php
namespace App\Forms\Customer\Wallet;
class CouponForm extends WalletForm
{
public function __construct()
{
parent::__construct();
}
public function getFormRule(string $action, string $field): string
{
switch ($field) {
case "clientinfo_uid":
case "cnt":
$rule = "required|numeric";
break;
case "title":
case "status":
$rule = "required|trim|string";
break;
case "content":
$rule = "permit_empty|trim|string";
break;
default:
$rule = parent::getFormRule($action, $field);
break;
}
return $rule;
}
}

View File

@ -1,8 +1,8 @@
<?php <?php
namespace App\Forms\Customer; namespace App\Forms\Customer\Wallet;
class PointForm extends CustomerForm class PointForm extends WalletForm
{ {
public function __construct() public function __construct()
{ {

View File

@ -0,0 +1,13 @@
<?php
namespace App\Forms\Customer\Wallet;
use App\Forms\Customer\CustomerForm;
abstract class WalletForm extends CustomerForm
{
protected function __construct()
{
parent::__construct();
}
}

View File

@ -1,8 +1,8 @@
<?php <?php
namespace App\Helpers\Customer; namespace App\Helpers\Customer\Wallet;
class AccountHelper extends CustomerHelper class AccountHelper extends WalletHelper
{ {
public function __construct() public function __construct()
{ {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace App\Helpers\Customer; namespace App\Helpers\Customer\Wallet;
class CouponHelper extends CustomerHelper class CouponHelper extends WalletHelper
{ {
public function __construct() public function __construct()
{ {

View File

@ -1,8 +1,8 @@
<?php <?php
namespace App\Helpers\Customer; namespace App\Helpers\Customer\Wallet;
class PointHelper extends CustomerHelper class PointHelper extends WalletHelper
{ {
public function __construct() public function __construct()
{ {

View File

@ -0,0 +1,14 @@
<?php
namespace App\Helpers\Customer\Wallet;
use App\Helpers\Customer\CustomerHelper;
abstract class WalletHelper extends CustomerHelper
{
protected function __construct()
{
parent::__construct();
}
}

View File

@ -65,17 +65,11 @@ class PaymentHelper extends CommonHelper
case 'invoice': case 'invoice':
$action = form_submit($action . "_submit", $label ? $label : '청구서 발행', [ $action = form_submit($action . "_submit", $label ? $label : '청구서 발행', [
"formaction" => current_url() . '/' . $action, "formaction" => current_url() . '/' . $action,
"class" => "btn btn-outline btn-primary", "class" => "btn btn-sm btn-outline btn-primary",
]); ]);
break; break;
case 'paid': case 'paid':
$action = form_submit($action . "_submit", $label ? $label : '결제 처리', [ $action = sprintf("<a href=\"/admin/payment/paid/%s\" class=\"btn btn-sm btn-warning\">%s</a>", $viewDatas['entity']->getPK(), $label ? $label : '결제');
"formaction" => current_url() . '/' . $action,
"class" => "btn btn-outline btn-warning",
]);
break;
case 'onetime_paid':
$action = "<a href=\"/admin/payment/paid/{$viewDatas['entity']->getPK()}\">{$label}</a>";
break; break;
default: default:
$action = parent::getListButton($action, $label, $viewDatas, $extras); $action = parent::getListButton($action, $label, $viewDatas, $extras);

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Models\Customer; namespace App\Models\Customer\Wallet;
use App\Entities\Customer\AccountEntity; use App\Entities\Customer\Wallet\AccountEntity;
class AccountModel extends CustomerModel class AccountModel extends WalletModel
{ {
const TABLE = "accountinfo"; const TABLE = "accountinfo";
const PK = "uid"; const PK = "uid";

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Models\Customer; namespace App\Models\Customer\Wallet;
use App\Entities\Customer\CouponEntity; use App\Entities\Customer\Wallet\CouponEntity;
class CouponModel extends CustomerModel class CouponModel extends WalletModel
{ {
const TABLE = "couponinfo"; const TABLE = "couponinfo";
const PK = "uid"; const PK = "uid";

View File

@ -1,10 +1,10 @@
<?php <?php
namespace App\Models\Customer; namespace App\Models\Customer\Wallet;
use App\Entities\Customer\PointEntity; use App\Entities\Customer\Wallet\PointEntity;
class PointModel extends CustomerModel class PointModel extends WalletModel
{ {
const TABLE = "pointinfo"; const TABLE = "pointinfo";
const PK = "uid"; const PK = "uid";

View File

@ -0,0 +1,14 @@
<?php
namespace App\Models\Customer\Wallet;
use App\Models\Customer\CustomerModel;
abstract class WalletModel extends CustomerModel
{
protected function __construct()
{
parent::__construct();
}
}

View File

@ -2,13 +2,13 @@
namespace App\Services\Customer; namespace App\Services\Customer;
use RuntimeException;
use App\Models\Customer\ClientModel;
use App\Helpers\Customer\ClientHelper;
use App\Forms\Customer\ClientForm;
use App\Entities\Customer\ClientEntity;
use App\Entities\CommonEntity;
use App\DTOs\Customer\ClientDTO; use App\DTOs\Customer\ClientDTO;
use App\Entities\Customer\ClientEntity;
use App\Entities\PaymentEntity;
use App\Forms\Customer\ClientForm;
use App\Helpers\Customer\ClientHelper;
use App\Models\Customer\ClientModel;
use RuntimeException;
class ClientService extends CustomerService class ClientService extends CustomerService
{ {
@ -123,6 +123,7 @@ class ClientService extends CustomerService
switch ($key) { switch ($key) {
case PAYMENT['PAY']['ACCOUNT']: case PAYMENT['PAY']['ACCOUNT']:
$balance = $entity->getAccountBalance(); $balance = $entity->getAccountBalance();
$title = "예치금";
break; break;
case PAYMENT['PAY']['COUPON']: case PAYMENT['PAY']['COUPON']:
$balance = $entity->getCouponBalance(); $balance = $entity->getCouponBalance();
@ -135,14 +136,15 @@ class ClientService extends CustomerService
} }
//입금,추가 처리 //입금,추가 처리
if ($status === STATUS['DEPOSIT']) { if ($status === STATUS['DEPOSIT']) {
$calculatedValue = $balance - $value; $calculatedValue = $balance + $value;
} }
//출금,사용 처리 //출금,사용 처리
if ($status === STATUS['WITHDRAWAL']) { if ($status === STATUS['WITHDRAWAL']) {
if ($balance < $value) { if ($balance < $value) {
throw new RuntimeException(sprintf( throw new RuntimeException(sprintf(
"%s 에서 오류발생: 고객 %s[%s]이/가 사용한 %s 금액/수[%s] 보다 작습니다.", "%s 에서 오류발생: %s 고객 %s[%s]이/가 사용한 %s 금액/수[%s] 보다 작습니다.",
__METHOD__, __METHOD__,
$entity->getTitle(),
$title, $title,
number_format($balance), number_format($balance),
$title, $title,
@ -152,7 +154,7 @@ class ClientService extends CustomerService
$calculatedValue = $balance - $value; $calculatedValue = $balance - $value;
} }
if (!is_int($calculatedValue) || $calculatedValue < 0) { if (!is_int($calculatedValue) || $calculatedValue < 0) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$title}의 계산결과 값이 NULL이거나 0보다 작은 값입니다."); throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$entity->getTitle()} 고객 {$title}의 계산결과 값이 NULL이거나 0보다 작은 값입니다.");
} }
//balance 수정 //balance 수정
$formDatas = ["{$key}_balance" => $calculatedValue, 'status' => $status]; $formDatas = ["{$key}_balance" => $calculatedValue, 'status' => $status];
@ -161,6 +163,38 @@ class ClientService extends CustomerService
$this->getFormService()->setFormRules('modify', $fields); $this->getFormService()->setFormRules('modify', $fields);
return parent::modify_process($entity, $formDatas); return parent::modify_process($entity, $formDatas);
} }
//pay방식에따른 결제처리
final public function updateWalletByPayment(PaymentEntity $entity): void
{
$service = null;
switch ($entity->getPay()) {
case PAYMENT['PAY']['ACCOUNT']:
$service = service('customer_wallet_accountservice');
break;
case PAYMENT['PAY']['COUPON']:
$service = service('customer_wallet_couponservice');
break;
case PAYMENT['PAY']['POINT']:
$service = service('customer_wallet_pointservice');
break;
default:
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getPay()}는 지정되지 않은 지불방식입니다.");
// break;
}
$formDatas = [
'clientinfo_uid' => $entity->getClientInfoUID(),
'bank' => '결제차감',
'title' => $entity->getTitle(),
'alias' => '결제차감',
'issue_at' => date('Y-m-d'),
'amount' => $entity->getAmount(),
'status' => STATUS['WITHDRAWAL'],
];
$fields = array_keys($formDatas);
$service->getFormService()->setFormFields($fields);
$service->getFormService()->setFormRules('create', $fields);
$service->create_process($formDatas);
}
//기본 기능부분 //기본 기능부분
protected function getEntity_process(mixed $entity): ClientEntity protected function getEntity_process(mixed $entity): ClientEntity
{ {

View File

@ -1,17 +1,15 @@
<?php <?php
namespace App\Services\Customer; namespace App\Services\Customer\Wallet;
use App\DTOs\Customer\AccountDTO; use App\DTOs\Customer\Wallet\AccountDTO;
use App\Entities\CommonEntity; use App\Entities\Customer\Wallet\AccountEntity;
use App\Entities\Customer\AccountEntity; use App\Forms\Customer\Wallet\AccountForm;
use App\Entities\PaymentEntity; use App\Helpers\Customer\Wallet\AccountHelper;
use App\Forms\Customer\AccountForm; use App\Models\Customer\Wallet\AccountModel;
use App\Helpers\Customer\AccountHelper;
use App\Models\Customer\AccountModel;
use RuntimeException; use RuntimeException;
class AccountService extends CustomerService class AccountService extends WalletService
{ {
private $_form = null; private $_form = null;
private $_helper = null; private $_helper = null;

View File

@ -1,15 +1,15 @@
<?php <?php
namespace App\Services\Customer; namespace App\Services\Customer\Wallet;
use RuntimeException; use RuntimeException;
use App\Models\Customer\CouponModel; use App\Models\Customer\Wallet\CouponModel;
use App\Helpers\Customer\CouponHelper; use App\Helpers\Customer\Wallet\CouponHelper;
use App\Forms\Customer\CouponForm; use App\Forms\Customer\Wallet\CouponForm;
use App\Entities\Customer\CouponEntity; use App\Entities\Customer\Wallet\CouponEntity;
use App\DTOs\Customer\CouponDTO; use App\DTOs\Customer\Wallet\CouponDTO;
class CouponService extends CustomerService class CouponService extends WalletService
{ {
private $_form = null; private $_form = null;
private $_helper = null; private $_helper = null;

View File

@ -1,16 +1,15 @@
<?php <?php
namespace App\Services\Customer; namespace App\Services\Customer\Wallet;
use RuntimeException; use RuntimeException;
use App\Models\Customer\PointModel; use App\Models\Customer\Wallet\PointModel;
use App\Helpers\Customer\PointHelper; use App\Helpers\Customer\Wallet\PointHelper;
use App\Forms\Customer\PointForm; use App\Forms\Customer\Wallet\PointForm;
use App\Entities\Customer\PointEntity; use App\Entities\Customer\Wallet\PointEntity;
use App\Entities\CommonEntity; use App\DTOs\Customer\Wallet\PointDTO;
use App\DTOs\Customer\PointDTO;
class PointService extends CustomerService class PointService extends WalletService
{ {
private $_form = null; private $_form = null;
private $_helper = null; private $_helper = null;

View File

@ -0,0 +1,15 @@
<?php
namespace App\Services\Customer\Wallet;
use App\Models\CommonModel;
use App\Services\Customer\CustomerService;
abstract class WalletService extends CustomerService
{
protected function __construct(CommonModel $model)
{
parent::__construct($model);
$this->addClassPaths('Wallet');
}
}

View File

@ -3,7 +3,6 @@
namespace App\Services; namespace App\Services;
use App\DTOs\PaymentDTO; use App\DTOs\PaymentDTO;
use App\Entities\CommonEntity;
use App\Entities\Customer\ClientEntity; use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\ServiceEntity; use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity; use App\Entities\Equipment\ServerEntity;
@ -13,7 +12,6 @@ use App\Forms\PaymentForm;
use App\Helpers\PaymentHelper; use App\Helpers\PaymentHelper;
use App\Models\PaymentModel; use App\Models\PaymentModel;
use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Validation\Exceptions\ValidationException;
use DateTime; use DateTime;
use RuntimeException; use RuntimeException;
@ -79,8 +77,9 @@ class PaymentService extends CommonService
"content", "content",
]; ];
$filters = ['user_uid', 'clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; $filters = ['user_uid', 'clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay'];
$indexFilter = ['clientinfo_uid', 'serviceinfo_uid', 'status', 'billing']; $indexFilter = ['clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay'];
$batchjobFilters = ['status']; $batchjobFilters = ['status'];
$actionButtons = ['view' => ICONS['SEARCH'], 'paid' => '결제'];
$batchjobButtons = ['batchjob' => '일괄결제', 'invoice' => '청구서발행']; $batchjobButtons = ['batchjob' => '일괄결제', 'invoice' => '청구서발행'];
switch ($action) { switch ($action) {
case 'create': case 'create':
@ -129,6 +128,7 @@ class PaymentService extends CommonService
$this->getFormService()->setFormFilters($filters); $this->getFormService()->setFormFilters($filters);
$this->getFormService()->setFormOptions($action, $filters, $formDatas); $this->getFormService()->setFormOptions($action, $filters, $formDatas);
$this->getFormService()->setIndexFilters($indexFilter); $this->getFormService()->setIndexFilters($indexFilter);
$this->getFormService()->setActionButtons($actionButtons);
$this->getFormService()->setBatchjobFilters($batchjobFilters); $this->getFormService()->setBatchjobFilters($batchjobFilters);
$this->getFormService()->setBatchjobButtons($batchjobButtons); $this->getFormService()->setBatchjobButtons($batchjobButtons);
} }
@ -147,7 +147,6 @@ class PaymentService extends CommonService
} }
return $unPaids; return $unPaids;
} }
//기본 기능부분 //기본 기능부분
protected function getEntity_process(mixed $entity): PaymentEntity protected function getEntity_process(mixed $entity): PaymentEntity
{ {
@ -242,34 +241,6 @@ class PaymentService extends CommonService
} }
//지불 관련 //지불 관련
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_process($formDatas);
break;
case PAYMENT['PAY']['COUPON']:
service('customer_couponservice')->create_process($formDatas);
break;
case PAYMENT['PAY']['POINT']:
service('customer_pointservice')->create_process($formDatas);
break;
default:
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getPay()}는 지정되지 않은 지불방식입니다.");
// break;
}
return $entity;
}
public function paid($uid): PaymentEntity public function paid($uid): PaymentEntity
{ {
$db = \Config\Database::connect(); $db = \Config\Database::connect();
@ -286,7 +257,8 @@ class PaymentService extends CommonService
$this->getFormService()->setFormFields($fields); $this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields); $this->getFormService()->setFormRules('modify', $fields);
$entity = parent::modify_process($entity, $formDatas); $entity = parent::modify_process($entity, $formDatas);
$entity = $this->paid_process($entity); //지불방식에 따른 고객 예치금,쿠폰,포인트 처리
$entity = service('customer_clientservice')->updateWalletByPayment($entity);
$db->transComplete(); $db->transComplete();
return $entity; return $entity;
} catch (DatabaseException $e) { } catch (DatabaseException $e) {

View File

@ -8,9 +8,9 @@
<th style="width: 120px">결제금액</th> <th style="width: 120px">결제금액</th>
<th style="width: 100px">청구방식</th> <th style="width: 100px">청구방식</th>
<th style="width: 100px">지불방법</th> <th style="width: 100px">지불방법</th>
<th style="width: 100px">결제처리</th>
<th style="width: 170px">등록일</th> <th style="width: 170px">등록일</th>
<th style="width: 100px">관리자</th> <th style="width: 100px">관리자</th>
<th style="width: 100px">결제처리</th>
</tr> </tr>
<?php $cnt = count(value: $paymentCellDatas['entities']) ?> <?php $cnt = count(value: $paymentCellDatas['entities']) ?>
<?php foreach ($paymentCellDatas['entities'] as $entity): ?> <?php foreach ($paymentCellDatas['entities'] as $entity): ?>
@ -25,13 +25,9 @@
<td class="text-end"><?= $paymentCellDatas['helper']->getFieldView('amount', $entity->getAmount(), $paymentCellDatas) ?></td> <td class="text-end"><?= $paymentCellDatas['helper']->getFieldView('amount', $entity->getAmount(), $paymentCellDatas) ?></td>
<td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('billing', $entity->getBilling(), $paymentCellDatas) ?></td> <td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('billing', $entity->getBilling(), $paymentCellDatas) ?></td>
<td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('pay', $entity->getPay(), $paymentCellDatas) ?></td> <td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('pay', $entity->getPay(), $paymentCellDatas) ?></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('create_at', $entity->getCreatedAt(), $paymentCellDatas) ?></td>
<td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('user_uid', $entity->getUserUID(), $paymentCellDatas) ?></td> <td class="text-center"><?= $paymentCellDatas['helper']->getFieldView('user_uid', $entity->getUserUID(), $paymentCellDatas) ?></td>
<td class="text-center"><?= $paymentCellDatas['helper']->getListButton('paid', "", $paymentCellDatas) ?></td>
</tr> </tr>
<?php $cnt-- ?> <?php $cnt-- ?>
<?php endforeach; ?> <?php endforeach; ?>