minor changes
This commit is contained in:
@@ -46,22 +46,22 @@ class EventRegistrationManager extends BaseObject
|
||||
const CANCEL_TIME_LIMIT_REACHED = 15;
|
||||
|
||||
public static $STATES = [
|
||||
self::CARD_NOT_FOUND => "Kártya nem található",
|
||||
self::CUSTOMER_NOT_FOUND => "Vendég nem található",
|
||||
self::TICKET_NOT_FOUND => "Bérlet nem található",
|
||||
self::NO_FREE_SEATS => "Nincs szabad hely",
|
||||
self::EVENT_TYPE_NOT_FOUND => "Esemény típus nem található",
|
||||
self::TICKET_INSUFFICIENT => "Bérlet nem található",
|
||||
self::UNKNOWN_ERROR => "Ismeretlen hiba",
|
||||
self::MAX_SEAT_COUNT_EXCEEDED => "Nincs szabad hely",
|
||||
self::EVENT_UNAVAILABLE => "Esemény nem elérhető",
|
||||
self::ALREADY_REGISTERED => "Már regisztrálva van",
|
||||
self::EVENT_START_DATE_IN_PAST => "Az esemény már elkezdődött",
|
||||
self::CARD_NOT_FOUND => "Kártya nem található",
|
||||
self::CUSTOMER_NOT_FOUND => "Vendég nem található",
|
||||
self::TICKET_NOT_FOUND => "Bérlet nem található",
|
||||
self::NO_FREE_SEATS => "Nincs szabad hely",
|
||||
self::EVENT_TYPE_NOT_FOUND => "Esemény típus nem található",
|
||||
self::TICKET_INSUFFICIENT => "Bérlet nem található",
|
||||
self::UNKNOWN_ERROR => "Ismeretlen hiba",
|
||||
self::MAX_SEAT_COUNT_EXCEEDED => "Nincs szabad hely",
|
||||
self::EVENT_UNAVAILABLE => "Esemény nem elérhető",
|
||||
self::ALREADY_REGISTERED => "Már regisztrálva van",
|
||||
self::EVENT_START_DATE_IN_PAST => "Az esemény már elkezdődött",
|
||||
|
||||
self::EVENT_NOT_FOUND => "Esemény tnem található",
|
||||
self::ALREADY_CANCELLED => "Ez a regisztráció már lemndásra került",
|
||||
self::ALREADY_DELETED => "Ez a regisztráció már törlésre került",
|
||||
self::CANCEL_TIME_LIMIT_REACHED => "Ez a regisztráció már nem mondható le",
|
||||
self::EVENT_NOT_FOUND => "Esemény tnem található",
|
||||
self::ALREADY_CANCELLED => "Ez a regisztráció már lemndásra került",
|
||||
self::ALREADY_DELETED => "Ez a regisztráció már törlésre került",
|
||||
self::CANCEL_TIME_LIMIT_REACHED => "Ez a regisztráció már nem mondható le",
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -195,10 +195,12 @@ class EventRegistrationManager extends BaseObject
|
||||
public function loadRegistration($idRegistration, $idCustomer)
|
||||
{
|
||||
|
||||
$registration = EventRegistration::find()
|
||||
->andWhere(['id' => $idRegistration])
|
||||
->andWhere(['id_customer' => $idCustomer])
|
||||
->one();
|
||||
$query = EventRegistration::find()
|
||||
->andWhere(['id' => $idRegistration]);
|
||||
if ( isset($idCustomer)){
|
||||
$query->andWhere(['id_customer' => $idCustomer])
|
||||
}
|
||||
$registration = $query->one();
|
||||
if ($registration === null) {
|
||||
throw new NotFoundHttpException('The requested registration does not exist.');
|
||||
}
|
||||
@@ -209,9 +211,9 @@ class EventRegistrationManager extends BaseObject
|
||||
* @param EventRegistration $registration
|
||||
* @throws ServerErrorHttpException
|
||||
*/
|
||||
public function cancelRegistration($registration, $idCustomer)
|
||||
public function cancelRegistration($registration, $idCustomer, $reason)
|
||||
{
|
||||
if ( $registration->id_customer != $idCustomer){
|
||||
if (isset($idCustomer) && $registration->id_customer != $idCustomer) {
|
||||
throw new NotFoundHttpException('The requested registration does not exist.');
|
||||
}
|
||||
|
||||
@@ -229,13 +231,16 @@ class EventRegistrationManager extends BaseObject
|
||||
throw new BadRequestHttpException('The reservation is already deleted', self::EVENT_NOT_FOUND);
|
||||
}
|
||||
$tx = \Yii::$app->db->beginTransaction();
|
||||
try {
|
||||
$now = strtotime("now UTC");
|
||||
$now = strtotime("now UTC");
|
||||
|
||||
if ($reason != EventRegistration::CANCEL_REASON_CUSTOMER) {
|
||||
$timeUntilEventStart = $event->start - $now;
|
||||
if ( $timeUntilEventStart < 30 * 60){
|
||||
if ($timeUntilEventStart < 30 * 60) {
|
||||
throw new BadRequestHttpException('The reservation is already deleted', self::CANCEL_TIME_LIMIT_REACHED);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$registration->canceled_at = date('Y-m-d H:i:s', $now);
|
||||
$registration->save(false);
|
||||
@@ -310,7 +315,7 @@ class EventRegistrationManager extends BaseObject
|
||||
foreach ($registrations as $registration) {
|
||||
if (!isset($registration->deleted_at)) {
|
||||
/** @var EventRegistration $registration */
|
||||
$this->deleteRegistration($registration);
|
||||
$this->cancelRegistration($registration, null, EventRegistration::CANCEL_REASON_EVENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user