96 lines
2.9 KiB
PHP
96 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Customer;
|
|
|
|
use App\Entities\Customer\ServiceItemEntity;
|
|
use App\Models\Customer\ServiceItemModel;
|
|
use App\Services\Customer\CustomerService;
|
|
use App\Services\Customer\ServicePaymentService;
|
|
use App\Services\Customer\ServiceService;
|
|
|
|
class ServiceItemService extends CustomerService
|
|
{
|
|
private ?ServiceService $_serviceService = null;
|
|
public function __construct(mixed $request = null)
|
|
{
|
|
parent::__construct($request);
|
|
$this->addClassName('ServiceItem');
|
|
}
|
|
public function getModelClass(): ServiceItemModel
|
|
{
|
|
return new ServiceItemModel();
|
|
}
|
|
public function getEntityClass(): ServiceItemEntity
|
|
{
|
|
return new ServiceItemEntity();
|
|
}
|
|
public function getServiceService(): ServiceService
|
|
{
|
|
if (!$this->_serviceService) {
|
|
$this->_serviceService = new ServiceService($this->request);
|
|
}
|
|
return $this->_serviceService;
|
|
}
|
|
public function getServicePaymentService(): ServicePaymentService
|
|
{
|
|
if (!$this->_servicePaymentService) {
|
|
$this->_servicePaymentService = new ServicePaymentService($this->request);
|
|
}
|
|
return $this->_servicePaymentService;
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"serviceinfo_uid",
|
|
"item_type",
|
|
"item_uid",
|
|
"billing_cycle",
|
|
"price",
|
|
"amount",
|
|
"start_at",
|
|
"status",
|
|
];
|
|
}
|
|
public function getFilterFields(): array
|
|
{
|
|
return ["serviceinfo_uid", 'item_type', 'item_uid', 'billing_cycle', 'status'];
|
|
}
|
|
public function getBatchJobFields(): array
|
|
{
|
|
return ['status'];
|
|
}
|
|
public function getIndexFields(): array
|
|
{
|
|
return ['serviceinfo_uid', 'item_type', 'item_uid', 'billing_cycle', 'price', 'amount', 'start_at', 'updated_at', 'status'];
|
|
}
|
|
//Entity의 관련객체정의용
|
|
//FieldForm관련용
|
|
public function getFormFieldOption(string $field, array $options = []): array
|
|
{
|
|
switch ($field) {
|
|
case 'serviceinfo_uid':
|
|
$options = $this->getServiceService()->getEntities();
|
|
break;
|
|
default:
|
|
$options = parent::getFormFieldOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
public function create(array $formDatas, mixed $entity = null): ServiceItemEntity
|
|
{
|
|
$entity = parent::create($formDatas, $entity);
|
|
//결제정보 ServicePaymentService에 등록
|
|
$this->getServicePaymentService()->createPaymentByServiceItem($entity);
|
|
return $entity;
|
|
}
|
|
public function modify(mixed $entity, array $formDatas): ServiceItemEntity
|
|
{
|
|
return parent::modify($entity, $formDatas);
|
|
}
|
|
public function delete(mixed $entity): bool
|
|
{
|
|
return parent::delete($entity);
|
|
}
|
|
}
|