96 lines
3.1 KiB
PHP
96 lines
3.1 KiB
PHP
<?php
|
|
namespace App\Traits;
|
|
|
|
use App\Concession;
|
|
use App\Order;
|
|
|
|
trait MoneyTrait
|
|
{
|
|
protected function calcPrice($tickets){
|
|
$price = 0;
|
|
$porto = false;
|
|
$portoPrice = 100;
|
|
foreach ($tickets as $singleSeat) {
|
|
$priceSingleTicket = $this->calcPriceTicket($singleSeat);
|
|
$price += $priceSingleTicket;
|
|
if ($singleSeat->paymentmethod()->first()->name == "Überweisung") {
|
|
$porto = true;
|
|
}
|
|
if ($singleSeat->updated_at >= new \DateTime('2025-09-14')) {
|
|
$porto = 150;
|
|
}
|
|
}
|
|
if ($porto) {
|
|
$price += $portoPrice;
|
|
}
|
|
return $price;
|
|
}
|
|
|
|
protected function calcPriceTicket($singleSeatUser){
|
|
return $this->calcPriceTicketFromSingleSeat($singleSeatUser->singleSeat()->first(), $singleSeatUser->concession()->first()->id, $singleSeatUser->paymentmethod_id);
|
|
}
|
|
|
|
protected function calcPriceOrder($orderId){
|
|
$order = Order::find($orderId);
|
|
$tickets = array();
|
|
foreach($order->singleseatusers as $ssu){
|
|
array_push($tickets, $ssu);
|
|
}
|
|
return $this->calcPriceNoPorto($tickets);
|
|
}
|
|
|
|
private function calcPriceNoPorto($tickets){
|
|
$price = 0;
|
|
foreach ($tickets as $singleSeat) {
|
|
$priceSingleTicket = $this->calcPriceTicket($singleSeat);
|
|
$price += $priceSingleTicket;
|
|
}
|
|
return $price;
|
|
}
|
|
|
|
protected function calcPriceTicketFromSingleSeat($singleSeat, $conc_id, $paymentmethod_id){
|
|
$priceSingleTicket = 0;
|
|
|
|
if($singleSeat != null){
|
|
$cat = $singleSeat->category;
|
|
$event = $singleSeat->seat()->first()->event()->first();
|
|
$targetDate = new \DateTime('2025-05-06');
|
|
$hackyDate= new \DateTime('2025-02-12');
|
|
|
|
if ($singleSeat->seat_id >= 506 && $singleSeat->seat_id <= 517 && $singleSeat->updated_at->format('Y-m-d') != $hackyDate->format('Y-m-d') && $singleSeat->updated_at < $targetDate){
|
|
// sommertheater 2025
|
|
// frühbuchpreis still applies
|
|
if ($cat == 'a') {
|
|
$priceSingleTicket = 25;
|
|
} else if ($cat == 'b') {
|
|
$priceSingleTicket = 20;
|
|
}
|
|
|
|
|
|
}else{
|
|
$priceSingleTicket = 0;
|
|
if ($cat == 'a') {
|
|
$priceSingleTicket = $event->price_cat_a;
|
|
} else if ($cat == 'b') {
|
|
$priceSingleTicket = $event->price_cat_b;
|
|
} else {
|
|
$priceSingleTicket = $event->price_cat_c;
|
|
}
|
|
if ($priceSingleTicket == 0) $priceSingleTicket = $event->price_cat_a;
|
|
|
|
}
|
|
$concession = Concession::find($conc_id);
|
|
$priceSingleTicket = $priceSingleTicket * (100 - $concession->perc);
|
|
|
|
//only reduced value for silvesterevent
|
|
if($paymentmethod_id == 5 && ($event->id==1280 || $event->id == 1381 || $event->id == 1447)) { //kulturkarte
|
|
$priceSingleTicket -= 2500;
|
|
}else if($paymentmethod_id == 5) { //kulturkarte
|
|
$priceSingleTicket = 0;
|
|
}
|
|
|
|
}
|
|
return ceil(floor($priceSingleTicket)/10)*10; //round to next 10 cent
|
|
}
|
|
}
|