31 lines
976 B
PHP
31 lines
976 B
PHP
<?php
|
|
|
|
use app\models\OrderBooking;
|
|
use app\services\JR;
|
|
|
|
$g = $_GET;
|
|
$event_id = $_GET['event_id'] ?? null;
|
|
$ticket_token = $_GET['ticket_token'] ?? null;
|
|
$user = \app\services\Auth::getUserByToken();
|
|
if($event_id && $user) {
|
|
$booking = OrderBooking::getBookingByHashId($ticket_token);
|
|
if($event_id != $booking->event_id) {
|
|
JR::message(JR::error, ['wrong_event' => 1]);
|
|
}
|
|
if(empty($_GET['validated_count'])) {
|
|
if ($booking->validated_count < $booking->tickets_count) {
|
|
JR::message(JR::done, $booking->responseData());
|
|
} else {
|
|
JR::message(JR::done, $booking->responseData());
|
|
}
|
|
} else {
|
|
$count = $booking->validated_count ?? 0;
|
|
$booking->validated_count = $count + $_GET['validated_count'];
|
|
$booking->last_validation_time = date('Y-m-d H:i:s');
|
|
$booking->save();
|
|
JR::message(JR::done, ['ready' => 1]);
|
|
}
|
|
} else {
|
|
JR::message(JR::not_authenticated);
|
|
}
|