improve customer timetable
This commit is contained in:
@@ -10,8 +10,8 @@ use common\models\EventRegistration;
|
||||
use common\models\Ticket;
|
||||
use customerapi\models\available\EventInterval;
|
||||
use customerapi\models\registrations\EventRegistrationAvailable;
|
||||
use customerapi\models\details\EventRegistrationView;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Yii;
|
||||
use yii\base\BaseObject;
|
||||
use yii\db\ActiveRecord;
|
||||
@@ -37,6 +37,7 @@ class EventRegistrationManager extends BaseObject
|
||||
const UNKNOWN_ERROR = 7;
|
||||
const MAX_SEAT_COUNT_EXCEEDED = 8;
|
||||
const EVENT_UNAVAILABLE = 9;
|
||||
const ALREADY_REGISTERED = 10;
|
||||
|
||||
public static $STATES = [
|
||||
self::CARD_NOT_FOUND => 'CARD_NOT_FOUND',
|
||||
@@ -48,8 +49,7 @@ class EventRegistrationManager extends BaseObject
|
||||
self::UNKNOWN_ERROR => 'UNKNOWN_ERROR',
|
||||
self::MAX_SEAT_COUNT_EXCEEDED => 'MAX_SEAT_COUNT_EXCEEDED',
|
||||
self::EVENT_UNAVAILABLE => 'EVENT_UNAVAILABLE',
|
||||
|
||||
|
||||
self::ALREADY_REGISTERED => 'ALREADY_REGISTERED',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ class EventRegistrationManager extends BaseObject
|
||||
|
||||
$activeTickets = $card->getActiveTickets();
|
||||
if (count($activeTickets) === 0) {
|
||||
throw new NotFoundHttpException('Ticket not found', self::TICKET_NOT_FOUND);
|
||||
throw new NotFoundHttpException('Ticket not found1', self::TICKET_NOT_FOUND);
|
||||
}
|
||||
|
||||
/** @var Event $event */
|
||||
@@ -101,24 +101,23 @@ class EventRegistrationManager extends BaseObject
|
||||
}
|
||||
|
||||
//detect if customer is already registered to event
|
||||
/** @var EventRegistration[] $registrations */
|
||||
$registrations = $event->getActiveEventRegistrations()->all();
|
||||
|
||||
foreach ($registrations as $registration ){
|
||||
if ($registration->customer_id == $card->customer->id_customer){
|
||||
throw new BadRequestHttpException("Already registered");
|
||||
if ($registration->id_customer == $card->customer->id_customer){
|
||||
throw new BadRequestHttpException("Already registered", self::ALREADY_REGISTERED);
|
||||
}
|
||||
}
|
||||
|
||||
$selectedTicket = $eventType->findTicketAllowingEventType($activeTickets);
|
||||
|
||||
|
||||
if (!isset($selectedTicket)) {
|
||||
throw new NotFoundHttpException('Ticket not found', self::TICKET_INSUFFICIENT);
|
||||
throw new NotFoundHttpException('Ticket not found2', self::TICKET_INSUFFICIENT);
|
||||
}
|
||||
|
||||
if ($selectedTicket->hasOpenReservationCount()) {
|
||||
$selectedTicket->consumeReservationCount(1);
|
||||
}
|
||||
$selectedTicket->consumeReservationCount(1);
|
||||
|
||||
$selectedTicket->save();
|
||||
|
||||
$registration = new EventRegistration();
|
||||
|
||||
Reference in New Issue
Block a user