diff --git a/app/Helpers/CommonHelper.php b/app/Helpers/CommonHelper.php index 0cffd79..8c8852f 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -291,6 +291,7 @@ class CommonHelper case 'end_at': case 'updated_at': case 'created_at': + case 'deleted_at': $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender'; $form = form_input($field, $value ?? "", $extras); break; diff --git a/app/Interfaces/Customer/CustomerInterface.php b/app/Interfaces/Customer/CustomerInterface.php index 3e017cf..10c68e6 100644 --- a/app/Interfaces/Customer/CustomerInterface.php +++ b/app/Interfaces/Customer/CustomerInterface.php @@ -2,4 +2,4 @@ namespace App\Interfaces\Customer; -interface CustomerInterFace {} +interface CustomerInterface {} diff --git a/app/Language/en/Payment.php b/app/Language/en/Payment.php index a50d386..26e7345 100644 --- a/app/Language/en/Payment.php +++ b/app/Language/en/Payment.php @@ -22,8 +22,9 @@ return [ PAYMENT['BILLING']['ONETIME'] => "일회성", ], "PAY" => [ - "account" => "예치금", - "coupon" => "쿠폰", + PAYMENT['PAY']['ACCOUNT'] => "예치금", + PAYMENT['PAY']['COUPON'] => "쿠폰", + PAYMENT['PAY']['POINT'] => "포인트", ], "STATUS" => [ STATUS['UNPAID'] => "미지급", diff --git a/app/Libraries/DBMigration/Process/SwitchCodeProcess.php b/app/Libraries/DBMigration/Process/SwitchCodeProcess.php index c24bbc2..80fc239 100644 --- a/app/Libraries/DBMigration/Process/SwitchCodeProcess.php +++ b/app/Libraries/DBMigration/Process/SwitchCodeProcess.php @@ -5,7 +5,7 @@ namespace App\Libraries\DBMigration\Process; use App\Entities\Part\SWITCHEntity; use CodeIgniter\Database\BaseConnection; -class SWITCHCodeProcess implements MigrationProcessInterface +class SwitchCodeProcess implements MigrationProcessInterface { private $db; public function __construct(BaseConnection $db) diff --git a/app/Services/Customer/AccountService.php b/app/Services/Customer/AccountService.php index 4344f12..7ff98b8 100644 --- a/app/Services/Customer/AccountService.php +++ b/app/Services/Customer/AccountService.php @@ -56,6 +56,9 @@ class AccountService extends CustomerService if (!$entity instanceof ClientEntity) { throw new \Exception("{$formDatas['clientinfo_uid']}에 대한 고객정보를 찾을수 없습니다."); } + if (!array_key_exists('amount', $formDatas) || !array_key_exists('status', $formDatas)) { + throw new \Exception("입출금처리를 위한 금액과 상태값이 필요합니다."); + } $amount = intval($formDatas['amount']); if ($formDatas['status'] === AccountEntity::DEFAULT_STATUS) { //입금, 쿠폰추가 $entity = $this->getClientService()->deposit($entity, 'account_balance', $amount); diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php index fb629f7..c5101fc 100644 --- a/app/Services/Customer/ClientService.php +++ b/app/Services/Customer/ClientService.php @@ -110,10 +110,9 @@ class ClientService extends CustomerService break; default: throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다."); + // break; } - $formDatas = [$field => $amount]; - // dd($formDatas); - return parent::modify($entity, $formDatas); + return parent::modify($entity, [$field => $amount]); } //출금(쿠폰:사용)처리 final public function withdrawal(ClientEntity $entity, string $field, int $amount): ClientEntity @@ -141,8 +140,7 @@ class ClientService extends CustomerService throw new \Exception("{$field}는 알수없는 Field가 정의되었습니다."); // break; } - $formDatas = [$field => $amount]; - return parent::modify($entity, $formDatas); + return parent::modify($entity, [$field => $amount]); } //기본 기능부분 //생성 diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 29b52a1..5c18f53 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -2,6 +2,7 @@ namespace App\Services; +use App\Entities\Customer\ClientEntity; use App\Entities\Customer\ServiceEntity; use App\Entities\Equipment\ServerPartEntity; use App\Entities\PaymentEntity; @@ -10,6 +11,7 @@ use App\Interfaces\Customer\ServiceInterface; use App\Interfaces\Equipment\ServerPartInterface; use App\Models\PaymentModel; use App\Services\CommonService; +use App\Services\Customer\AccountService; use App\Services\Customer\ClientService; use App\Services\Customer\ServiceService; use App\Services\Equipment\ServerPartService; @@ -103,7 +105,6 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa } return $this->_serverPartService; } - //총 미납건수, 금액 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(); 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 검색용 //OrderBy 처리 final public function setOrderBy(mixed $field = null, mixed $value = null): void diff --git a/app/Views/admin/server/index.php b/app/Views/admin/server/index.php index fcf5c40..8052b94 100644 --- a/app/Views/admin/server/index.php +++ b/app/Views/admin/server/index.php @@ -80,7 +80,7 @@