/**
  * @param string   $key
  * @param Api      $api
  * @param Customer $customer
  *
  * @throws ApiException
  * @throws Exception
  */
 public function update($key, $api, $customer)
 {
     $this->info('начинаем сбор информации о клиенте: ' . $customer->id . ' [' . $customer->agbis_id . ']');
     Reporter::aggregateExternalInfoStart($key, $customer->agbis_id, $customer->id);
     $client = $api->ContrInfo($key);
     $this->line('... общая информация');
     $client['key'] = $key;
     try {
         $promo = $api->PromoCodeUse($key);
         $this->line('... промокод');
     } catch (ApiException $e) {
         if ($e->isDataError()) {
             $promo = null;
         } else {
             throw $e;
         }
     }
     $client['promo'] = $promo;
     $client['bonus'] = $api->Bonus($key)['bonus'];
     $this->line('... бонус');
     $client['deposit'] = $api->Deposit($key)['deposit'];
     $this->line('... депозитный счет');
     $client['orders'] = $api->Orders($key)['orders'];
     $this->line('... заказы');
     $client['history'] = $api->OrdersHistory($key)['orders'];
     $this->line('... история заказов');
     $client['tokens'] = $api->TokenPayList($key)['tokens'];
     $this->line('... токены платежей');
     Reporter::aggregateExternalInfoEnd($customer->id);
     $component = \Dryharder\Components\Customer::instance()->initByExternalId($client['id']);
     $this->line('... обновляем информацию в нашей базе данных');
     $component->updateExternalInfo($client);
     $this->info('закончили работу с клиентом');
 }
Example #2
0
 /**
  * история заказов
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function history()
 {
     try {
         $api = new Api();
         $orders = $api->OrdersHistory()['orders'];
     } catch (ApiException $e) {
         return $this->responseException($e);
     }
     $orders = $this->filterHistoryOrders($orders);
     $qnt = count($orders);
     $browser = View::make('ac::orders', ['orders' => $orders])->render();
     $mobile = View::make('ac::orders_mobile', ['orders' => $orders])->render();
     return Response::json(compact('browser', 'mobile', 'qnt'));
 }