<?php

namespace lib\Services;

use lib\Entities\ClientEntity;
use lib\Entities\HistoryEntity as Entity;
use lib\Entities\MemberEntity;
use lib\Entities\ServiceEntity;
use lib\Models\HistoryModel as Model;

class HistoryService extends CommonService
{
  public function __construct()
  {
    parent::__construct();
  }
  final public function getClassName(): string
  {
    return "History";
  }
  final public function getClassPath(): string
  {
    return $this->getClassName();
  }
  public function getModelClass(): string
  {
    return Model::class;
  }
  public function getEntityClass(): string
  {
    return Entity::class;
  }
  //도메인쿠폰 사용
  public function useCouponByService(ServiceEntity $service, ClientEntity $client, string $onetime_case, int $coupon, string $note, string $onetime_request_date): bool
  {
    $formDatas = [
      "service_code" => $service->getServiceCode(),
      "server_code" => $service->getServerCode(),
      "behavior_case" => $onetime_case,
      "behavior" => "도메인 쿠폰 구매 / {$coupon} 개",
      "behavior_date" => $onetime_request_date,
      "note" => trim($note),
      "client_name" => $client->getTitle()
    ];
    return $this->getModel()->insert($formDatas);
  }
}
