64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Customer;
|
|
|
|
use App\Entities\Customer\ClientEntity;
|
|
use App\Entities\Customer\CouponEntity;
|
|
use App\Helpers\Customer\CouponHelper;
|
|
use App\Models\Customer\CouponModel;
|
|
|
|
class CouponService extends CustomerService
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new CouponModel(), new CouponHelper());
|
|
$this->addClassName('Coupon');
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"clientinfo_uid",
|
|
"title",
|
|
"cnt",
|
|
"status",
|
|
"content"
|
|
];
|
|
}
|
|
public function getFormFilters(): array
|
|
{
|
|
return [
|
|
"clientinfo_uid",
|
|
"status",
|
|
];
|
|
}
|
|
public function getBatchjobFields(): array
|
|
{
|
|
return ['status'];
|
|
}
|
|
//고객쿠폰처리
|
|
private function setBalance(array $formDatas): ClientEntity
|
|
{
|
|
if (!array_key_exists('clientinfo_uid', $formDatas)) {
|
|
throw new \Exception("고객정보가 필요합니다.");
|
|
}
|
|
$entity = $this->getClientService()->getEntity($formDatas['clientinfo_uid']);
|
|
if (!$entity instanceof ClientEntity) {
|
|
throw new \Exception("{$formDatas['clientinfo_uid']}에 대한 고객정보를 찾을수 없습니다.");
|
|
}
|
|
return $this->getClientService()->setCoupon($formDatas['status'], $entity, intval($formDatas['cnt']));
|
|
}
|
|
//기본 기능부분
|
|
protected function create_process(array $formDatas): CouponEntity
|
|
{
|
|
// dd($formDatas);
|
|
$this->setBalance($formDatas);
|
|
$entity = parent::create_process($formDatas);
|
|
return $entity;
|
|
}
|
|
//수정
|
|
public function modify(mixed $entity, array $formDatas): CouponEntity
|
|
{
|
|
throw new \Exception("쿠폰은 수정하실 수 없습니다.");
|
|
}
|
|
}
|