dbmsv4 init...3
This commit is contained in:
parent
8349f3318b
commit
1eac94698f
@ -37,6 +37,10 @@ class ServerPartEntity extends EquipmentEntity
|
|||||||
{
|
{
|
||||||
return $this->attributes['billing'];
|
return $this->attributes['billing'];
|
||||||
}
|
}
|
||||||
|
public function getBillingAt(): string
|
||||||
|
{
|
||||||
|
return $this->attributes['billing_at'];
|
||||||
|
}
|
||||||
public function getAmount(): int
|
public function getAmount(): int
|
||||||
{
|
{
|
||||||
return $this->attributes['amount'];
|
return $this->attributes['amount'];
|
||||||
|
|||||||
@ -173,7 +173,7 @@ class ServiceService extends CustomerService
|
|||||||
return $date->format('Y-m-d');
|
return $date->format('Y-m-d');
|
||||||
}
|
}
|
||||||
// 서비스금액관련처리
|
// 서비스금액관련처리
|
||||||
private function saveAmount(ServiceEntity $entity): ServiceEntity
|
final public function updateAmount(ServiceEntity $entity): ServiceEntity
|
||||||
{
|
{
|
||||||
//총 서비스금액 구하기
|
//총 서비스금액 구하기
|
||||||
$server_amount = service('equipment_serverservice')->getCalculatedAmount($entity->getServerInfoUID());
|
$server_amount = service('equipment_serverservice')->getCalculatedAmount($entity->getServerInfoUID());
|
||||||
@ -187,13 +187,20 @@ class ServiceService extends CustomerService
|
|||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
final public function saveAmountByPK(int $uid): ServiceEntity
|
// 서비스금액관련처리
|
||||||
|
final public function updateBillingAt($uid, string $billing_at): ServiceEntity
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity($uid);
|
$entity = $this->getEntity($uid);
|
||||||
if (!$entity instanceof ServiceEntity) {
|
if (!$entity instanceof ServiceEntity) {
|
||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:{$uid}에 해당하는 서비스정보를 찾을 수 업습니다.");
|
||||||
}
|
}
|
||||||
return $this->saveAmount($entity);
|
$entity->billing_at = $billing_at;
|
||||||
|
if (!$this->model->save($entity)) {
|
||||||
|
// 저장 실패 시 예외 처리
|
||||||
|
$errors = $this->model->errors();
|
||||||
|
throw new RuntimeException("금액 업데이트 중 DB 저장 오류: " . implode(', ', $errors));
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
//기본 기능부분
|
//기본 기능부분
|
||||||
protected function getEntity_process(mixed $entity): ServiceEntity
|
protected function getEntity_process(mixed $entity): ServiceEntity
|
||||||
@ -212,7 +219,7 @@ class ServiceService extends CustomerService
|
|||||||
//서버정보 연결
|
//서버정보 연결
|
||||||
service('equipment_serverservice')->attatchToService($entity, $entity->getServerInfoUID());
|
service('equipment_serverservice')->attatchToService($entity, $entity->getServerInfoUID());
|
||||||
//서비스비용 설정
|
//서비스비용 설정
|
||||||
$entity = $this->saveAmount($entity);
|
$entity = $this->updateAmount($entity);
|
||||||
//결제정보 생성
|
//결제정보 생성
|
||||||
service('paymentservice')->createByService($entity);
|
service('paymentservice')->createByService($entity);
|
||||||
return $entity;
|
return $entity;
|
||||||
@ -231,7 +238,7 @@ class ServiceService extends CustomerService
|
|||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 ServiceEntity만 가능");
|
||||||
}
|
}
|
||||||
//신규 서비스 서버의 비용으로 재계산 서비스 금액 설정
|
//신규 서비스 서버의 비용으로 재계산 서비스 금액 설정
|
||||||
$entity = $this->saveAmount($entity);
|
$entity = $this->updateAmount($entity);
|
||||||
//기존 서비스용 결제비용 과 신규 서버스용으로 결제비용이 다르면 수정
|
//기존 서비스용 결제비용 과 신규 서버스용으로 결제비용이 다르면 수정
|
||||||
service('paymentservice')->modifyByService($oldEntity, $entity);
|
service('paymentservice')->modifyByService($oldEntity, $entity);
|
||||||
//서버정보 연결 신규서버로 변경
|
//서버정보 연결 신규서버로 변경
|
||||||
|
|||||||
@ -4,6 +4,7 @@ namespace App\Services\Equipment;
|
|||||||
|
|
||||||
use App\DTOs\Equipment\ServerPartDTO;
|
use App\DTOs\Equipment\ServerPartDTO;
|
||||||
use App\Entities\CommonEntity;
|
use App\Entities\CommonEntity;
|
||||||
|
use App\Entities\Customer\ServiceEntity;
|
||||||
use App\Entities\Equipment\ServerEntity;
|
use App\Entities\Equipment\ServerEntity;
|
||||||
use App\Entities\Equipment\ServerPartEntity;
|
use App\Entities\Equipment\ServerPartEntity;
|
||||||
use App\Entities\Part\PartEntity;
|
use App\Entities\Part\PartEntity;
|
||||||
@ -116,29 +117,68 @@ class ServerPartService extends EquipmentService
|
|||||||
{
|
{
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
protected function create_process(array $formDatas): CommonEntity
|
private function getFormDatasForServerPart(array $formDatas): array
|
||||||
{
|
{
|
||||||
|
if (!array_key_exists('serverinfo_uid', $formDatas)) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서버번호가 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
if (!array_key_exists('type', $formDatas)) {
|
if (!array_key_exists('type', $formDatas)) {
|
||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:부품형식이 지정되지 않았습니다.");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 부품형식이 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
if (!array_key_exists('billing', $formDatas)) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 청구방법이 지정되지 않았습니다.");
|
||||||
|
}
|
||||||
|
//서버정보 가져오기
|
||||||
|
$serverEntity = service('equipment_serverservice')->getEntity($formDatas['serverinfo_uid']);
|
||||||
|
if (!$serverEntity instanceof ServerEntity) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$formDatas['serverinfo_uid']}에 해당하는 서버정보을 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
//서비스정보 가져오기
|
||||||
|
$serviceEntity = null;
|
||||||
|
if ($serverEntity->getServiceInfoUID()) {
|
||||||
|
$serviceEntity = service('customer_serviceservice')->getEntity($serverEntity->getServiceInfoUID());
|
||||||
}
|
}
|
||||||
//각 파트정보 가져오기
|
//각 파트정보 가져오기
|
||||||
$partEntity = $this->getPartService($formDatas['type'])->getEntity($formDatas['part_uid']);
|
$partEntity = $this->getPartService($formDatas['type'])->getEntity($formDatas['part_uid']);
|
||||||
//해당 파트정보 Title 설정용
|
if (!$serviceEntity instanceof ServiceEntity) {
|
||||||
|
}
|
||||||
|
//해당 파트정보에 고객번호,서비스번호 설정
|
||||||
|
$formDatas['clientinfo_uid'] = $serverEntity->getClientInfoUID();
|
||||||
|
$formDatas['serviceinfo_uid'] = $serverEntity->getServiceInfoUID();
|
||||||
|
//해당 파트정보의 Title을 서버파트정보의 Titlte 설정
|
||||||
$formDatas['title'] = $partEntity->getTitle();
|
$formDatas['title'] = $partEntity->getTitle();
|
||||||
|
//청구방식에 따른 결제일 설정
|
||||||
|
$formDatas['billing_at'] = null;
|
||||||
|
if ($formDatas['billing'] === PAYMENT['BILLING']['MONTH']) {
|
||||||
|
if (!$serviceEntity instanceof ServiceEntity) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 매월결제 상품은 서비스정보가 지정된 후 설정하실 수 있습니다.");
|
||||||
|
}
|
||||||
|
$formDatas['billing_at'] = $serviceEntity->getBillingAt();
|
||||||
|
} elseif ($formDatas['billing'] === PAYMENT['BILLING']['ONETIME']) {
|
||||||
|
if (!$serviceEntity instanceof ServiceEntity) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 매월결제 상품은 서비스정보가 지정된 후 설정하실 수 있습니다.");
|
||||||
|
}
|
||||||
|
$formDatas['billing_at'] = date("Y-m-d");
|
||||||
|
}
|
||||||
|
return array($serverEntity, $serviceEntity, $partEntity, $formDatas);
|
||||||
|
}
|
||||||
|
protected function create_process(array $formDatas): CommonEntity
|
||||||
|
{
|
||||||
//서버파트 생성
|
//서버파트 생성
|
||||||
|
list($serverEntity, $serviceEntity, $partEntity, $formDatas) = $this->getFormDatasForServerPart($formDatas);
|
||||||
$entity = parent::create_process($formDatas);
|
$entity = parent::create_process($formDatas);
|
||||||
if (!$entity instanceof ServerPartEntity) {
|
if (!$entity instanceof ServerPartEntity) {
|
||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||||
}
|
}
|
||||||
//해당 파트별 설정 수정
|
//해당 파트정보를 서버파트정보에 추가
|
||||||
$this->getPartService($entity->getType())->attachToServerPart($entity);
|
$this->getPartService($entity->getType())->attachToServerPart($entity);
|
||||||
//서비스가 정의 되어 있으면
|
//서비스가 정의 되어 있으면
|
||||||
if ($entity->getServiceInfoUID() !== null) {
|
if ($serviceEntity instanceof ServiceEntity) {
|
||||||
//Billing형식이 Month이면 서비스 금액설정 호출
|
//Billing형식이 Month이면 서비스 금액설정 호출
|
||||||
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
|
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
|
||||||
service('customer_serviceservice')->saveAmountByPK($entity->getServiceInfoUID());
|
service('customer_serviceservice')->updateAmount($serviceEntity);
|
||||||
}
|
}
|
||||||
//Billing형식이 Onetime이면 일회성결제 추가
|
//Billing형식이 Onetime이면 일회성결제 생성
|
||||||
if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) {
|
if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) {
|
||||||
service('paymentservice')->createByServerPart($entity);
|
service('paymentservice')->createByServerPart($entity);
|
||||||
}
|
}
|
||||||
@ -147,28 +187,28 @@ class ServerPartService extends EquipmentService
|
|||||||
}
|
}
|
||||||
protected function modify_process($entity, array $formDatas): CommonEntity
|
protected function modify_process($entity, array $formDatas): CommonEntity
|
||||||
{
|
{
|
||||||
if (!array_key_exists('type', $formDatas)) {
|
list($serverEntity, $serviceEntity, $partEntity, $formDatas) = $this->getFormDatasForServerPart($formDatas);
|
||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:부품형식이 지정되지 않았습니다.");
|
|
||||||
}
|
|
||||||
//각 파트정보 가져오기
|
|
||||||
$partEntity = $this->getPartService($formDatas['type'])->getEntity($formDatas['part_uid']);
|
|
||||||
//해당 파트정보 Title 설정용
|
|
||||||
$formDatas['title'] = $partEntity->getTitle();
|
|
||||||
//서버파트 수정
|
//서버파트 수정
|
||||||
|
$oldEntity = clone $entity;
|
||||||
$entity = parent::modify_process($entity, $formDatas);
|
$entity = parent::modify_process($entity, $formDatas);
|
||||||
if (!$entity instanceof ServerPartEntity) {
|
if (!$entity instanceof ServerPartEntity) {
|
||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 PaymentEntity만 가능");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 PaymentEntity만 가능");
|
||||||
}
|
}
|
||||||
|
//해당 파트정보가 변경
|
||||||
|
if ($oldEntity->getPartUID() != $entity->getPartUID()) {
|
||||||
|
$this->getPartService($entity->getType())->detachFromServerPart($oldEntity);
|
||||||
|
$this->getPartService($entity->getType())->attachToServerPart($entity);
|
||||||
|
}
|
||||||
//서비스가 정의 되어 있으면
|
//서비스가 정의 되어 있으면
|
||||||
if ($entity->getServiceInfoUID() !== null) {
|
if ($serviceEntity instanceof ServiceEntity) {
|
||||||
//월비용 서버파트 인경우 서비스 금액 재설정
|
//Billing형식이 Month이면 서비스 금액설정 호출
|
||||||
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
|
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
|
||||||
service('customer_serviceservice')->saveAmountByPK($entity->getServiceInfoUID());
|
service('customer_serviceservice')->updateAmount($serviceEntity);
|
||||||
|
}
|
||||||
|
//Billing형식이 Onetime이면 일회성결제 수정
|
||||||
|
if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) {
|
||||||
|
service('paymentservice')->modifyByServerPart($oldEntity, $entity);
|
||||||
}
|
}
|
||||||
//Billing형식이 Onetime이면 일회성결제 수정 (필요없는듯 하여 주석처리)
|
|
||||||
// if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) {
|
|
||||||
// service('paymentservice')->modifyByServerPart($entity);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
@ -180,15 +220,14 @@ class ServerPartService extends EquipmentService
|
|||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 PaymentEntity만 가능");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 PaymentEntity만 가능");
|
||||||
}
|
}
|
||||||
//서비스가 정의 되어 있으면
|
//서비스가 정의 되어 있으면
|
||||||
if ($entity->getServiceInfoUID() !== null) {
|
//월비용 서버파트 인경우 서비스 금액 재설정
|
||||||
//월비용 서버파트 인경우 서비스 금액 재설정
|
if ($entity->getServiceInfoUID() !== null && $entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
|
||||||
if ($entity->getBilling() == PAYMENT['BILLING']['MONTH']) {
|
//서비스정보 가져오기
|
||||||
service('customer_serviceservice')->saveAmountByPK($entity->getServiceInfoUID());
|
$serviceEntity = service('customer_serviceservice')->getEntity($entity->getServiceInfoUID());
|
||||||
|
if (!$serviceEntity instanceof ServiceEntity) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getServiceInfoUID()}에 해당하는 서비스정보를 찾을 수 없습니다.");
|
||||||
}
|
}
|
||||||
//Billing형식이 Onetime이면 일회성결제 수정 (필요없는듯 하여 주석처리)
|
service('customer_serviceservice')->updateAmount($serviceEntity);
|
||||||
// if ($entity->getBilling() == PAYMENT['BILLING']['ONETIME']) {
|
|
||||||
// service('paymentservice')->modifyByServerPart($entity);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -250,7 +250,11 @@ class ServerService extends EquipmentService
|
|||||||
service('equipment_chassisservice')->attachToServer($entity);
|
service('equipment_chassisservice')->attachToServer($entity);
|
||||||
}
|
}
|
||||||
if ($entity->getServiceInfoUID() !== null) { //서비스가 정의 되어 있으면
|
if ($entity->getServiceInfoUID() !== null) { //서비스가 정의 되어 있으면
|
||||||
service('customer_serviceservice')->saveAmountByPK($entity->getServiceInfoUID());
|
$serviceEntity = service('customer_serviceservice')->getEntity($entity->getServiceInfoUID());
|
||||||
|
if (!$serviceEntity instanceof ServiceEntity) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getServiceInfoUID()}에 해당하는 서비스정보을 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
service('customer_serviceservice')->updateAmount($entity);
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ use App\Forms\PaymentForm;
|
|||||||
use App\Helpers\PaymentHelper;
|
use App\Helpers\PaymentHelper;
|
||||||
use App\Models\PaymentModel;
|
use App\Models\PaymentModel;
|
||||||
|
|
||||||
|
use App\Services\Customer\Wallet\WalletService;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
@ -176,10 +177,10 @@ class PaymentService extends CommonService
|
|||||||
}
|
}
|
||||||
//추가기능
|
//추가기능
|
||||||
//pay방식에따른 WalletService 등록
|
//pay방식에따른 WalletService 등록
|
||||||
private function setWallet(PaymentEntity $entity): void
|
private function getWalletService($pay): WalletService
|
||||||
{
|
{
|
||||||
$walletService = null;
|
$walletService = null;
|
||||||
switch ($entity->getPay()) {
|
switch ($pay) {
|
||||||
case PAYMENT['PAY']['ACCOUNT']:
|
case PAYMENT['PAY']['ACCOUNT']:
|
||||||
$walletService = service('customer_wallet_accountservice');
|
$walletService = service('customer_wallet_accountservice');
|
||||||
break;
|
break;
|
||||||
@ -190,10 +191,10 @@ class PaymentService extends CommonService
|
|||||||
$walletService = service('customer_wallet_pointservice');
|
$walletService = service('customer_wallet_pointservice');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getPay()}는 지정되지 않은 지불방식입니다.");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$pay}는 지정되지 않은 지불방식입니다.");
|
||||||
// break;
|
// break;
|
||||||
}
|
}
|
||||||
$walletService->withdrawalByPayment($entity);
|
return $walletService;
|
||||||
}
|
}
|
||||||
//일회성,선결제,쿠폰,포인트 입력 관련
|
//일회성,선결제,쿠폰,포인트 입력 관련
|
||||||
protected function create_process(array $formDatas): PaymentEntity
|
protected function create_process(array $formDatas): PaymentEntity
|
||||||
@ -202,6 +203,9 @@ class PaymentService extends CommonService
|
|||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스가 정의되지 않았습니다.");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스가 정의되지 않았습니다.");
|
||||||
}
|
}
|
||||||
$serviceEntity = service('customer_serviceservice')->getEntity($formDatas['serviceinfo_uid']);
|
$serviceEntity = service('customer_serviceservice')->getEntity($formDatas['serviceinfo_uid']);
|
||||||
|
if (!$serviceEntity instanceof ServiceEntity) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$formDatas['serviceinfo_uid']}에 해당하는 서비스정보를 찾을 수 없습니다.");
|
||||||
|
}
|
||||||
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
|
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
|
||||||
$entity = parent::create_process($formDatas);
|
$entity = parent::create_process($formDatas);
|
||||||
if (!$entity instanceof PaymentEntity) {
|
if (!$entity instanceof PaymentEntity) {
|
||||||
@ -209,11 +213,11 @@ class PaymentService extends CommonService
|
|||||||
}
|
}
|
||||||
//지불이 완료된경우 지불처리
|
//지불이 완료된경우 지불처리
|
||||||
if ($entity->getStatus() === STATUS['PAID']) {
|
if ($entity->getStatus() === STATUS['PAID']) {
|
||||||
$this->setWallet($entity);
|
$this->getWalletService($entity->getPay())->withdrawalByPayment($entity);;
|
||||||
}
|
}
|
||||||
//선결제인경우 서비스정보에 결제일 변경용
|
//선결제인경우 서비스정보에 결제일 변경용
|
||||||
if ($entity->getBilling() === PAYMENT['BILLING']['PREPAYMENT']) {
|
if ($entity->getBilling() === PAYMENT['BILLING']['PREPAYMENT']) {
|
||||||
service('customer_serviceservice')->modify($entity->getServiceInfoUID(), ['billing_at' => $entity->getBillingAt()]);
|
service('customer_serviceservice')->updateBillingAt($entity->getServiceInfoUID(), $entity->getBillingAt());
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
@ -223,6 +227,14 @@ class PaymentService extends CommonService
|
|||||||
if ($entity->getStatus() === STATUS['PAID']) {
|
if ($entity->getStatus() === STATUS['PAID']) {
|
||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 이미 지불된 결제정보는 수정이 불가합니다.");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 이미 지불된 결제정보는 수정이 불가합니다.");
|
||||||
}
|
}
|
||||||
|
if (!array_key_exists('serviceinfo_uid', $formDatas)) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스가 정의되지 않았습니다.");
|
||||||
|
}
|
||||||
|
$serviceEntity = service('customer_serviceservice')->getEntity($formDatas['serviceinfo_uid']);
|
||||||
|
if (!$serviceEntity instanceof ServiceEntity) {
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$formDatas['serviceinfo_uid']}에 해당하는 서비스정보를 찾을 수 없습니다.");
|
||||||
|
}
|
||||||
|
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
|
||||||
//수정된 결제정보
|
//수정된 결제정보
|
||||||
$entity = parent::modify_process($entity, $formDatas);
|
$entity = parent::modify_process($entity, $formDatas);
|
||||||
if (!$entity instanceof PaymentEntity) {
|
if (!$entity instanceof PaymentEntity) {
|
||||||
@ -230,11 +242,11 @@ class PaymentService extends CommonService
|
|||||||
}
|
}
|
||||||
//지불이 된경우 지불처리
|
//지불이 된경우 지불처리
|
||||||
if ($entity->getStatus() === STATUS['PAID']) {
|
if ($entity->getStatus() === STATUS['PAID']) {
|
||||||
$this->setWallet($entity);
|
$this->getWalletService($entity->getPay())->withdrawalByPayment($entity);;
|
||||||
}
|
}
|
||||||
//선결제인경우 서비스정보에 결제일 변경용
|
//선결제인경우 서비스정보에 결제일 변경용
|
||||||
if ($entity->getBilling() === PAYMENT['BILLING']['PREPAYMENT']) {
|
if ($entity->getBilling() === PAYMENT['BILLING']['PREPAYMENT']) {
|
||||||
service('customer_serviceservice')->modify($entity->getServiceInfoUID(), ['billing_at' => $entity->getBillingAt()]);
|
service('customer_serviceservice')->updateBillingAt($entity->getServiceInfoUID(), $entity->getBillingAt());
|
||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
@ -315,7 +327,7 @@ class PaymentService extends CommonService
|
|||||||
static::class . '->' . __FUNCTION__,
|
static::class . '->' . __FUNCTION__,
|
||||||
$this->model->getLastQuery() ?? "No Query Available",
|
$this->model->getLastQuery() ?? "No Query Available",
|
||||||
));
|
));
|
||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 기존 서비스정보의 {$oldServiceEntity->getPK()}에 해당하는 결제정보가 존재하지 않습니다.");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 기존 서비스정보의 {$oldServiceEntity->getTitle()}에 해당하는 결제정보가 존재하지 않습니다.");
|
||||||
}
|
}
|
||||||
//신규 서비스정보에 맞게 수정
|
//신규 서비스정보에 맞게 수정
|
||||||
$formDatas = $this->getFormDatasFromService($serviceEntity);
|
$formDatas = $this->getFormDatasFromService($serviceEntity);
|
||||||
@ -332,7 +344,7 @@ class PaymentService extends CommonService
|
|||||||
$formDatas["clientinfo_uid"] = $serverPartEntity->getClientInfoUID();
|
$formDatas["clientinfo_uid"] = $serverPartEntity->getClientInfoUID();
|
||||||
$formDatas['amount'] = $serverPartEntity->getAmount();
|
$formDatas['amount'] = $serverPartEntity->getAmount();
|
||||||
$formDatas['billing'] = $formDatas['billing'] ?? PAYMENT['BILLING']['ONETIME'];
|
$formDatas['billing'] = $formDatas['billing'] ?? PAYMENT['BILLING']['ONETIME'];
|
||||||
$formDatas['billing_at'] = date('Y-m-d');
|
$formDatas['billing_at'] = $serverPartEntity->getBillingAt();
|
||||||
$formDatas['pay'] = $formDatas['pay'] ?? PAYMENT['PAY']['ACCOUNT'];
|
$formDatas['pay'] = $formDatas['pay'] ?? PAYMENT['PAY']['ACCOUNT'];
|
||||||
$formDatas['status'] = $formDatas['status'] ?? STATUS['UNPAID'];
|
$formDatas['status'] = $formDatas['status'] ?? STATUS['UNPAID'];
|
||||||
$formDatas['title'] = sprintf("%s 일회성비용", $formDatas['title'] ?? $serverPartEntity->getTitle());
|
$formDatas['title'] = sprintf("%s 일회성비용", $formDatas['title'] ?? $serverPartEntity->getTitle());
|
||||||
@ -346,24 +358,29 @@ class PaymentService extends CommonService
|
|||||||
$formDatas = $this->getFormDatasFromServerPart($serverPartEntity);
|
$formDatas = $this->getFormDatasFromServerPart($serverPartEntity);
|
||||||
return parent::create_process($formDatas);
|
return parent::create_process($formDatas);
|
||||||
}
|
}
|
||||||
public function modifyByServerPart(ServerPartEntity $serverPartEntity): PaymentEntity
|
public function modifyByServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity): PaymentEntity
|
||||||
{
|
{
|
||||||
if ($serverPartEntity->getServiceInfoUID() === null) {
|
if ($serverPartEntity->getServiceInfoUID() === null) {
|
||||||
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스정보가 정의되지 않아 일회성 상품을 설정하실수 없습니다.");
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스정보가 정의되지 않아 일회성 상품을 설정하실수 없습니다.");
|
||||||
}
|
}
|
||||||
//서버파트정보의 서비스번호가 같고, 청구방식이 onetime이고 상태가 UNPAID인 결제정보 가져와서 결제정보 수정
|
//서버파트정보의 서비스번호가 같고, 청구방식이 onetime이고 상태가 UNPAID인 결제정보 가져와서 결제정보 수정
|
||||||
$entity = $this->getEntity([
|
$entity = $this->getEntity([
|
||||||
'serverpartinfo_uid' => $serverPartEntity->getPK(),
|
'serverpartinfo_uid' => $oldServerPartEntity->getPK(),
|
||||||
'serviceinfo_uid' => $serverPartEntity->getServiceInfoUID(),
|
'serviceinfo_uid' => $oldServerPartEntity->getServiceInfoUID(),
|
||||||
'billing' => PAYMENT['BILLING']['ONETIME'],
|
'billing' => PAYMENT['BILLING']['ONETIME'],
|
||||||
|
'billing_at' => $oldServerPartEntity->getBillingAt(),
|
||||||
'status' => STATUS['UNPAID']
|
'status' => STATUS['UNPAID']
|
||||||
]);
|
]);
|
||||||
if (!$entity instanceof PaymentEntity) {
|
if (!$entity instanceof PaymentEntity) { //해당조건에 맞는게 없으면 생성
|
||||||
$entity = $this->createByServerPart($serverPartEntity);
|
log_message('error', sprintf(
|
||||||
} else {
|
"\n------Last Query (%s)-----\nQuery: %s\n------------------------------\n",
|
||||||
$formDatas = $this->getFormDatasFromServerPart($serverPartEntity);
|
static::class . '->' . __FUNCTION__,
|
||||||
$entity = parent::modify_process($entity, $formDatas);
|
$this->model->getLastQuery() ?? "No Query Available",
|
||||||
|
));
|
||||||
|
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 기존 서버파트정보의 {$oldServerPartEntity->getTitle()}에 해당하는 결제정보가 존재하지 않습니다.");
|
||||||
}
|
}
|
||||||
|
$formDatas = $this->getFormDatasFromServerPart($serverPartEntity);
|
||||||
|
$entity = parent::modify_process($entity, $formDatas);
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user