public function show() { $customer = $this->getCustomer(); if (!$customer) { return $this->responseError(['Данные не доступны'], 'Требуется авторизация', 401); } $api = new Api(); try { $key = $api->key(); Reporter::aggregateExternalInfoStart($key, $api->id(), $customer->get()->id); $client = $api->_cache_customer_info($key); $client['key'] = $key; try { $promo = $api->PromoCodeUse($key); } catch (ApiException $e) { if ($e->isDataError()) { $promo = null; } else { throw $e; } } $client['promo'] = $promo; Reporter::aggregateExternalInfoEnd($customer->get()->id); $customer->updateExternalInfo($client); return $this->responseSuccess($client, 'Данные клиента'); } catch (ApiException $e) { $api->cleanup(); return $this->responseException($e, 'Не удалось получить данные', 'customer'); } }
/** * личный кабинет * * @return \Illuminate\View\View */ public function index() { if (Input::get('orderNumber')) { return Redirect::to('/account'); } Customer::instance()->closeIfNotMember(); $promo = null; $mainPage = Config::get('app.url'); $langReplace = App::getLocale() == 'ru' ? 'index' : App::getLocale(); $mainPage = str_replace('#lang#', $langReplace, $mainPage); try { $api = new Api(); if (!$api->key()) { return \Redirect::to($mainPage); } $user = $api->ContrInfo(); $promo = $this->promoInfo($user, $promo); //$token = PaymentCloud::getToken($user['id']); $agbisKey = $api->key(); $customer = Customer::instance()->initByExternalId($user['id']); if (!$customer->get()) { Reporter::errorLostExternalCustomer($user['id'], $user); $customer->cleanup(); $api->cleanup(); return \Redirect::to($mainPage); } $saveCard = $customer->isSaveCard(); $cards = PaymentCloud::getCustomersCards($api->id()); } catch (ApiException $e) { return \Redirect::to($mainPage); } $invite = new InviteComponent(); return View::make('ac::index', ['user' => $user, 'promo' => $promo, 'agbisKey' => $agbisKey, 'saveCard' => $saveCard, 'invite_url' => $invite->url(), 'cards' => $cards]); }