06 Feb
This commit is contained in:
parent
98bd71c760
commit
8b2ec705c9
83 changed files with 3467 additions and 1214 deletions
|
|
@ -20,7 +20,7 @@ class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
|
|||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function process(FewoBookingRequest $fewoBookingRequest, FewoLodging $fewoLodging, FewoPrice $fewoPrice)
|
||||
public function process(FewoBookingRequest $fewoBookingRequest, FewoLodging $fewoLodging, FewoPrice $fewoPrice, $priceResult)
|
||||
{
|
||||
$lead = $this->createLead($fewoBookingRequest);
|
||||
if ($lead === null)
|
||||
|
|
@ -28,7 +28,7 @@ class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
|
|||
$this->warn('Failed creating lead in CRM', $fewoBookingRequest, Logger::ERROR);
|
||||
return false;
|
||||
}
|
||||
$bookingUrl = $this->createBooking($fewoBookingRequest, $fewoLodging, $fewoPrice, $lead['customer_id'], $lead['id']);
|
||||
$bookingUrl = $this->createBooking($fewoBookingRequest, $fewoLodging, $fewoPrice, $priceResult, $lead['customer_id'], $lead['id']);
|
||||
if ($bookingUrl === false)
|
||||
{
|
||||
$this->warn('Failed creating booking in CRM', $fewoBookingRequest, Logger::ERROR);
|
||||
|
|
@ -41,10 +41,31 @@ class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
|
|||
$this->warn('Failed creating traveler in CRM.', $fewoBookingRequest);
|
||||
}
|
||||
*/
|
||||
$this->createNewDrafts($bookingUrl, $fewoBookingRequest, $fewoLodging, $fewoPrice, $priceResult);
|
||||
|
||||
return $bookingUrl;
|
||||
}
|
||||
|
||||
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 $resp;
|
||||
|
||||
}
|
||||
|
||||
private function createLead(FewoBookingRequest $fewoBookingRequest)
|
||||
{
|
||||
$resp = $this->httpPost('lead', ['lead' => [
|
||||
|
|
@ -88,15 +109,16 @@ class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
|
|||
return null;
|
||||
}
|
||||
|
||||
private function createBooking(FewoBookingRequest $fewoBookingRequest, FewoLodging $lodging, FewoPrice $price, $customerId, $leadId)
|
||||
private function createBooking(FewoBookingRequest $fewoBookingRequest, FewoLodging $lodging, FewoPrice $price, $priceResult, $customerId, $leadId)
|
||||
{
|
||||
$resp = $this->httpPost('booking', ['booking' => [
|
||||
'booking_date' => (new \DateTime())->format('Y-m-d'),
|
||||
'customer_id' => $customerId,
|
||||
'lead_id' => $leadId,
|
||||
//'travel_country_id' => $tp->getTravelCountry(),
|
||||
//'travel_category_id' => $tp->getTravelCategory(),
|
||||
//'travelagenda_id' => $tp->getTravelAgenda(),
|
||||
'travel_country_id' => 27,
|
||||
'travel_category_id' => 7,
|
||||
'travel_company_id' => 1,
|
||||
'travelagenda_id' => 109,
|
||||
'sf_guard_user_id' => self::API_USER_ID,
|
||||
'branch_id' => 4,
|
||||
'website_id' => self::WEBSITE_ID,
|
||||
|
|
@ -104,13 +126,15 @@ class FewoBookingSternToursCrmExporter extends SternToursCrmExporter
|
|||
'start_date' => $fewoBookingRequest->getFromDate()->format('Y-m-d'), // required
|
||||
'end_date' => $fewoBookingRequest->getToDate()->format('Y-m-d'), // required
|
||||
'pax' => $fewoBookingRequest->getTravelerCount(),
|
||||
'travel_number' => substr($lodging->getName()." - ".$price->getSeason()->getName(), 0, 30),
|
||||
'price' => $fewoBookingRequest->getTotalPrice(),
|
||||
|
||||
'travel_number' => substr($price->getSeason()->getName(), 0, 30),
|
||||
'price' => $priceResult['total'],
|
||||
'price_total' => $priceResult['total_price'],
|
||||
'participant_salutation_id' => $fewoBookingRequest->getSalutation(),
|
||||
'participant_name' => $fewoBookingRequest->getLastName(),
|
||||
'participant_firstname' => $fewoBookingRequest->getFirstName(),
|
||||
//'participant_birthdate' => $bookingRequest->getTravelers()[0]->getBirthDate(),
|
||||
'new_drafts' => true,
|
||||
|
||||
]]);
|
||||
|
||||
if (!$resp['success'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue