init without trunk
This commit is contained in:
parent
ed24ac4994
commit
bb809e7233
14652 changed files with 177862 additions and 94817 deletions
141
src/AppBundle/Export/FewoBookingSternToursCrmExporter.php
Normal file
141
src/AppBundle/Export/FewoBookingSternToursCrmExporter.php
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
<?php
|
||||
|
||||
namespace AppBundle\Export;
|
||||
|
||||
|
||||
use AppBundle\Entity\BookingRequest;
|
||||
use AppBundle\Entity\FewoBookingRequest;
|
||||
use AppBundle\Entity\FewoLodging;
|
||||
use AppBundle\Entity\FewoPrice;
|
||||
use AppBundle\Entity\TravelDate;
|
||||
use AppBundle\Entity\Traveler;
|
||||
use AppBundle\Util;
|
||||
use Monolog\Logger;
|
||||
|
||||
class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
|
||||
{
|
||||
|
||||
public function __construct(Logger $logger)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function process(FewoBookingRequest $fewoBookingRequest, FewoLodging $fewoLodging, FewoPrice $fewoPrice, $priceResult, $reservationId)
|
||||
{
|
||||
$lead = $this->createLead($fewoBookingRequest);
|
||||
if ($lead === null)
|
||||
{
|
||||
$this->warn('Failed creating lead in CRM', $fewoBookingRequest, Logger::ERROR);
|
||||
return false;
|
||||
}
|
||||
$booking = $this->createBooking($fewoBookingRequest, $fewoLodging, $fewoPrice, $priceResult, $lead->travel_user_id, $reservationId);
|
||||
if ($booking === null)
|
||||
{
|
||||
$this->warn('Failed creating booking in CRM', $fewoBookingRequest, Logger::ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
// is out $this->createNewDrafts($booking['crm_url'], $fewoBookingRequest, $fewoLodging, $fewoPrice, $priceResult);
|
||||
|
||||
return $booking->crm_url;
|
||||
}
|
||||
|
||||
/* private function createNewDrafts($bookingUrl, $fewoBookingRequest, $fewoLodging, $fewoPrice, $priceResult){
|
||||
//make an request omn the new API
|
||||
|
||||
|
||||
$resp = $this->httpPostAPIv3('draft/create_drafts_from_fewo', [
|
||||
'booking_id' => array_values(array_slice(explode("/", $bookingUrl), -1))[0],
|
||||
'fewo_lodging_id' => $fewoLodging->getId(),
|
||||
'request_date' => (new \DateTime())->format('Y-m-d'), // required
|
||||
'priceResult' => $priceResult,
|
||||
'startDateStr' => $fewoBookingRequest->getFromDate()->format('Y-m-d'),
|
||||
'endDateStr' => $fewoBookingRequest->getToDate()->format('Y-m-d'),
|
||||
]);
|
||||
if (count($resp) == 0)
|
||||
{
|
||||
$this->warn('Failed retrieving newly created new draft object', $fewoBookingRequest);
|
||||
return null;
|
||||
|
||||
}
|
||||
return $resp;
|
||||
|
||||
} */
|
||||
|
||||
|
||||
private function createLead(FewoBookingRequest $fewoBookingRequest)
|
||||
{
|
||||
$resp = $this->httpPostAPIv3('fewo/create_travel_users',
|
||||
['travel_user' => [
|
||||
'salutation_id' => $fewoBookingRequest->getSalutation(),
|
||||
'first_name' => $fewoBookingRequest->getFirstName(),
|
||||
'last_name' => $fewoBookingRequest->getLastName(),
|
||||
'street' => $fewoBookingRequest->getStreetAddress(),
|
||||
'zipcode' => $fewoBookingRequest->getZipCode(),
|
||||
'city' => $fewoBookingRequest->getCity(),
|
||||
'travel_nationality_id' => $fewoBookingRequest->getNation(),
|
||||
'phone' => $fewoBookingRequest->getPhone(),
|
||||
'mobile' => $fewoBookingRequest->getMobile(),
|
||||
'email' => $fewoBookingRequest->getEmail()
|
||||
],
|
||||
]
|
||||
);
|
||||
if (count($resp) == 0)
|
||||
{
|
||||
$this->warn('Failed retrieving newly created new draft object', $fewoBookingRequest);
|
||||
return null;
|
||||
}
|
||||
return $resp;
|
||||
}
|
||||
|
||||
private function createBooking(FewoBookingRequest $fewoBookingRequest, FewoLodging $lodging, FewoPrice $price, $priceResult, $travel_user_id, $reservationId)
|
||||
{
|
||||
$resp = $this->httpPostAPIv3('fewo/create_fewo_booking',
|
||||
['travel_user_booking_fewo' => [
|
||||
'travel_user_id' => $travel_user_id,
|
||||
'fewo_lodging_id' => $lodging->getId(),
|
||||
'fewo_reservation_id' => $reservationId,
|
||||
'invoice_number' => '',
|
||||
'persons' => $fewoBookingRequest->getTravelerCount(),
|
||||
'adults' => $fewoBookingRequest->getTravelerCountAdult(),
|
||||
'children' => $fewoBookingRequest->getTravelerCountChild(),
|
||||
// 'booking_date' => now(),
|
||||
'from_date' => $fewoBookingRequest->getFromDate()->format('Y-m-d'),
|
||||
'to_date' => $fewoBookingRequest->getToDate()->format('Y-m-d'),
|
||||
'daily_prices' => $priceResult['season'],
|
||||
'price_travel' => $priceResult['total'],
|
||||
'price_deposit' => $priceResult['deposit'],
|
||||
'price_service' => $priceResult['flatPrice'],
|
||||
'price_total' => $priceResult['total_price'],
|
||||
'notice' => $fewoBookingRequest->getNotes(),
|
||||
'travel_booking_fewo_channel_id' => 7,
|
||||
'is_calendar_fewo_direct' => false,
|
||||
'is_calendar_hrs' => false,
|
||||
'is_calendar_stern_tours' => true,
|
||||
'status' => false,
|
||||
'status_text' => "",
|
||||
]]);
|
||||
|
||||
if (count($resp) == 0)
|
||||
{
|
||||
$this->warn('Failed retrieving newly created new draft object', $fewoBookingRequest);
|
||||
return null;
|
||||
}
|
||||
return $resp;
|
||||
}
|
||||
|
||||
|
||||
private function warn($msg, FewoBookingRequest $fewoBookingRequest = null, $level = Logger::WARNING)
|
||||
{
|
||||
$this->logger->log($level, 'SternToursCrmBookingExporter: '. $msg);
|
||||
$this->logger->log($level, '*** Date: '. (new \DateTime())->format('d.m.Y'));
|
||||
|
||||
if ($fewoBookingRequest !== null)
|
||||
{
|
||||
$this->logger->log($level, '*** Booking date: '. $fewoBookingRequest->getFromDate()->format('d.m.Y') .
|
||||
' - '. $fewoBookingRequest->getToDate()->format('d.m.Y') .')');
|
||||
|
||||
$this->logger->log($level, '*** User name: '. $fewoBookingRequest->getFirstName() .' '. $fewoBookingRequest->getLastName());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue