diff --git a/app/Config/Services.php b/app/Config/Services.php index 6bcb2eb..8fc106b 100644 --- a/app/Config/Services.php +++ b/app/Config/Services.php @@ -2,19 +2,22 @@ namespace Config; +use CodeIgniter\Config\BaseService; use App\Services\Auth\GoogleService; use App\Services\Auth\LocalService; 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\CouponService; -use App\Services\Customer\PointService; +use App\Services\Customer\Wallet\CouponService; +use App\Services\Customer\Wallet\PointService; +use App\Services\Customer\Wallet\AccountService; use App\Services\Customer\ServiceService; use App\Services\Equipment\LineService; use App\Services\Equipment\ServerPartService; use App\Services\Equipment\ServerService; use App\Services\Equipment\CHASSISService; -use App\Services\MylogService; use App\Services\Part\CPUService; use App\Services\Part\CSService; use App\Services\Part\DISKService; @@ -22,9 +25,6 @@ use App\Services\Part\IPService; use App\Services\Part\RAMService; use App\Services\Part\SOFTWAREService; use App\Services\Part\SWITCHService; -use App\Services\PaymentService; -use App\Services\UserService; -use CodeIgniter\Config\BaseService; /** * Services Configuration file. @@ -130,31 +130,31 @@ class Services extends BaseService new \App\Models\Customer\ClientModel(), ); } - public static function customer_accountservice($getShared = true): AccountService + public static function customer_wallet_accountservice($getShared = true): AccountService { if ($getShared) { return static::getSharedInstance(__FUNCTION__); } 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) { return static::getSharedInstance(__FUNCTION__); } 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) { return static::getSharedInstance(__FUNCTION__); } return new PointService( - new \App\Models\Customer\PointModel(), + new \App\Models\Customer\Wallet\PointModel(), ); } public static function customer_serviceservice($getShared = true): ServiceService diff --git a/app/Controllers/Admin/AdminController.php b/app/Controllers/Admin/AdminController.php index 26c31c9..53129aa 100644 --- a/app/Controllers/Admin/AdminController.php +++ b/app/Controllers/Admin/AdminController.php @@ -28,7 +28,7 @@ abstract class AdminController extends CommonController $this->addViewDatas('formRules', $this->service->getFormService()->getFormRules()); $this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters()); $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_batchjobButtons', $this->service->getFormService()->getBatchjobButtons()); } diff --git a/app/Controllers/Admin/Customer/AccountController.php b/app/Controllers/Admin/Customer/Wallet/AccountController.php similarity index 72% rename from app/Controllers/Admin/Customer/AccountController.php rename to app/Controllers/Admin/Customer/Wallet/AccountController.php index ace20bc..5be8cfc 100644 --- a/app/Controllers/Admin/Customer/AccountController.php +++ b/app/Controllers/Admin/Customer/Wallet/AccountController.php @@ -1,18 +1,18 @@ service === null) { - $this->service = service('customer_accountservice'); + $this->service = service('customer_wallet_accountservice'); } $this->addActionPaths('account'); } diff --git a/app/Controllers/Admin/Customer/CouponController.php b/app/Controllers/Admin/Customer/Wallet/CouponController.php similarity index 69% rename from app/Controllers/Admin/Customer/CouponController.php rename to app/Controllers/Admin/Customer/Wallet/CouponController.php index a62154a..3236b73 100644 --- a/app/Controllers/Admin/Customer/CouponController.php +++ b/app/Controllers/Admin/Customer/Wallet/CouponController.php @@ -1,19 +1,18 @@ service === null) { - $this->service = service('customer_couponservice'); + $this->service = service('customer_wallet_couponservice'); } $this->addActionPaths('coupon'); } diff --git a/app/Controllers/Admin/Customer/PointController.php b/app/Controllers/Admin/Customer/Wallet/PointController.php similarity index 69% rename from app/Controllers/Admin/Customer/PointController.php rename to app/Controllers/Admin/Customer/Wallet/PointController.php index 4b537a0..1e50365 100644 --- a/app/Controllers/Admin/Customer/PointController.php +++ b/app/Controllers/Admin/Customer/Wallet/PointController.php @@ -1,19 +1,18 @@ service === null) { - $this->service = service('customer_pointservice'); + $this->service = service('customer_wallet_pointservice'); } $this->addActionPaths('point'); } diff --git a/app/Controllers/Admin/Customer/Wallet/WalletController.php b/app/Controllers/Admin/Customer/Wallet/WalletController.php new file mode 100644 index 0000000..96134cd --- /dev/null +++ b/app/Controllers/Admin/Customer/Wallet/WalletController.php @@ -0,0 +1,18 @@ +addActionPaths('wallet'); + } + //Index,FieldForm관련 +} diff --git a/app/DTOs/Customer/AccountDTO.php b/app/DTOs/Customer/Wallet/AccountDTO.php similarity index 93% rename from app/DTOs/Customer/AccountDTO.php rename to app/DTOs/Customer/Wallet/AccountDTO.php index c4c536e..73fd842 100644 --- a/app/DTOs/Customer/AccountDTO.php +++ b/app/DTOs/Customer/Wallet/AccountDTO.php @@ -1,6 +1,6 @@ _actionButtons = $buttons; } - final public function getactionButtons(): array + final public function getActionButtons(): array { return $this->_actionButtons; } diff --git a/app/Forms/Customer/CouponForm.php b/app/Forms/Customer/CouponForm.php deleted file mode 100644 index a6153ab..0000000 --- a/app/Forms/Customer/CouponForm.php +++ /dev/null @@ -1,11 +0,0 @@ - current_url() . '/' . $action, - "class" => "btn btn-outline btn-primary", + "class" => "btn btn-sm btn-outline btn-primary", ]); break; case 'paid': - $action = form_submit($action . "_submit", $label ? $label : '결제 처리', [ - "formaction" => current_url() . '/' . $action, - "class" => "btn btn-outline btn-warning", - ]); - break; - case 'onetime_paid': - $action = "getPK()}\">{$label}"; + $action = sprintf("%s", $viewDatas['entity']->getPK(), $label ? $label : '결제'); break; default: $action = parent::getListButton($action, $label, $viewDatas, $extras); diff --git a/app/Language/ko/Customer/Account.php b/app/Language/ko/Customer/Wallet/Account.php similarity index 100% rename from app/Language/ko/Customer/Account.php rename to app/Language/ko/Customer/Wallet/Account.php diff --git a/app/Language/ko/Customer/Coupon.php b/app/Language/ko/Customer/Wallet/Coupon.php similarity index 100% rename from app/Language/ko/Customer/Coupon.php rename to app/Language/ko/Customer/Wallet/Coupon.php diff --git a/app/Language/ko/Customer/Point.php b/app/Language/ko/Customer/Wallet/Point.php similarity index 100% rename from app/Language/ko/Customer/Point.php rename to app/Language/ko/Customer/Wallet/Point.php diff --git a/app/Models/Customer/AccountModel.php b/app/Models/Customer/Wallet/AccountModel.php similarity index 81% rename from app/Models/Customer/AccountModel.php rename to app/Models/Customer/Wallet/AccountModel.php index a58e4d1..aa1ee17 100644 --- a/app/Models/Customer/AccountModel.php +++ b/app/Models/Customer/Wallet/AccountModel.php @@ -1,10 +1,10 @@ getAccountBalance(); + $title = "예치금"; break; case PAYMENT['PAY']['COUPON']: $balance = $entity->getCouponBalance(); @@ -135,14 +136,15 @@ class ClientService extends CustomerService } //입금,추가 처리 if ($status === STATUS['DEPOSIT']) { - $calculatedValue = $balance - $value; + $calculatedValue = $balance + $value; } //출금,사용 처리 if ($status === STATUS['WITHDRAWAL']) { if ($balance < $value) { throw new RuntimeException(sprintf( - "%s 에서 오류발생: 고객 %s[%s]이/가 사용한 %s 금액/수[%s] 보다 작습니다.", + "%s 에서 오류발생: %s 고객의 %s[%s]이/가 사용한 %s 금액/수[%s] 보다 작습니다.", __METHOD__, + $entity->getTitle(), $title, number_format($balance), $title, @@ -152,7 +154,7 @@ class ClientService extends CustomerService $calculatedValue = $balance - $value; } 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 수정 $formDatas = ["{$key}_balance" => $calculatedValue, 'status' => $status]; @@ -161,6 +163,38 @@ class ClientService extends CustomerService $this->getFormService()->setFormRules('modify', $fields); 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 { diff --git a/app/Services/Customer/AccountService.php b/app/Services/Customer/Wallet/AccountService.php similarity index 92% rename from app/Services/Customer/AccountService.php rename to app/Services/Customer/Wallet/AccountService.php index e4619ec..64d7d6e 100644 --- a/app/Services/Customer/AccountService.php +++ b/app/Services/Customer/Wallet/AccountService.php @@ -1,17 +1,15 @@ addClassPaths('Wallet'); + } +} diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 74bfb38..d0459ae 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -3,7 +3,6 @@ namespace App\Services; use App\DTOs\PaymentDTO; -use App\Entities\CommonEntity; use App\Entities\Customer\ClientEntity; use App\Entities\Customer\ServiceEntity; use App\Entities\Equipment\ServerEntity; @@ -13,7 +12,6 @@ use App\Forms\PaymentForm; use App\Helpers\PaymentHelper; use App\Models\PaymentModel; use CodeIgniter\Database\Exceptions\DatabaseException; -use CodeIgniter\Validation\Exceptions\ValidationException; use DateTime; use RuntimeException; @@ -79,8 +77,9 @@ class PaymentService extends CommonService "content", ]; $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']; + $actionButtons = ['view' => ICONS['SEARCH'], 'paid' => '결제']; $batchjobButtons = ['batchjob' => '일괄결제', 'invoice' => '청구서발행']; switch ($action) { case 'create': @@ -129,6 +128,7 @@ class PaymentService extends CommonService $this->getFormService()->setFormFilters($filters); $this->getFormService()->setFormOptions($action, $filters, $formDatas); $this->getFormService()->setIndexFilters($indexFilter); + $this->getFormService()->setActionButtons($actionButtons); $this->getFormService()->setBatchjobFilters($batchjobFilters); $this->getFormService()->setBatchjobButtons($batchjobButtons); } @@ -147,7 +147,6 @@ class PaymentService extends CommonService } return $unPaids; } - //기본 기능부분 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 { $db = \Config\Database::connect(); @@ -286,7 +257,8 @@ class PaymentService extends CommonService $this->getFormService()->setFormFields($fields); $this->getFormService()->setFormRules('modify', $fields); $entity = parent::modify_process($entity, $formDatas); - $entity = $this->paid_process($entity); + //지불방식에 따른 고객 예치금,쿠폰,포인트 처리 + $entity = service('customer_clientservice')->updateWalletByPayment($entity); $db->transComplete(); return $entity; } catch (DatabaseException $e) { diff --git a/app/Views/cells/payment/detail.php b/app/Views/cells/payment/detail.php index 7f35c28..e75c35f 100644 --- a/app/Views/cells/payment/detail.php +++ b/app/Views/cells/payment/detail.php @@ -8,9 +8,9 @@ 결제금액 청구방식 지불방법 - 결제처리 등록일 관리자 + 결제처리 @@ -25,13 +25,9 @@ getFieldView('amount', $entity->getAmount(), $paymentCellDatas) ?> getFieldView('billing', $entity->getBilling(), $paymentCellDatas) ?> getFieldView('pay', $entity->getPay(), $paymentCellDatas) ?> - getListButton( - 'onetime_paid', - $serverCellDatas['helper']->getFieldView('status', $entity->getStatus(), $paymentCellDatas), - $paymentCellDatas - ) ?> getFieldView('create_at', $entity->getCreatedAt(), $paymentCellDatas) ?> getFieldView('user_uid', $entity->getUserUID(), $paymentCellDatas) ?> + getListButton('paid', "", $paymentCellDatas) ?>