Пример #1
0
 private function getCredentials($productId)
 {
     if (ChannelManager::isDebugMode()) {
         return ['id' => '11111', 'password' => '11111', 'cubilis_id' => '11111'];
     }
     /**
      * @var \DDD\Dao\Apartment\Details $accDetailsDao
      * @var \DDD\Domain\Apartment\Details\Sync $accDetails
      * @var \DDD\Dao\Apartel\General $apartelGeneralDao
      */
     if ($this->chm->getProductType() == ChannelManager::PRODUCT_APARTEL) {
         $apartelGeneralDao = $this->getServiceLocator()->get('dao_apartel_general');
         $apartelGeneral = $apartelGeneralDao->getGeneralConnectionData($productId);
         $syncCubilis = $apartelGeneral->getSyncCubilis();
         $username = $apartelGeneral->getCubilisUsername();
         $password = $apartelGeneral->getCubilisPassword();
         $cubilisId = $apartelGeneral->getCubilisId();
     } else {
         $accDetailsDao = $this->getAccDetailsDao();
         $accDetails = $accDetailsDao->fetchOne(['apartment_id' => $productId], ['sync_cubilis', 'cubilis_id', 'cubilis_us', 'cubilis_pass']);
         $syncCubilis = $accDetails->getSync_cubilis();
         $username = $accDetails->getCubilisUs();
         $password = $accDetails->getCubilisPass();
         $cubilisId = $accDetails->getCubilisId();
     }
     if (DomainConstants::BO_DOMAIN_NAME == "backoffice.ginosi.com" || ChannelManager::isHighestPrivilegyGiven()) {
         if ($syncCubilis) {
             if ($cubilisId && $username && $password) {
                 return ['id' => $username, 'password' => $password, 'cubilis_id' => $cubilisId];
             } else {
                 throw new \Exception('Cubilis apartment credentials are empty or are in wrong format.');
             }
         } else {
             throw new \Exception('This product doesnot need to be synced with cubilis.');
         }
     } else {
         if ($syncCubilis) {
             throw new \Exception('TEST! This product cannot be synchronized with cubilis.');
         } else {
             throw new \Exception('TEST! This product does not need to be synced with cubilis.');
         }
     }
 }
Пример #2
0
 /**
  * Send Confirmation to cubilis
  *
  * @param ChannelManagerLib $chm
  * @param int $productId
  * @param array $channelResIdList
  * @return bool
  */
 private function sendConfirmation(ChannelManagerLib $chm, $productId, array $channelResIdList)
 {
     try {
         $result = $chm->sendConfirmation(['apartment_id' => $productId, 'data' => $this->transformChannelResIdList($channelResIdList)]);
         if ($result->getStatus() == CivilResponder::STATUS_SUCCESS) {
             $this->gr2info("Confirmation successful!", ['cron' => 'ChannelManager']);
             return true;
         } else {
             $this->gr2err("Cubilis confirmation about reservation is failed", ['cron' => 'ChannelManager', 'channel_message' => $result->getMessage()]);
         }
     } catch (\Exception $e) {
         $this->gr2logException($e, "Channel Manager: Confirmation mail wasn't send", ['apartment_id' => $productId]);
     }
     return false;
 }