src/Controller/EventsController.php line 227

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\EntityOtpusk\Cruises;
  4. use App\EntityOtpusk\Events;
  5. use App\EntityOtpusk\Operators;
  6. use App\EntityOtpusk\Statistics;
  7. use App\EntityOtpusk\Thotels AS Hotels;
  8. use App\EntityOtpusk\Tcities as City;
  9. use App\EntityOtpusk\Tcountries as Country;
  10. use App\Repository\AdvertsRepository;
  11. use App\Repository\ManagerLogsRepository;
  12. use App\Repository\ApikeyRepository;
  13. use App\Repository\StatisticsRepository;
  14. use App\Service\EventsService;
  15. use App\Service\StatisticsService;
  16. use App\Service\Ipv6Service;
  17. use App\Exception\EventsException;
  18. use Nelmio\ApiDocBundle\Annotation as ApiDoc;
  19. use OpenApi\Annotations as OA;
  20. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  21. use Symfony\Component\HttpFoundation\JsonResponse;
  22. use Symfony\Component\HttpFoundation\Request;
  23. use Symfony\Component\HttpKernel\KernelInterface;
  24. use Symfony\Component\Routing\Annotation\Route;
  25. use Symfony\Component\Validator\Constraints\Country as Countries;
  26. /**
  27.  * Публічний прийом статистики показів і взаємодій з рекламою.
  28.  *
  29.  * @ApiDoc\Areas({"default"})
  30.  */
  31. class EventsController extends AbstractController
  32. {
  33.     /**
  34.      * @Route("/api/events", name="event", methods={"GET"})
  35.      *
  36.      * @OA\Get(
  37.      *     summary="Взаємодія з рекламою",
  38.      *     description="Приймає взаємодію користувача з рекламним оголошенням агенції (телефон, форма, перехід тощо), визначає ціну за правилами білінгу й записує подію в ClickHouse. Увага: помилки валідації повертаються з HTTP 200 і status=error. Контракт: Docs/reference/B-advertising-billing.md, розд. 2.",
  39.      *     tags={"Реклама"},
  40.      *     @OA\Parameter(name="offerId", in="query", required=true, description="Ідентифікатор оферу: перші 20 символів - id оферу, хвіст після 20-го символу - код складу туристів.", @OA\Schema(type="string")),
  41.      *     @OA\Parameter(name="advertId", in="query", required=true, description="ID оголошення; має існувати й мати агенцію.", @OA\Schema(type="integer")),
  42.      *     @OA\Parameter(name="regionId", in="query", required=true, description="ID міста користувача.", @OA\Schema(type="integer")),
  43.      *     @OA\Parameter(name="officeId", in="query", required=true, description="ID офісу агенції.", @OA\Schema(type="integer")),
  44.      *     @OA\Parameter(name="event", in="query", required=true, description="Тип події (назва з Events::EVENTS). Невідома назва трактується як view (0). Коди: view=0, phone=1, viber=2, telegram=3, form=4, callback=5, order=6, url=7, logo=8, title=9, map*=10-19. Псевдоніми: showPhoneAd, showViberAd, showTelegramAd, showFormAd, sendFormAd, sentFormAd, showCallbackd, showOrderAd, showUrlAd, clickTitleAd, showLogoAd, showTitleAd, а також їх варіанти з префіксом api.", @OA\Schema(type="string", enum={"view","phone","viber","telegram","form","callback","order","url","logo","title","map","mapphone","mapviber","maptelegram","mapform","mapcallback","maporder","mapurl","maplogo","maptitle","showPhoneAd","showViberAd","showTelegramAd","showFormAd","showCallbackd","showOrderAd","showUrlAd","showLogoAd","showTitleAd","clickTitleAd","sendFormAd","sentFormAd"})),
  45.      *     @OA\Parameter(name="cruiseId", in="query", required=false, description="Якщо більше 0 - подія екскурсійного туру (cruise), інакше tour.", @OA\Schema(type="integer", default=0)),
  46.      *     @OA\Parameter(name="agencyId", in="query", required=false, description="ID агенції; за замовчуванням - агенція оголошення.", @OA\Schema(type="integer")),
  47.      *     @OA\Parameter(name="operatorId", in="query", required=false, description="ID оператора; за замовчуванням береться з оферу.", @OA\Schema(type="integer", default=0)),
  48.      *     @OA\Parameter(name="people", in="query", required=false, description="Склад туристів; має пріоритет над суфіксом offerId.", @OA\Schema(type="integer")),
  49.      *     @OA\Parameter(name="cid", in="query", required=false, description="Google Analytics client_id.", @OA\Schema(type="string")),
  50.      *     @OA\Parameter(name="sid", in="query", required=false, description="Google Analytics session_id (не зберігається).", @OA\Schema(type="string")),
  51.      *     @OA\Parameter(name="eventPosition", in="query", required=false, description="Позиція; сервер перезаписує кодом причини обнулення ціни.", @OA\Schema(type="integer", default=0)),
  52.      *     @OA\Response(
  53.      *         response=200,
  54.      *         description="Подію прийнято (status=success) або відхилено валідацією (status=error, також HTTP 200). Поле message для помилок: Empty offerId, Empty advertId, No found advertId, No found agency, Empty regionId, Empty officeId, Empty event.",
  55.      *         @OA\JsonContent(
  56.      *             @OA\Property(property="status", type="string", enum={"success","error"}, example="success"),
  57.      *             @OA\Property(property="message", type="string", example="Empty offerId", description="Лише для status=error.")
  58.      *         )
  59.      *     ),
  60.      *     @OA\Response(response=500, description="Внутрішня помилка сервера.")
  61.      * )
  62.      * @param Request               $request
  63.      * @param KernelInterface       $kernel
  64.      * @param AdvertsRepository     $advertsRepository
  65.      * @param ManagerLogsRepository $managerLogsRepository
  66.      * @param EventsService         $eventsService
  67.      * @return JsonResponse
  68.      */
  69.     public function eventsAdd(
  70.         Request $request,
  71.         KernelInterface $kernel,
  72.         AdvertsRepository $advertsRepository,
  73.         ManagerLogsRepository $managerLogsRepository,
  74.         EventsService $eventsService
  75.     )
  76.     {
  77.         try {
  78.             if (empty($request->get('offerId'))) {
  79.                 throw new EventsException('Empty offerId');
  80.             }
  81.             if (empty($request->get('advertId'))) {
  82.                 throw new EventsException('Empty advertId');
  83.             }
  84.             $advertInfo = $advertsRepository->findOneBy(['id' => $request->get('advertId')]);
  85.             if (!$advertInfo) {
  86.                 throw new EventsException('No found advertId');
  87.             }
  88.             if (!$advertInfo->getAgency()) {
  89.                 throw new EventsException('No found agency');
  90.             }
  91.             if (empty($request->get('regionId'))) {
  92.                 throw new EventsException('Empty regionId');
  93.             }
  94.             if (empty($request->get('officeId'))) {
  95.                 throw new EventsException('Empty officeId');
  96.             }
  97.             if (empty($request->get('event'))) {
  98.                 throw new EventsException('Empty event');
  99.             }
  100.             $cruiseId = $request->get('cruiseId');
  101.             if ($cruiseId > 0) {
  102.                 $action = 'cruise';
  103.             } else {
  104.                 $action = 'tour';
  105.             }
  106.             $event = new Events();
  107.             $event->setEventTypeName($request->get('event'));
  108.             header('x-event: '.$request->get('event').'='.$event->getEventType());
  109.             if (is_null($event->getEventType())) {
  110.                 throw new EventsException('No valid event');
  111.             }
  112.             $event->setEventAction($action);
  113.             //$event->setHotelId($request->get('hotelId'));
  114.             $event->setCruiseId($request->get('cruiseId', 0));
  115.             $event->setAdvertId($request->get('advertId'));
  116.             $advert = $advertsRepository->find($request->get('advertId'));
  117.             $agencyId = $advert->getAgency()->getId();
  118.             $event->setAgencyId($request->get('agencyId', $agencyId)); // не обязательно, если что найдет из advertId
  119.             $event->setRegionId($request->get('regionId'));
  120.             $offerId = $request->get('offerId');
  121.             $people = (int)substr($offerId, 20);
  122.             if (empty($people)) $people = $request->get('people');
  123.             $offerId = substr($offerId, 0, 20);
  124.             $event->setOfferId($offerId);
  125.             $event->setCid($request->get('cid'));
  126.             $event->setOperatorId($request->get('operatorId', 0)); // не обязательно, если что найдет из offerId
  127.             $event->setOfficeId($request->get('officeId'));
  128.             $event->setPeople($request->get('people', $people));
  129.             $event->setIp(Ipv6Service::ip2long($request->getClientIp()));
  130.             $event->setEventDate(new \DateTime());
  131.             $event->setEventPosition($request->get('eventPosition', 0)); // не обязательно
  132.             $price = $eventsService->saveEvent($event, $request->get('event'));
  133.             header('X-eventPrice: '.$event->getEventPrice());
  134.             header('X-eventPosition: '.$event->getEventPosition());
  135.             $res = array();
  136.             if (isset($_COOKIE['DM']) || $kernel->isDebug()) {
  137.                 $res['_event'] = $event ? $event->_toArray() : null;
  138.             }
  139.             if (isset($_COOKIE['DM']) || $kernel->isDebug()) {
  140.                 $res['_price'] = $price;
  141.             }
  142.             $eventsService->sendGA($request->get('cid'), $request->get('sid'), $event, $request->get('event'));
  143.             //$price = 0;
  144.             return new JsonResponse([
  145.                     'status' => 'success',
  146.                     //'price'  => $price,
  147.                 ] + $res);
  148.         } catch (EventsException $e) {
  149.             return new JsonResponse([
  150.                 'status'  => 'error',
  151.                 'message' => $e->getMessage(),
  152.             ]);
  153.         }
  154.         return new JsonResponse([
  155.             'status' => 'error',
  156.             'text'   => 'Запрос не отправлен'
  157.         ]);
  158.     }
  159.     /**
  160.      * @Route("/api/stats", name="stats", methods={"GET"})
  161.      *
  162.      * @OA\Get(
  163.      *     summary="Запис показів",
  164.      *     description="Приймає подію перегляду (тур, пошук, готель, екскурсійний тур, чартер) і записує її в ClickHouse. Контракт: Docs/reference/C-statistics-marketplace.md, розд. 2.",
  165.      *     tags={"Статистика"},
  166.      *     @OA\Parameter(name="source", in="query", required=true, description="Джерело: ім'я enum або числовий код (краще код). Коди й назви: 1 otpusk — tat.ua, 2 moituristy — crm.moituristy, 3 tat — crm.tat, 4 5stars — crm.5stars (припинено), 5 nakanikuly — crm.nakanikuly, 6 travelon.lt, 7 travelon.lv, 8 otpusk.md, 9 easybooking — crm.easybooking (припинено), 10 multitour — crm.multitour.pl, 11 multitour.pl — сайт multitour.pl, 12 crm.multitour.io.", @OA\Schema(type="string", enum={"otpusk","moituristy","tat","5stars","nakanikuly","travelon.lt","travelon.lv","otpusk.md","easybooking","multitour","multitour.pl","crm.multitour.io","1","2","3","4","5","6","7","8","9","10","11","12"})),
  167.      *     @OA\Parameter(name="action", in="query", required=true, description="Дія: ключ або числовий код. Коди: tour=1, search=2, hotel=3, cruise=4, charter=5, charter-search=6.", @OA\Schema(type="string", enum={"tour","search","hotel","cruise","charter","charter-search","1","2","3","4","5","6"})),
  168.      *     @OA\Parameter(name="id", in="query", required=true, description="ID готелю/оферу/круїзу, не 0. Для дій 1-3 - у межах 5000..999999, готель має існувати.", @OA\Schema(type="integer")),
  169.      *     @OA\Parameter(name="countryId", in="query", required=true, description="ID країни, не 0. Для дій 1-3 має збігатися з країною готелю.", @OA\Schema(type="integer")),
  170.      *     @OA\Parameter(name="operatorId", in="query", required=false, description="ID оператора. Обов'язковий для всіх дій, крім 3 (hotel).", @OA\Schema(type="integer")),
  171.      *     @OA\Parameter(name="checkIn", in="query", required=false, description="Дата заїзду: не раніше поточного моменту і не пізніше ніж за 2 роки. Без параметра пишеться 2000-01-01.", @OA\Schema(type="string", format="date")),
  172.      *     @OA\Parameter(name="nights", in="query", required=false, description="Кількість ночей, 0..33.", @OA\Schema(type="integer", minimum=0, maximum=33)),
  173.      *     @OA\Parameter(name="fromCity", in="query", required=false, description="ID міста вильоту (перекриває formCity).", @OA\Schema(type="integer")),
  174.      *     @OA\Parameter(name="formCity", in="query", required=false, description="Застарілий псевдонім fromCity (друкарська помилка збережена для сумісності).", @OA\Schema(type="integer")),
  175.      *     @OA\Parameter(name="food", in="query", required=false, description="Харчування; інші значення ігноруються.", @OA\Schema(type="string", enum={"ob","bb","hb","fb","ai","uai"}, default="ob")),
  176.      *     @OA\Parameter(name="transport", in="query", required=false, description="Транспорт; інші значення ігноруються.", @OA\Schema(type="string", enum={"no","air","bus","train","trainbus","ship"}, default="no")),
  177.      *     @OA\Parameter(name="roomId", in="query", required=false, description="ID номера.", @OA\Schema(type="integer")),
  178.      *     @OA\Parameter(name="price", in="query", required=false, description="Ціна, не менше 0.", @OA\Schema(type="number", minimum=0)),
  179.      *     @OA\Parameter(name="people", in="query", required=false, description="Склад туристів; якщо не задано, береться з суфікса offerId після 20-го символу.", @OA\Schema(type="integer")),
  180.      *     @OA\Parameter(name="offerId", in="query", required=false, description="ID оферу; використовується лише для визначення people.", @OA\Schema(type="string")),
  181.      *     @OA\Parameter(name="cid", in="query", required=false, description="Google Analytics client_id.", @OA\Schema(type="string")),
  182.      *     @OA\Parameter(name="position", in="query", required=false, description="Позиція у видачі, не менше 0.", @OA\Schema(type="integer", minimum=0, default=0)),
  183.      *     @OA\Parameter(name="key", in="query", required=false, description="SPEC-T14: ключ API клієнта модулів; сервер переводить у apiKeyId, невідомий ключ → 0.", @OA\Schema(type="string")),
  184.      *     @OA\Parameter(name="aid", in="query", required=false, description="SPEC-T14: id турфірми (агенції), до 64 символів.", @OA\Schema(type="string")),
  185.      *     @OA\Parameter(name="searchId", in="query", required=false, description="SPEC-T14: id пошуку [A-Za-z0-9_-]{1,64}; зв'язує search → hotel/tour і charter-search → charter.", @OA\Schema(type="string")),
  186.      *     @OA\Parameter(name="ref", in="query", required=false, description="SPEC-T14: повна адреса сторінки події; без параметра береться заголовок Referer. Зберігаються домен і шлях без query.", @OA\Schema(type="string")),
  187.      *     @OA\Response(
  188.      *         response=200,
  189.      *         description="Подію записано.",
  190.      *         @OA\JsonContent(@OA\Property(property="status", type="string", example="success"))
  191.      *     ),
  192.      *     @OA\Response(
  193.      *         response=400,
  194.      *         description="Помилка валідації. Можливі message: Empty source, Empty action, Empty id, Error source, Error source!, Error action, Error action!, Error id, Error country, Error operator, Error operator: <код дії>, Error operator., Error operator!, Error hotel, Error hotel., Error checkIn, Error nights, Error price, Error position.",
  195.      *         @OA\JsonContent(
  196.      *             @OA\Property(property="status", type="string", example="error"),
  197.      *             @OA\Property(property="message", type="string", example="Empty source")
  198.      *         )
  199.      *     ),
  200.      *     @OA\Response(response=500, description="Внутрішня помилка сервера.")
  201.      * )
  202.      * @param Request               $request
  203.      * @param KernelInterface       $kernel
  204.      * @param ManagerLogsRepository $managerLogsRepository
  205.      * @param StatisticsRepository  $statisticsRepository
  206.      * @param StatisticsService     $statisticsService
  207.      * @param ApikeyRepository      $apikeyRepository
  208.      * @return JsonResponse
  209.      */
  210.     public function statsAdd(
  211.         Request $request,
  212.         KernelInterface $kernel,
  213.         ManagerLogsRepository $managerLogsRepository,
  214.         StatisticsRepository $statisticsRepository,
  215.         StatisticsService $statisticsService,
  216.         ApikeyRepository $apikeyRepository
  217.     )
  218.     {
  219.         try {
  220.             if (empty($request->get('source'))) {
  221.                 throw new EventsException('Empty source');
  222.             }
  223.             if (empty($request->get('action'))) {
  224.                 throw new EventsException('Empty action');
  225.             }
  226.             if (empty($request->get('id'))) {
  227.                 throw new EventsException('Empty id');
  228.             }
  229.             $stats = new Statistics();
  230.             $sourses = $stats->getEventSources();
  231.             $sourse = $request->get('source');
  232.             if (is_numeric($sourse)) {
  233.                 $sourses = array_flip($sourses);
  234.                 if (!isset($sourses[$sourse])) throw new EventsException('Error source');
  235.                 $stats->setEventSource($sourse);
  236.             } else if (!isset($sourses[$sourse])) {
  237.                 throw new EventsException('Error source!');
  238.             }
  239.             else $stats->setEventSource($sourses[$sourse]);
  240.             $actions = $stats->getEventActions();
  241.             $action = $request->get('action');
  242.             if (is_numeric($action)) {
  243.                 $actions = array_flip($actions);
  244.                 if (!isset($actions[$action])) throw new EventsException('Error action');
  245.                 $stats->setEventAction($action);
  246.             } else if (!isset($actions[$action])) {
  247.                 throw new EventsException('Error action!');
  248.             }
  249.             else $stats->setEventAction($actions[$action]);
  250.             $res = array();
  251.             if (empty((int)$request->get('id'))) {
  252.                 throw new EventsException('Error id');
  253.             }
  254.             if (empty((int)$request->get('countryId'))) {
  255.                 throw new EventsException('Error country');
  256.             }
  257.             if ($stats->getEventAction()!=3 && empty((int)$request->get('operatorId'))) {
  258.                 throw new EventsException('Error operator: '.$stats->getEventAction());
  259.             }
  260.             $stats->setId((int)$request->get('id'));
  261.             if ($request->get('operatorId')) {
  262.                 $stats->setOperatorId((int)$request->get('operatorId'));
  263.             }
  264.             if (in_array($stats->getEventAction(), [5,6])) {
  265.                 if (empty($request->get('operatorId'))){
  266.                     throw new EventsException('Error operator');
  267.                 }
  268.                 $stats->setCountryId((int)$request->get('countryId'));
  269.             } elseif ($stats->getEventAction() == 4) {
  270.                 if (empty($request->get('operatorId'))){
  271.                     throw new EventsException('Error operator');
  272.                 }
  273.                 $cruise = $statisticsService->getCruiseCountry($stats);
  274.                 /** @var $cruise Cruises */
  275.                 if (!$cruise || empty($cruise->getOperatorId())) {
  276.                     throw new EventsException('Error operator.');
  277.                 }
  278.                 if ((int)$request->get('operatorId') != $cruise->getOperatorId()){
  279.                     throw new EventsException('Error operator!');
  280.                 }
  281.                 $stats->setCountryId((int)$request->get('countryId'));
  282.             } else {
  283.                 if ((int)$request->get('id')<5000 || (int)$request->get('id')>999999) {
  284.                     throw new EventsException('Error hotel');
  285.                 }
  286.                 if ($stats->getEventAction()!=3) {
  287.                     $operator = $statisticsService->getOperator($stats);
  288.                     /** @var $operator Operators */
  289.                     if (!$operator || empty($operator->getId())) {
  290.                         throw new EventsException('Error operator: '.$stats->getEventAction());
  291.                     }
  292.                 }
  293.                 $geo = $statisticsService->getHotelCountry($stats);
  294.                 if (!isset($geo['hotel'])) {
  295.                     throw new EventsException('Error hotel.');
  296.                 }
  297.                 if (!isset($geo['city'])) {
  298.                     throw new EventsException('Error city.');
  299.                 }
  300.                 if (!isset($geo['country'])) {
  301.                     throw new EventsException('Error country.');
  302.                 }
  303.                 /** @var $hotel Hotels */
  304.                 $hotel = $geo['hotel'];
  305.                 if (!$hotel || empty($hotel->getId())) {
  306.                     throw new EventsException('Error hotel!');
  307.                 }
  308.                 $stats->setId($hotel->getId());
  309.                 /** @var $city City */
  310.                 $city = $geo['city'];
  311.                 if (!$city || empty($city->getId())) {
  312.                     throw new EventsException('Error city!');
  313.                 }
  314.                 //$stats->setCityId($city->getId());
  315.                 /** @var $country Country */
  316.                 $country = $geo['country'];
  317.                 if (!$country || empty($country->getId())) {
  318.                     throw new EventsException('Error country!');
  319.                 }
  320.                 if ((int)$request->get('countryId') != $country->getId()){
  321.                     throw new EventsException('Error country');
  322.                 }
  323.                 $stats->setCountryId($country->getId());
  324.             }
  325.             if ($request->get('formCity')) $stats->setFromCityId((int)$request->get('formCity'));
  326.             if ($request->get('checkIn')) {
  327.                 if (strtotime($request->get('checkIn')) < time() || strtotime($request->get('checkIn'))>mktime(0,0,0,date('m'),date('d'),date('Y')+2)){
  328.                     throw new EventsException('Error checkIn');
  329.                 }
  330.                 $stats->setCheckIn(new \DateTime($request->get('checkIn')));
  331.             }
  332.             else $stats->setCheckIn(new \DateTime('2000-01-01'));
  333.             if ($request->get('nights')) {
  334.                 if ($request->get('nights')<0 || $request->get('nights')>33) {
  335.                     throw new EventsException('Error nights');
  336.                 }
  337.                 $stats->setNights((int)$request->get('nights'));
  338.             }
  339.             if ((int)$request->get('fromCity')) $stats->setFromCityId((int)$request->get('fromCity'));
  340.             if ($request->get('food') && in_array($request->get('food'),['ob','bb','hb','fb','ai','uai'])) $stats->setFood($request->get('food'));
  341.             if ($request->get('transport') && in_array($request->get('transport'),['no','air','bus','train','trainbus','ship'])) $stats->setTransport($request->get('transport'));
  342.             if ((int)$request->get('roomId')) $stats->setRoomId((int)$request->get('roomId'));
  343.             if ($request->get('price')) {
  344.                 if ((float)$request->get('price')<0) {
  345.                     throw new EventsException('Error price');
  346.                 }
  347.                 //$stats->setPrice($request->get('price'));
  348.                 $stats->setEventPrice($request->get('price'));
  349.             }
  350.             if ($request->get('people')>0) {
  351.                 $stats->setPeople((int)$request->get('people'));
  352.             } elseif ($request->get('offerId')) {
  353.                 $people = (int)substr($request->get('offerId'), 20);
  354.                 $stats->setPeople((int)$people);
  355.             }
  356.             if ($request->get('cid')) $stats->setCid($request->get('cid'));
  357.             // SPEC-T14: атрибуція (усі параметри необов'язкові, старі клієнти не зачеплені)
  358.             $stats->setApiKeyId($apikeyRepository->idByKey((string)$request->get('key', '')));
  359.             $stats->setAid((string)$request->get('aid', ''));
  360.             $stats->setSearchId((string)$request->get('searchId', ''));
  361.             $stats->setReferer($request->get('ref') ?: $request->headers->get('referer'));
  362.             $stats->setIp(Ipv6Service::ip2long($request->getClientIp()));
  363.             $stats->setEventDate(new \DateTime());
  364.             $stats->setEventTime(new \DateTime());
  365.             if ((int)$request->get('position')) {
  366.                 if ($request->get('position')<0) {
  367.                     throw new EventsException('Error position');
  368.                 }
  369.                 $stats->setEventPosition((int)$request->get('position', 0));
  370.             }
  371.             //dump($stats->_toArray());
  372.             $price = $statisticsService->saveStatistics($stats);
  373.             if (isset($_COOKIE['DM']) || $kernel->isDebug()) {
  374.                 $res['_stats'] = $stats ? $stats->_toArray() : null;
  375.             }
  376.             return new JsonResponse([
  377.                     'status' => 'success',
  378.                     //'price'  => $price,
  379.                 ] + $res);
  380.         } catch (EventsException $e) {
  381.             return new JsonResponse([
  382.                 'status'  => 'error',
  383.                 'message' => $e->getMessage(),
  384.             ], 400);
  385.         }
  386.         return new JsonResponse([
  387.             'status' => 'error',
  388.             'text'   => 'Запрос не отправлен'
  389.         ], 400);
  390.     }
  391. }