/** * Add all lines of the account to the billrun object * @param boolean $update_lines whether to set the billrun key as the billrun stamp of the lines * @param int $start_time lower bound date to get lines from. A unix timestamp * @return array the stamps of the lines used to create the billrun */ public function addLines($update_lines = false, $start_time = 0, $flat_lines = array()) { Billrun_Factory::log()->log("Querying account " . $this->aid . " for lines...", Zend_Log::INFO); $account_lines = $this->getAccountLines($this->aid, $start_time, false); // Billrun_Factory::log()->log("Found " . count($account_lines) . " lines.", Zend_Log::DEBUG); Billrun_Factory::log("Processing account Lines {$this->aid}", Zend_Log::INFO); $updatedLines = array_merge($this->processLines($account_lines), $this->processLines($flat_lines)); $updateLinesStamps = array_keys($updatedLines); Billrun_Factory::log("Finished processing account {$this->aid} lines. Total: " . count($updatedLines), Zend_log::INFO); // Billrun_Factory::log()->log("Querying subscriber " . $sid . " for ggsn lines...", Zend_Log::DEBUG); // $subscriber_aggregated_data = $this->getSubscriberDataLines($sid, $start_time); // Billrun_Factory::log()->log("Finished querying subscriber " . $sid . " for ggsn lines", Zend_Log::DEBUG); // Billrun_Factory::log("Processing data lines for subscriber $sid", Zend_Log::DEBUG); // $data_lines_stamps = $this->updateAggregatedData($sid, $subscriber_aggregated_data); // Billrun_Factory::log("Finished processing data lines for subscriber $sid", Zend_Log::DEBUG); if ($update_lines) { Billrun_Factory::log("Updating account {$this->aid} lines with billrun stamp", Zend_Log::INFO); // $updatedLines = array_merge($updatedLines, $data_lines_stamps); asort($updateLinesStamps); $offset = 0; while (count($stamps_chunk = array_slice($updateLinesStamps, $offset, $this->updateStampChunk))) { $this->lines->update(array('stamp' => array('$in' => $stamps_chunk)), array('$set' => array('billrun' => $this->billrun_key)), array('multiple' => true)); $offset += $this->updateStampChunk; } Billrun_Factory::log("Finished updating account {$this->aid} lines with billrun stamp", Zend_Log::INFO); } $this->updateTotals(); return $updatedLines; }
/** * removes the transactions from the subscriber's balance to save space. * @param type $row */ public function removeBalanceTx($row) { $sid = $row['sid']; $billrun_key = Billrun_Util::getBillrunKey($row['urt']->sec); $query = array('billrun_month' => $billrun_key, 'sid' => $sid); $values = array('$unset' => array('tx.' . $row['stamp'] => 1)); $this->balances->update($query, $values); }