wip: first working version
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Form\Model\BookingData;
|
||||
class Booking
|
||||
{
|
||||
public ?int $id = null;
|
||||
public ?int $agencyId = null;
|
||||
public ?int $bookingNumber = null;
|
||||
public ?Travel $travelData = null;
|
||||
public ?string $status = null;
|
||||
@@ -22,11 +23,15 @@ class Booking
|
||||
public ?string $hotelName = null;
|
||||
public ?bool $document = null;
|
||||
public ?float $payment = null;
|
||||
public ?string $paymentId = null;
|
||||
public ?string $paymentType = null;
|
||||
public ?string $paymentLabel = null;
|
||||
public array $participantsStatus = [];
|
||||
public array $participants = [];
|
||||
public array $transportationServices = [];
|
||||
public array $additionalServices = [];
|
||||
public array $rooms = [];
|
||||
public array $pickups = [];
|
||||
public ?int $invoiceNumber = null;
|
||||
public ?float $totalPrice = null;
|
||||
|
||||
@@ -111,11 +116,11 @@ class Booking
|
||||
|
||||
public function toPayload(?BookingData $formData): array
|
||||
{
|
||||
// Reset services to participants mappings
|
||||
foreach ([...$this->additionalServices, ...$this->transportationServices] as $service) {
|
||||
// Reset mappings
|
||||
foreach ([...$this->additionalServices, ...$this->transportationServices, ...$this->pickups] as $service) {
|
||||
$service->mapping = [];
|
||||
}
|
||||
// Update mappings and add previously unselected services
|
||||
// Update mappings, add services and pickups
|
||||
foreach ($formData->participants as $participant) {
|
||||
$servicesToMap = [
|
||||
...$participant->courses,
|
||||
@@ -140,6 +145,12 @@ class Booking
|
||||
}
|
||||
$this->transportationServices[$service->id]->mapping[] = $participant->index;
|
||||
}
|
||||
if ('BUS' === $participant->transportationServiceTo->subType && null !== $selectedPickup = $participant->pickup) {
|
||||
if (false === isset($this->pickups[$selectedPickup->id])) {
|
||||
$this->pickups[$selectedPickup->id] = $selectedPickup;
|
||||
}
|
||||
$this->pickups[$selectedPickup->id]->mapping[] = $participant->index;
|
||||
}
|
||||
}
|
||||
// Remove services with empty mappings
|
||||
foreach ($this->additionalServices as $service) {
|
||||
@@ -166,15 +177,79 @@ class Booking
|
||||
$this->participants[$participant->index]->communication->mobile = $participant->mobile;
|
||||
}
|
||||
|
||||
return [
|
||||
$payload = [
|
||||
'idbuchung' => $this->id,
|
||||
'status' => $this->status,
|
||||
'idagentur' => $this->agencyId,
|
||||
'idreise' => $this->travelId,
|
||||
'idpartner' => $this->hotelId,
|
||||
'anmelder' => $this->applicant->toPayload(),
|
||||
'teilnehmerliste' => [],
|
||||
'beförderungen' => [],
|
||||
'unterbringungen' => [],
|
||||
'zusatzleistungen' => [],
|
||||
'zustiege' => [],
|
||||
'zahlung' => [
|
||||
'@idzahlungsart' => $this->paymentId,
|
||||
'@bezeichnung' => $this->paymentLabel,
|
||||
'@art' => $this->paymentType,
|
||||
],
|
||||
'teilnehmerliste' => [
|
||||
'teilnehmer' => [],
|
||||
],
|
||||
'zusatzleistungen' => [
|
||||
'zusatzleistung' => [],
|
||||
],
|
||||
'beförderungen' => [
|
||||
'beförderung' => [],
|
||||
],
|
||||
'ferienzielunterbringungen' => [
|
||||
'ferienzielunterbringung' => [],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($this->participants as $index => $participant) {
|
||||
$payload['teilnehmerliste']['teilnehmer'][] = [
|
||||
'@id' => $index,
|
||||
'status' => $this->participantsStatus[$index],
|
||||
...$participant->toPayload(),
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($this->additionalServices as $service) {
|
||||
$payload['zusatzleistungen']['zusatzleistung'][] = [
|
||||
'@idleistung' => $service->id,
|
||||
'@anzahl' => count($service->mapping),
|
||||
'@zuordnung' => implode(',', $service->mapping),
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($this->transportationServices as $service) {
|
||||
$payload['beförderungen']['beförderung'][] = [
|
||||
'@idleistung' => $service->id,
|
||||
'@anzahl' => count($service->mapping),
|
||||
'@zuordnung' => implode(',', $service->mapping),
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($this->rooms as $room) {
|
||||
$payload['ferienzielunterbringungen']['ferienzielunterbringung'][] = [
|
||||
'@idzimmer' => $room->id,
|
||||
'@kategorie' => $room->category,
|
||||
'@idverpflegung' => $room->boardId,
|
||||
'@anreise' => $room->dateFrom ? $room->dateFrom->format('d.m.Y') : null,
|
||||
'@abreise' => $room->dateTo ? $room->dateTo->format('d.m.Y') : null,
|
||||
'@anzahl' => count($room->mapping),
|
||||
'@zuordnung' => implode(',', $room->mapping),
|
||||
];
|
||||
}
|
||||
|
||||
if (0 < count($this->pickups)) {
|
||||
$payload['zustiege']['zustieg'] = [];
|
||||
foreach ($this->pickups as $pickup) {
|
||||
$payload['zustiege']['zustieg'][] = [
|
||||
'@idzustieg' => $pickup->id,
|
||||
'@anzahl' => count($pickup->mapping),
|
||||
'@zuordnung' => implode(',', $pickup->mapping),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\BusProNet\Model;
|
||||
|
||||
class BookingUpdate
|
||||
{
|
||||
public bool $valid = false;
|
||||
public ?string $status = null;
|
||||
public array $prices = [];
|
||||
public ?float $totalPrice = null;
|
||||
}
|
||||
@@ -44,6 +44,9 @@ class PersonalData
|
||||
'name' => $this->name,
|
||||
'anschrift' => $this->address->toPayload(),
|
||||
'kommunikation' => $this->communication->toPayload(),
|
||||
'sonstiges1' => $this->height,
|
||||
'sonstiges2' => $this->weight,
|
||||
'sonstiges3' => $this->shoeSize,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,5 @@ class Pickup
|
||||
public ?string $street = null;
|
||||
public ?\DateTimeImmutable $time = null;
|
||||
public ?float $price = null;
|
||||
public array $mapping = [];
|
||||
}
|
||||
@@ -5,6 +5,8 @@ namespace App\BusProNet\Model;
|
||||
class Room
|
||||
{
|
||||
public ?int $id = null;
|
||||
public ?string $category = null;
|
||||
public ?int $boardId = null;
|
||||
public ?string $code = null;
|
||||
public ?string $label = null;
|
||||
public ?\DateTimeImmutable $dateFrom = null;
|
||||
|
||||
Reference in New Issue
Block a user