AbstractPackageApplicationService.php
2 years ago
BasicPackageApplicationService.php
2 years ago
BookableApplicationService.php
1 year ago
AbstractPackageApplicationService.php
139 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Application\Services\Bookable; |
| 4 | |
| 5 | use AmeliaBooking\Domain\Collection\Collection; |
| 6 | use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException; |
| 7 | use AmeliaBooking\Domain\Entity\Bookable\Service\Package; |
| 8 | use AmeliaBooking\Infrastructure\Common\Container; |
| 9 | use AmeliaBooking\Infrastructure\Common\Exceptions\QueryExecutionException; |
| 10 | use Exception; |
| 11 | use Slim\Exception\ContainerValueNotFoundException; |
| 12 | |
| 13 | /** |
| 14 | * Class AbstractPackageApplicationService |
| 15 | * |
| 16 | * @package AmeliaBooking\Application\Services\Booking |
| 17 | */ |
| 18 | abstract class AbstractPackageApplicationService |
| 19 | { |
| 20 | /** @var Container $container */ |
| 21 | public $container; |
| 22 | |
| 23 | /** |
| 24 | * AbstractPackageApplicationService constructor. |
| 25 | * |
| 26 | * @param Container $container |
| 27 | */ |
| 28 | public function __construct(Container $container) |
| 29 | { |
| 30 | $this->container = $container; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @param Collection $packageCustomerServices |
| 35 | * |
| 36 | * @return boolean |
| 37 | * |
| 38 | * @throws ContainerValueNotFoundException |
| 39 | */ |
| 40 | abstract public function deletePackageCustomer($packageCustomerServices); |
| 41 | |
| 42 | /** |
| 43 | * @param Collection $appointments |
| 44 | * |
| 45 | * @return void |
| 46 | */ |
| 47 | abstract public function setPackageBookingsForAppointments($appointments); |
| 48 | |
| 49 | /** |
| 50 | * @param int $packageCustomerServiceId |
| 51 | * @param int $customerId |
| 52 | * @param bool $isCabinetBooking |
| 53 | * |
| 54 | * @return boolean |
| 55 | */ |
| 56 | abstract public function isBookingAvailableForPurchasedPackage($packageCustomerServiceId, $customerId, $isCabinetBooking); |
| 57 | |
| 58 | /** |
| 59 | * @param array $params |
| 60 | * |
| 61 | * @return array |
| 62 | */ |
| 63 | abstract public function getPackageStatsData($params); |
| 64 | |
| 65 | /** |
| 66 | * @param array $packageDatesData |
| 67 | * @param Collection $appointmentsPackageCustomerServices |
| 68 | * @param int $packageCustomerServiceId |
| 69 | * @param string $date |
| 70 | * @param int $occupiedDuration |
| 71 | * |
| 72 | * @return void |
| 73 | */ |
| 74 | abstract public function updatePackageStatsData( |
| 75 | &$packageDatesData, |
| 76 | $appointmentsPackageCustomerServices, |
| 77 | $packageCustomerServiceId, |
| 78 | $date, |
| 79 | $occupiedDuration |
| 80 | ); |
| 81 | |
| 82 | /** |
| 83 | * @param Collection $appointments |
| 84 | * |
| 85 | * @return Collection |
| 86 | * |
| 87 | * @throws Exception |
| 88 | */ |
| 89 | abstract public function getPackageCustomerServicesForAppointments($appointments); |
| 90 | |
| 91 | /** |
| 92 | * @param Collection $appointments |
| 93 | * @param array $params |
| 94 | * |
| 95 | * @return array |
| 96 | */ |
| 97 | abstract public function getPackageAvailability($appointments, $params); |
| 98 | |
| 99 | /** |
| 100 | * @return array |
| 101 | */ |
| 102 | abstract public function getPackagesArray(); |
| 103 | |
| 104 | /** |
| 105 | * @param array $paymentsData |
| 106 | * @return void |
| 107 | * |
| 108 | * @throws InvalidArgumentException |
| 109 | * @throws QueryExecutionException |
| 110 | */ |
| 111 | abstract public function setPaymentData(&$paymentsData); |
| 112 | |
| 113 | /** |
| 114 | * @param Collection $appointments |
| 115 | * @param Collection $packageCustomerServices |
| 116 | * @param array $packageData |
| 117 | * |
| 118 | * @return void |
| 119 | */ |
| 120 | abstract protected function fixPurchase($appointments, $packageCustomerServices, $packageData); |
| 121 | |
| 122 | /** |
| 123 | * @param Collection $packageCustomerServices |
| 124 | * @param Collection $appointments |
| 125 | * |
| 126 | * @return array |
| 127 | * |
| 128 | * @throws ContainerValueNotFoundException |
| 129 | */ |
| 130 | abstract public function getPackageUnusedBookingsCount($packageCustomerServices, $appointments); |
| 131 | |
| 132 | /** |
| 133 | * @param array $package |
| 134 | * |
| 135 | * @return array |
| 136 | */ |
| 137 | abstract public function getOnlyOneEmployee($package); |
| 138 | } |
| 139 |