public function actionFinish()
 {
     $get = Yii::$app->request->get();
     if (isset($get["orderId"])) {
         if ($ch = @curl_init()) {
             $id_order = $get["orderId"];
             $order = Order::findOne(["bankOrderId" => $id_order]);
             if ($order->type_ticket == 1) {
                 $host = "https://securepayments.sberbank.ru";
                 $password = "******";
             } else {
                 if ($order->type_ticket == 2) {
                     $host = "https://securepayments.sberbank.ru";
                     $password = "******";
                 } else {
                     $host = "https://3dsec.sberbank.ru";
                     $password = "******";
                 }
             }
             @curl_setopt($ch, CURLOPT_URL, $host . '/payment/rest/getOrderStatus.do?userName=masterslavl-api&password='******'&orderId=' . $id_order);
             @curl_setopt($ch, CURLOPT_HEADER, false);
             @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
             @curl_setopt($ch, CURLOPT_USERAGENT, 'Masterslavl');
             $data = @curl_exec($ch);
             $dt = json_decode($data);
             @curl_close($ch);
             if (isset($dt->OrderStatus) and $dt->OrderStatus == 2) {
                 $id_rel = array();
                 $kids = array();
                 $adults = array();
                 $orderId = $get["orderId"];
                 $order = Order::findOne(["bankOrderId" => $orderId]);
                 $orderId = $order->id;
                 if ($order->type_ticket == 2) {
                     $price_kids = PriceSertificate::findOne(["name" => "kids"]);
                     $price_adult = PriceSertificate::findOne(["name" => "adult"]);
                     if ($order->status_sertificate == 0) {
                         for ($i = 0; $i < $order->count_kids; $i++) {
                             $RelOrderPeople = new RelOrderPeople();
                             $RelOrderPeople->id_order = $order->id;
                             $RelOrderPeople->id_people = 687;
                             $RelOrderPeople->type_people = 2;
                             $RelOrderPeople->type_tiket = $order->type_ticket;
                             $RelOrderPeople->qr = md5(time() . "687" . $order->id);
                             $RelOrderPeople->summ = $price_kids->price * 100;
                             $RelOrderPeople->save();
                         }
                         for ($i = 0; $i < $order->count_adult; $i++) {
                             $RelOrderPeople = new RelOrderPeople();
                             $RelOrderPeople->id_order = $order->id;
                             $RelOrderPeople->id_people = 356;
                             $RelOrderPeople->type_people = 1;
                             $RelOrderPeople->type_tiket = $order->type_ticket;
                             $RelOrderPeople->qr = md5(time() . "356" . $order->id);
                             $RelOrderPeople->summ = $price_adult->price * 100;
                             $RelOrderPeople->save();
                         }
                         $order->status_sertificate = 1;
                         $order->save();
                     }
                     $tikets_kids = RelOrderPeople::find()->where(["id_order" => $orderId, "type_people" => "2"])->all();
                     $tikets_adults = RelOrderPeople::find()->where(["id_order" => $orderId, "type_people" => "1"])->all();
                     $r_kids = array();
                     $r_adult = array();
                     $order_kids = array();
                     $order_adults = array();
                     $i = 1;
                     foreach ($tikets_kids as $val) {
                         $id_people_kids = $val->id_people;
                         $order_kids[$i] = $val;
                         $r_kids[$i] = Kids::findOne($id_people_kids);
                         $i++;
                     }
                     $i = 1;
                     foreach ($tikets_adults as $val) {
                         $id_people_adults = $val->id_people;
                         $order_adults[$i] = $val;
                         $r_adult[$i] = Parents::findOne($id_people_adults);
                         $i++;
                     }
                     if (count($r_adult) == 0) {
                         $r_adult = false;
                         //$r_adult = Parents::findOne($id_people_adults);
                     }
                     $i = 1;
                     foreach ($order_kids as $val) {
                         $kids[$val->id]["name"] = $r_kids[$i]->name;
                         $kids[$val->id]["surname"] = $r_kids[$i]->surname;
                         $kids[$val->id]["id"] = $r_kids[$i]->id;
                         $kids[$val->id]["id_rel"] = $val->id;
                         $kids[$val->id]["summ"] = $val->summ / 100;
                         $id_rel[] = $val->id;
                         $i++;
                     }
                     //var_dump($r_adult);
                     if ($r_adult != false) {
                         $i = 1;
                         foreach ($order_adults as $val) {
                             $adults[$val->id]["name"] = $r_adult[$i]->surname;
                             $adults[$val->id]["surname"] = $r_adult[$i]->name;
                             $adults[$val->id]["id"] = $r_adult[$i]->id;
                             $adults[$val->id]["id_rel"] = $val->id;
                             $adults[$val->id]["summ"] = $val->summ / 100;
                             $id_rel[] = $val->id;
                             $i++;
                         }
                     }
                 } elseif ($order->type_ticket == 6) {
                     $tikets_kids = RelOrderPeople::find()->where(["id_order" => $orderId, "type_people" => "2"])->all();
                     foreach ($tikets_kids as $val) {
                         $id_people_kids[] = $val->id_people;
                         $order_kids[$val->id_people] = $val;
                     }
                     $r_kids = Kids::find()->where(["id" => $id_people_kids])->all();
                     foreach ($r_kids as $val) {
                         $kids[$val->id]["name"] = $val->surname . " " . $val->name;
                         $kids[$val->id]["id"] = $val->id;
                         $kids[$val->id]["id_rel"] = $order_kids[$val->id]["id"];
                         $kids[$val->id]["summ"] = $order_kids[$val->id]["summ"] / 100;
                         $id_rel[] = $order_kids[$val->id]["id"];
                     }
                 } elseif ($order->id_ticket == 7) {
                     $tikets_kids = RelOrderPeople::find()->where(["id_order" => $orderId, "type_people" => "2"])->all();
                     foreach ($tikets_kids as $val) {
                         $id_people_kids[] = $val->id_people;
                         $order_kids[$val->id_people] = $val;
                     }
                     $r_kids = Kids::find()->where(["id" => $id_people_kids])->all();
                     foreach ($r_kids as $val) {
                         $kids[$val->id]["name"] = $val->name;
                         $kids[$val->id]["surname"] = $val->surname;
                         $kids[$val->id]["id"] = $val->id;
                         $kids[$val->id]["id_rel"] = $order_kids[$val->id]["id"];
                         $kids[$val->id]["summ"] = $order_kids[$val->id]["summ"] / 100;
                         $id_rel[] = $order_kids[$val->id]["id"];
                     }
                 } else {
                     $tikets_kids = RelOrderPeople::find()->where(["id_order" => $orderId, "type_people" => "2"])->all();
                     $tikets_adults = RelOrderPeople::find()->where(["id_order" => $orderId, "type_people" => "1"])->all();
                     $id_people_kids = array();
                     foreach ($tikets_kids as $val) {
                         $id_people_kids[] = $val->id_people;
                         $order_kids[$val->id_people] = $val;
                     }
                     foreach ($tikets_adults as $val) {
                         $id_people_adults[] = $val->id_people;
                         $order_adults[$val->id_people] = $val;
                     }
                     $r_kids = Kids::find()->where(["id" => $id_people_kids])->all();
                     if (isset($id_people_adults)) {
                         $r_adult = Parents::find()->where(["id" => $id_people_adults])->all();
                     } else {
                         $r_adult = false;
                     }
                     foreach ($r_kids as $val) {
                         $kids[$val->id]["name"] = $val->name;
                         $kids[$val->id]["surname"] = $val->surname;
                         $kids[$val->id]["id"] = $val->id;
                         $kids[$val->id]["id_rel"] = $order_kids[$val->id]["id"];
                         $kids[$val->id]["summ"] = $order_kids[$val->id]["summ"] / 100;
                         $id_rel[] = $order_kids[$val->id]["id"];
                     }
                     if ($r_adult != false) {
                         foreach ($r_adult as $val) {
                             $adults[$val->id]["name"] = $val->name;
                             $adults[$val->id]["surname"] = $val->surname;
                             $adults[$val->id]["id"] = $val->id;
                             $adults[$val->id]["id_rel"] = $order_adults[$val->id]["id"];
                             $adults[$val->id]["summ"] = $order_adults[$val->id]["summ"] / 100;
                             $id_rel[] = $order_adults[$val->id]["id"];
                         }
                     }
                 }
                 $txt = "";
                 $pdf_array = array();
                 foreach ($id_rel as $val) {
                     $_GET["id"] = $val;
                     $txt .= $this->getTiketContent();
                     $pdf_array[] = $this->getTiketContent();
                 }
                 $this->SendMail($pdf_array, $txt, $order->id);
                 return $this->render('finish', ["kids" => $kids, "order" => $order, "adults" => $adults, "order_id" => $order->id]);
             }
         }
     }
     return "Ошибка! Заказ не оплачен!";
 }