Пример #1
0
 public function initOrders()
 {
     $cutomerOrders = new OrderQuery($this->doorGets);
     $cutomerOrders->filterByUserId($this->id);
     $cutomerOrders->find();
     $data = $cutomerOrders->_getEntities('array');
     $counter = 0;
     $amounts = array();
     $amountsProfit = array();
     if (!empty($data)) {
         foreach ($data as $order) {
             if ($order['status'] === 'payment_success') {
                 $counter++;
                 if (!array_key_exists($order['currency'], $amounts)) {
                     $amounts[$order['currency']] = 0.0;
                 }
                 $amounts[$order['currency']] += (double) $order['amount_with_shipping'];
                 if (!array_key_exists($order['currency'], $amountsProfit)) {
                     $amountsProfit[$order['currency']] = 0.0;
                 }
                 $amountsProfit[$order['currency']] += (double) $order['amount_profit'];
             }
         }
     }
     $this->countSuccess = $counter;
     if (!empty($amounts)) {
         foreach ($amounts as $currency => $amount) {
             $this->amountSuccess .= $this->doorGets->setCurrencyIcon($amount, $currency) . ' | ';
         }
         $this->amountSuccess = substr($this->amountSuccess, 0, -2);
     }
     if (!empty($amountsProfit)) {
         foreach ($amountsProfit as $currency => $amount) {
             $this->amountProfit .= $this->doorGets->setCurrencyIcon($amount, $currency) . ' | ';
         }
         $this->amountProfit = substr($this->amountProfit, 0, -2);
     }
     return $data;
 }