Example #1
0
 /**
  * Method to save fraud events on the fraud system once event triggered
  * 
  * @param array $row the line from lines collection
  * @param Mongodloid_Entity $balance 
  * @param string $usage_type, the usage type could be: call, data, mms, sms
  * @param array $rate
  * @param string $volume
  * @param Billrun_Calculator $calculator
  * 
  * @return boolean in case we are on chain return true if all ok and chain can continue, else return false if require to stop the plugin chain
  * 
  */
 public function afterUpdateSubscriberBalance($row, $balance, $rowPrice, $calculator)
 {
     if (is_null($balance)) {
         Billrun_Factory::log("Fraud plugin - balance is empty or not transfer to the plugin" . $row['stamp'] . ' | calculator ' . $calculator->getType(), Zend_Log::WARN);
         return true;
     }
     // if not plan to row - cannot do anything
     if (!isset($row['plan'])) {
         Billrun_Factory::log("Fraud plugin - plan not exists for line " . $row['stamp'], Zend_Log::ERR);
         return true;
     }
     // first check we are not on tap3, because we prevent intl fraud on nrtrde
     if ($row['type'] == 'tap3') {
         return true;
     }
     // check if row is too "old" to be considered as a fraud. TODO: consider lowering min_time in 1-2 days.
     if ($row['urt']->sec <= $this->min_time) {
         return true;
     }
     $thresholds = Billrun_Factory::config()->getConfigValue('fraud.thresholds', array());
     foreach ($thresholds as $type => $limits) {
         switch ($type) {
             case 'cost':
                 $this->costCheck($limits, $row, $balance, $rowPrice);
                 break;
             case 'usage':
                 $this->usageCheck($limits, $row, $balance);
                 break;
             default:
                 Billrun_Factory::log("Fraud plugin - method doesn't exists " . $type, Zend_Log::WARN);
                 break;
         }
     }
     return true;
 }
Example #2
0
 public function __construct($options = array())
 {
     parent::__construct($options);
     if (isset($options['calculator']['rate_mapping'])) {
         $this->rateMapping = $options['calculator']['rate_mapping'];
         //Billrun_Factory::log()->log("receive options : ".print_r($this->rateMapping,1),  Zend_Log::DEBUG);
     }
 }
Example #3
0
 public function __construct($options = array())
 {
     parent::__construct($options);
     if (isset($options['lines_query'])) {
         $this->linesQuery = $options['lines_query'];
     }
     $this->setCarriers();
 }
Example #4
0
 public function __construct($options = array())
 {
     parent::__construct($options);
     if (isset($options['peak_times'])) {
         $this->peakTimes = $options['peak_times'];
     }
     if (isset($options['wholesale_records'])) {
         $this->wholesaleRecords = $options['wholesale_records'];
     }
 }
Example #5
0
 /**
  * method to execute the calculate process
  * it's called automatically by the cli main controller
  */
 public function execute()
 {
     $possibleOptions = array('type' => false);
     if (($options = $this->_controller->getInstanceOptions($possibleOptions)) === FALSE) {
         return;
     }
     $this->_controller->addOutput("Loading Calculator");
     $calculator = Billrun_Calculator::getInstance($options);
     $this->_controller->addOutput("Calculator loaded");
     if ($calculator) {
         $this->_controller->addOutput("Starting to calculate. This action can take a while...");
         $calculator->calc();
         $this->_controller->addOutput("Writing calculated data.");
         $calculator->write();
         $this->_controller->addOutput("Calculation finished.");
         $calculator->removeFromQueue();
     } else {
         $this->_controller->addOutput("Calculator cannot be loaded");
     }
 }
Example #6
0
 /**
  * 
  * @param type $queueLines
  * @return type
  * @todo consider moving isLineLegitimate to here if possible
  */
 protected function pullLines($queueLines)
 {
     $lines = parent::pullLines($queueLines);
     if ($this->bulk) {
         // load all the subscribers in one call
         $this->loadSubscribers($lines);
     }
     return $lines;
 }
Example #7
0
 public function __construct($options = array())
 {
     parent::__construct($options);
 }
Example #8
0
 public function removeFromQueue()
 {
     parent::removeFromQueue();
     $this->releaseAllLines();
 }
Example #9
0
 /**
  * 
  */
 protected function setCalculatorTag($query = array(), $update = array())
 {
     parent::setCalculatorTag($query, $update);
     foreach ($this->data as $item) {
         if ($this->isLineLegitimate($item) && !empty($item['tx_saved'])) {
             $this->removeBalanceTx($item);
             // we can safely remove the transactions after the lines have left the current queue
         }
     }
 }
Example #10
0
 public function afterProcessorStore($processor)
 {
     Billrun_Factory::log('Plugin calc cpu triggered after processor store', Zend_Log::INFO);
     $customerPricingCalc = Billrun_Calculator::getInstance(array('type' => 'customerPricing', 'autoload' => false));
     foreach ($this->tx_saved_rows as $row) {
         $customerPricingCalc->removeBalanceTx($row);
     }
     if (isset($this->unifyCalc)) {
         $this->unifyCalc->releaseAllLines();
     }
 }