From 3de5fd617be9814c41c019e9178b816424042ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Mon, 15 Dec 2025 14:43:01 +0900 Subject: [PATCH] dbmsv4 init...3 --- app/Services/Customer/Wallet/AccountService.php | 3 +-- app/Services/Customer/Wallet/CouponService.php | 17 ++++++++++++++++- app/Services/Customer/Wallet/PointService.php | 1 - 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/Services/Customer/Wallet/AccountService.php b/app/Services/Customer/Wallet/AccountService.php index 82c1c28..2bd9ecb 100644 --- a/app/Services/Customer/Wallet/AccountService.php +++ b/app/Services/Customer/Wallet/AccountService.php @@ -5,7 +5,6 @@ namespace App\Services\Customer\Wallet; use App\DTOs\Customer\Wallet\AccountDTO; use App\Entities\Customer\ClientEntity; use App\Entities\Customer\Wallet\AccountEntity; -use App\Entities\PaymentEntity; use App\Forms\Customer\Wallet\AccountForm; use App\Helpers\Customer\Wallet\AccountHelper; use App\Models\Customer\Wallet\AccountModel; @@ -167,7 +166,7 @@ class AccountService extends WalletService )); } //최종처리 - $formDatas['bank'] = BANKS['결제차감']; + $formDatas['bank'] = array_key_exists('bank', $formDatas) ? $formDatas['bank'] : BANKS['결제차감']; $formDatas['alias'] = array_key_exists('alias', $formDatas) ? $formDatas['alias'] : $clientEntity->getTitle(); $formDatas['balance'] = $clientEntity->getAccountBalance() - $formDatas['amount']; if ($formDatas['balance'] < 0) { diff --git a/app/Services/Customer/Wallet/CouponService.php b/app/Services/Customer/Wallet/CouponService.php index 995a6b8..b386739 100644 --- a/app/Services/Customer/Wallet/CouponService.php +++ b/app/Services/Customer/Wallet/CouponService.php @@ -13,6 +13,7 @@ use RuntimeException; class CouponService extends WalletService { + const CLIENTINFO_BALANCE_FIELD = 'coupon_balance'; private $_form = null; private $_helper = null; public function __construct(CouponModel $model) @@ -112,7 +113,6 @@ class CouponService extends WalletService protected function create_process(array $formDatas): CouponEntity { $entity = parent::create_process($formDatas); - service('customer_clientservice')->updateBalance($entity->getClientInfoUID(), "쿠폰", PAYMENT['PAY']['COUPON'], $entity->getCnt(), $entity->getStatus()); return $entity; } protected function modify_process($entity, array $formDatas): CouponEntity @@ -123,6 +123,21 @@ class CouponService extends WalletService //FormFilter 조건절 처리 //검색어조건절처리 + //입금,쿠폰 충전 처리 + protected function deposit_process(ClientEntity $clientEntity, array $formDatas): array + { + if (!array_key_exists('cnt', $formDatas)) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 쿠폰수가 정의되지 않았습니다."); + } + //최종처리 + $formDatas['balance'] = $clientEntity->getCouponBalance() + $formDatas['cnt']; + if ($formDatas['balance'] < 0) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 쿠폰수가 0보다 작은 값이 정의 되었습니다."); + } + //고객 잔액 갱신 + service('customer_clientservice')->modify_process($clientEntity, [self::CLIENTINFO_BALANCE_FIELD => $formDatas['balance']]); + return parent::deposit_process($clientEntity, $formDatas); + } //결제 관련 쿠폰 사용 처리 protected function withdrawalByPayment_process(ClientEntity $clientEntity, PaymentEntity $paymentEntity, array $formDatas): array { diff --git a/app/Services/Customer/Wallet/PointService.php b/app/Services/Customer/Wallet/PointService.php index e63095d..a01da2c 100644 --- a/app/Services/Customer/Wallet/PointService.php +++ b/app/Services/Customer/Wallet/PointService.php @@ -112,7 +112,6 @@ class PointService extends WalletService protected function create_process(array $formDatas): PointEntity { $entity = parent::create_process($formDatas); - service('customer_clientservice')->updateBalance($entity->getClientInfoUID(), "포인트", PAYMENT['PAY']['POINT'], $entity->getAmount(), $entity->getStatus()); return $entity; } protected function modify_process($entity, array $formDatas): PointEntity