06 Feb
This commit is contained in:
parent
98bd71c760
commit
8b2ec705c9
83 changed files with 3467 additions and 1214 deletions
|
|
@ -176,7 +176,7 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter
|
|||
$i++;
|
||||
}
|
||||
|
||||
$resp = $this->httpPostAPIv3('create_drafts', [
|
||||
$resp = $this->httpPostAPIv3('draft/create_drafts_from_booking', [
|
||||
'travel_program_id' => $tp->getId(),
|
||||
'comfort' => $bookingRequest->getComfort(),
|
||||
'booking_before' => $bookingPriceInfo['booking_before'],
|
||||
|
|
|
|||
|
|
@ -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'])
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ abstract class SternToursCrmExporter
|
|||
|
||||
|
||||
const API_URL_LOCAL = 'http://cms-stern-tours.local/api';
|
||||
const API_v3_URL_LOCAL = 'http://mein.sterntours.local/';
|
||||
|
||||
const API_URL = 'https://cms.stern-tours.net/api';
|
||||
const API_v3_URL_LOCAL = 'http://crm-stern-tours.local/';
|
||||
const API_v3_URL = 'https://mein.sterntours.de/';
|
||||
|
||||
const API_KEY = 'f6077389c9ce710e554763a5de02c8ec';
|
||||
|
|
@ -82,7 +83,6 @@ abstract class SternToursCrmExporter
|
|||
$baseUrl = self::API_v3_URL_LOCAL.'api/';
|
||||
}
|
||||
|
||||
|
||||
$data = array(
|
||||
'email' => self::API_v3_MAIL,
|
||||
'password' => self::API_v3_PASS,
|
||||
|
|
@ -98,9 +98,7 @@ abstract class SternToursCrmExporter
|
|||
|
||||
$result = curl_exec($ch);
|
||||
$r = json_decode($result);
|
||||
|
||||
if($r->success) {
|
||||
if($action == 'create_drafts'){
|
||||
|
||||
//api URL
|
||||
$data = json_encode($postData);
|
||||
|
|
@ -108,15 +106,15 @@ abstract class SternToursCrmExporter
|
|||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $r->success->token, 'Accept:application/json', 'Content-Type:application/json']);
|
||||
curl_setopt($ch, CURLOPT_URL, $baseUrl.'draft/create_drafts_from_booking');
|
||||
curl_setopt($ch, CURLOPT_URL, $baseUrl.$action);
|
||||
$result = curl_exec($ch);
|
||||
$r = json_decode($result);
|
||||
// var_dump($r);
|
||||
// var_dump($r);
|
||||
if($r->success) {
|
||||
curl_close($ch);
|
||||
return $r->success;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue