DB-Skript:
CREATE TABLE fewo_lodging (id INT AUTO_INCREMENT NOT NULL, type_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT NOT NULL, equipment LONGTEXT NOT NULL, adress1 VARCHAR(255) NOT NULL, adress2 VARCHAR(255) DEFAULT NULL, zip_code VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, maximum_persons INT NOT NULL, deposit DOUBLE PRECISION NOT NULL, only_weekday INT NOT NULL, calendar_visible TINYINT(1) NOT NULL, INDEX IDX_9629C357C54C8C93 (type_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_lodging_image (id INT AUTO_INCREMENT NOT NULL, lodging_id INT DEFAULT NULL, full_file_name VARCHAR(255) NOT NULL, file_name VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, INDEX IDX_D49F667187335AF1 (lodging_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_lodging_type (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_price (id INT AUTO_INCREMENT NOT NULL, lodging_id INT DEFAULT NULL, season_id INT DEFAULT NULL, per_night DOUBLE PRECISION NOT NULL, flat_price DOUBLE PRECISION NOT NULL, INDEX IDX_3DE13C987335AF1 (lodging_id), INDEX IDX_3DE13C94EC001D1 (season_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_reservation (id INT AUTO_INCREMENT NOT NULL, lodging_id INT DEFAULT NULL, from_date DATE NOT NULL, to_date DATE NOT NULL, status INT NOT NULL, type INT NOT NULL, INDEX IDX_36537F7487335AF1 (lodging_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_season (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, from_date DATE NOT NULL, to_date DATE NOT NULL, minimum_stay INT NOT NULL, description LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
ALTER TABLE fewo_lodging ADD CONSTRAINT FK_9629C357C54C8C93 FOREIGN KEY (type_id) REFERENCES fewo_lodging_type (id);
ALTER TABLE fewo_lodging_image ADD CONSTRAINT FK_D49F667187335AF1 FOREIGN KEY (lodging_id) REFERENCES fewo_lodging (id) ON DELETE SET NULL;
ALTER TABLE fewo_price ADD CONSTRAINT FK_3DE13C987335AF1 FOREIGN KEY (lodging_id) REFERENCES fewo_lodging (id);
ALTER TABLE fewo_price ADD CONSTRAINT FK_3DE13C94EC001D1 FOREIGN KEY (season_id) REFERENCES fewo_season (id) ON DELETE SET NULL;
ALTER TABLE fewo_reservation ADD CONSTRAINT FK_36537F7487335AF1 FOREIGN KEY (lodging_id) REFERENCES fewo_lodging (id) ON DELETE SET NULL;
ALTER TABLE page ADD fewo_lodging INT DEFAULT NULL;
ALTER TABLE page ADD CONSTRAINT FK_140AB6209629C357 FOREIGN KEY (fewo_lodging) REFERENCES fewo_lodging (id) ON DELETE SET NULL;
CREATE UNIQUE INDEX UNIQ_140AB6209629C357 ON page (fewo_lodging);
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Apartment');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Bauernhof');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Bungalow');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Campingplatz');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Chalet');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Ferienanlage');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Ferienhaus');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Ferienwohnung');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Finca');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Hotel');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Hütte');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Pension');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Schloss');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Villa');
git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3348 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
2ebd38d3d7
commit
ab026b752f
57 changed files with 6507 additions and 25 deletions
144
trunk/src/AppBundle/Export/FewoBookingSternToursCrmExporter.php
Normal file
144
trunk/src/AppBundle/Export/FewoBookingSternToursCrmExporter.php
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
<?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)
|
||||
{
|
||||
$lead = $this->createLead($fewoBookingRequest);
|
||||
if ($lead === null)
|
||||
{
|
||||
$this->warn('Failed creating lead in CRM', $fewoBookingRequest, Logger::ERROR);
|
||||
return false;
|
||||
}
|
||||
$bookingUrl = $this->createBooking($fewoBookingRequest, $fewoLodging, $fewoPrice, $lead['customer_id'], $lead['id']);
|
||||
if ($bookingUrl === false)
|
||||
{
|
||||
$this->warn('Failed creating booking in CRM', $fewoBookingRequest, Logger::ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
if(!$this->createTraveler($bookingUrl, $fewoBookingRequest))
|
||||
{
|
||||
$this->warn('Failed creating traveler in CRM.', $fewoBookingRequest);
|
||||
}
|
||||
*/
|
||||
|
||||
return $bookingUrl;
|
||||
}
|
||||
|
||||
private function createLead(FewoBookingRequest $fewoBookingRequest)
|
||||
{
|
||||
$resp = $this->httpPost('lead', ['lead' => [
|
||||
'customerForm' => [
|
||||
'salutation_id' => $fewoBookingRequest->getSalutation(),
|
||||
'name' => $fewoBookingRequest->getLastName(),
|
||||
'firstname' => $fewoBookingRequest->getFirstName(),
|
||||
'street' => $fewoBookingRequest->getStreetAddress(),
|
||||
'zip' => $fewoBookingRequest->getZipCode(),
|
||||
'city' => $fewoBookingRequest->getCity(),
|
||||
'country_id' => $fewoBookingRequest->getNation(),
|
||||
'phone' => $fewoBookingRequest->getPhone(),
|
||||
'fax' => $fewoBookingRequest->getFax(),
|
||||
'email' => $fewoBookingRequest->getEmail()
|
||||
],
|
||||
'request_date' => (new \DateTime())->format('Y-m-d'),
|
||||
'sf_guard_user_id' => self::API_USER_ID,
|
||||
'status_id' => 7, // 'gebucht'
|
||||
'travelperiod_start' => $fewoBookingRequest->getFromDate()->format('Y-m-d'),
|
||||
'travelperiod_end' => $fewoBookingRequest->getToDate()->format('Y-m-d'),
|
||||
//'travelcategory_id'
|
||||
'is_closed' => 1,
|
||||
'website_id' => self::WEBSITE_ID,
|
||||
'initialcontacttype_id' => 14,
|
||||
// 'travelperiod_length
|
||||
'remarks' => $fewoBookingRequest->getNotes()
|
||||
]]);
|
||||
|
||||
if ($resp['success'])
|
||||
{
|
||||
$ret = $this->httpGet($resp['location']);
|
||||
if ($ret == null)
|
||||
{
|
||||
$this->warn('Failed retrieving newly created lead object', $fewoBookingRequest);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function createBooking(FewoBookingRequest $fewoBookingRequest, FewoLodging $lodging, FewoPrice $price, $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(),
|
||||
'sf_guard_user_id' => self::API_USER_ID,
|
||||
'branch_id' => 4,
|
||||
'website_id' => self::WEBSITE_ID,
|
||||
'title' => $lodging->getName(),
|
||||
'start_date' => $fewoBookingRequest->getFromDate()->format('Y-m-d'),
|
||||
'end_date' => $fewoBookingRequest->getToDate()->format('Y-m-d'),
|
||||
'pax' => $fewoBookingRequest->getTravelerCount(),
|
||||
'travel_number' => $lodging->getName()." - ".$price->getSeason()->getName(),
|
||||
'price' => $fewoBookingRequest->getTotalPrice(),
|
||||
|
||||
'participant_salutation_id' => $fewoBookingRequest->getSalutation(),
|
||||
'participant_name' => $fewoBookingRequest->getLastName(),
|
||||
'participant_firstname' => $fewoBookingRequest->getFirstName(),
|
||||
//'participant_birthdate' => $bookingRequest->getTravelers()[0]->getBirthDate(),
|
||||
]]);
|
||||
|
||||
if (!$resp['success'])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $resp['location'];
|
||||
}
|
||||
|
||||
private function createTraveler($bookingUrl, FewoBookingRequest $fewoBookingRequest)
|
||||
{
|
||||
$resp = $this->httpPost($bookingUrl .'/participant.json', ['participant' => [
|
||||
'participant_salutation_id' => $fewoBookingRequest->getSalutation(),
|
||||
'participant_name' => $fewoBookingRequest->getLastName(),
|
||||
'participant_firstname' => $fewoBookingRequest->getFirstName(),
|
||||
//'participant_birthdate' => $traveler->getBirthDate(),
|
||||
]], true);
|
||||
return $resp['success'];
|
||||
}
|
||||
|
||||
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