當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Helper::getPenalty方法代碼示例

本文整理匯總了PHP中Library\Utility\Helper::getPenalty方法的典型用法代碼示例。如果您正苦於以下問題:PHP Helper::getPenalty方法的具體用法?PHP Helper::getPenalty怎麽用?PHP Helper::getPenalty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Library\Utility\Helper的用法示例。


在下文中一共展示了Helper::getPenalty方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: prepareData

 /**
  * @param \DDD\Domain\Booking\BookingTicket $data
  * @param array $formData
  *
  * @return array
  */
 public function prepareData($data, $formData)
 {
     /**
      * @var ReviewBooking $review
      * @var \DDD\Service\Reservation\PartnerSpecific $partnerSpecificService
      * @var \DDD\Service\Booking\Charge $bookingChargeService
      * @var \DDD\Dao\Booking\Booking $bookingDao
      */
     $partnerSpecificService = $this->getServiceLocator()->get('service_reservation_partner_specific');
     $daoReview = new \DDD\Dao\Accommodation\Review($this->getServiceLocator(), 'DDD\\Domain\\Review\\ReviewBooking');
     $bookingChargeService = $this->getServiceLocator()->get('service_booking_charge');
     $cityService = $this->getServiceLocator()->get('service_location');
     $bookingDao = $this->getServiceLocator()->get('dao_booking_booking');
     $bookingDao->setEntity(new \DDD\Domain\Booking\PrepareData());
     $dataOther = [];
     $reservationId = $data->getId();
     $startDate = $data->getDate_from();
     $endDate = $data->getDate_to();
     $review_res_number = $data->getResNumber();
     $review = $daoReview->fetchOne(['res_number' => $review_res_number]);
     if ($review) {
         $data->setHas_review(true);
     } else {
         $data->setHas_review(false);
     }
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $dataOther['credit_card_view'] = false;
     if ($auth->hasRole(Roles::ROLE_CREDIT_CARD)) {
         $dataOther['credit_card_view'] = true;
         $dataOther['secure_url'] = "https://" . DomainConstants::WS_SECURE_DOMAIN_NAME . "/booking/update-cc-details?code=" . $formData['data']->getProvideCcPageHash();
     }
     if ($auth->hasRole(Roles::ROLE_RESERVATIONS)) {
         $dataOther['reservation_role'] = true;
     } else {
         $bookingService = $this->getServiceLocator()->get('service_booking');
         $part = $bookingService->getPartnerById($data->getPartnerId());
         $dataOther['affiliate'] = $part->getPartnerName();
     }
     $keyPageStatus = '';
     if (!Helper::checkDatesByDaysCount(1, $data->getDate_to())) {
         $keyPageStatus = "Expired";
     } elseif ($data->getKiPageStatus() == 1) {
         $kiPageHash = $data->getKiPageHash();
         $keyPageStatus = "<a target='_blank'  href='https://" . DomainConstants::WS_SECURE_DOMAIN_NAME . '/key?view=0&code=' . $kiPageHash . "' >Key Entry Link</a>";
     } elseif (!$data->getKiPageStatus()) {
         $keyPageStatus = "Not set yet";
     }
     $is_penalty_applied = $this->isPenaltyApplied($data->getDate_from(), $data->getIsRefundable(), $data->getRefundableBeforeHours());
     $penalty_period = $this->calculateCancelationPeriod($data->getStatus(), $data->getCancelation_date(), $data->getDate_to(), $is_penalty_applied);
     $dataOther['keyPageStatus'] = $keyPageStatus;
     $dataOther['penalty_period'] = $penalty_period;
     $penalty_val = number_format(str_replace(",", ".", $data->getPenalty_val()), 2, '.', '');
     $penalty = number_format(str_replace(",", ".", $data->getPenalty()), 2, '.', '');
     if (Rate::APARTMENT_RATE_REFUNDABLE == $data->getIsRefundable()) {
         if ($data->getRefundableBeforeHours() > 48) {
             $dataOther['cancellation'] = "This deal can be canceled for FREE up to " . $data->getRefundableBeforeHours() / 24 . " days before arrival";
         } else {
             $dataOther['cancellation'] = "This deal can be canceled for FREE up to " . $data->getRefundableBeforeHours() . " hours before arrival";
         }
     } else {
         $dataOther['cancellation'] = 'Non refundable';
     }
     $dataOther['panelty_type'] = Helper::getPenalty($penalty, $penalty_val, $data->getApartmentCurrencyCode());
     foreach ($formData['options']['statuses'] as $row) {
         if ($row->getId() == $data->getStatus()) {
             $dataOther['status_name'] = $row->getName();
             break;
         }
     }
     foreach ($formData['options']['partners'] as $row) {
         if ($row->getGid() == $data->getPartnerId()) {
             $dataOther['partner_name'] = $row->getPartnerName();
             $dataOther['partner_id'] = $data->getPartnerId();
             break;
         }
     }
     $customerReservations = $bookingDao->getCustomerReservationsStatuses($data->getGuestEmail());
     $bookedReservationsCount = 0;
     $cancelledReservationsCount = 0;
     $hasDebtBalance = false;
     foreach ($customerReservations as $customerReservation) {
         if (!$hasDebtBalance && $customerReservation->getBalance() < 0 && $data->getResNumber() != $customerReservation->getResNumber()) {
             $hasDebtBalance = true;
         }
         if ($customerReservation->getStatus() == BookingService::BOOKING_STATUS_BOOKED) {
             $bookedReservationsCount++;
         } else {
             $cancelledReservationsCount++;
         }
     }
     $dataOther['pendingCreditCardInQueue'] = false;
     $pendingCreditCardInQueue = $bookingDao->getPendingInQueueCardsByReservationId($reservationId);
     if ($pendingCreditCardInQueue->count()) {
         $dataOther['pendingCreditCardInQueue'] = true;
//.........這裏部分代碼省略.........
開發者ID:arbi,項目名稱:MyCode,代碼行數:101,代碼來源:BookingTicket.php


注:本文中的Library\Utility\Helper::getPenalty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。