本文整理汇总了PHP中Billrun_Factory::plan方法的典型用法代码示例。如果您正苦于以下问题:PHP Billrun_Factory::plan方法的具体用法?PHP Billrun_Factory::plan怎么用?PHP Billrun_Factory::plan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Billrun_Factory
的用法示例。
在下文中一共展示了Billrun_Factory::plan方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBalancesVolume
/**
* method to receive the balances lines that over requested date usage
*
* @return Mongodloid_Cursor Mongo cursor for iteration
*/
public function getBalancesVolume($plan, $data_usage, $from_account_id, $to_account_id, $billrun)
{
$params = array('name' => $plan, 'time' => Billrun_Util::getStartTime($billrun));
$plan_id = Billrun_Factory::plan($params);
$id = $plan_id->get('_id')->getMongoID();
$data_usage_bytes = Billrun_Util::megabytesToBytesFormat((int) $data_usage);
$query = array('aid' => array('$gte' => (int) $from_account_id, '$lte' => (int) $to_account_id), 'billrun_month' => $billrun, 'balance.totals.data.usagev' => array('$gt' => (double) $data_usage_bytes), 'current_plan' => Billrun_Factory::db()->plansCollection()->createRef($id));
// print_R($query);die;
return $this->collection->query($query)->cursor()->setReadPreference(Billrun_Factory::config()->getConfigValue('read_only_db_pref'))->hint(array('aid' => 1, 'billrun_month' => 1))->limit($this->size);
}
示例2: getData
/**
* Get the data resource
*
* @return Mongo Cursor
*/
public function getData($filter_query = array(), $fields = false)
{
$cursor = $this->getRates($filter_query);
$this->_count = $cursor->count();
$resource = $cursor->sort($this->sort)->skip($this->offset())->limit($this->size);
$ret = array();
foreach ($resource as $item) {
if ($fields) {
foreach ($fields as $field) {
$row[$field] = $item->get($field);
}
if (isset($row['rates'])) {
// convert plan ref to plan name
foreach ($row['rates'] as &$rate) {
if (isset($rate['plans'])) {
$plans = array();
foreach ($rate['plans'] as $plan) {
$plan_id = $plan['$id'];
$plans[] = Billrun_Factory::plan(array('id' => $plan_id))->getName();
}
$rate['plans'] = $plans;
}
}
}
$ret[] = $row;
} else {
if ($item->get('rates') && !$this->showprefix) {
foreach ($item->get('rates') as $key => $rate) {
if (is_array($rate)) {
$added_columns = array('t' => $key, 'tprice' => $rate['rate'][0]['price'], 'taccess' => isset($rate['access']) ? $rate['access'] : 0);
if (strpos($key, 'call') !== FALSE) {
$added_columns['tduration'] = Billrun_Util::durationFormat($rate['rate'][0]['interval']);
} else {
if ($key == 'data') {
$added_columns['tduration'] = Billrun_Util::byteFormat($rate['rate'][0]['interval'], '', 0, true);
} else {
$added_columns['tduration'] = $rate['rate'][0]['interval'];
}
}
$ret[] = new Mongodloid_Entity(array_merge($item->getRawData(), $added_columns, $rate));
}
}
} else {
if ($this->showprefix && (isset($filter_query['$and'][0]['key']) || isset($filter_query['$and'][0]['params.prefix']))) {
foreach ($item->get('params.prefix') as $prefix) {
$item_raw_data = $item->getRawData();
unset($item_raw_data['params']['prefix']);
// to prevent high memory usage
$entity = new Mongodloid_Entity(array_merge($item_raw_data, array('prefix' => $prefix)));
$ret[] = $entity;
}
} else {
$ret[] = $item;
}
}
}
}
return $ret;
}
示例3: getFlatCosts
/**
*
* @param array $subscriber subscriber entry from billrun collection
* @return array
*/
protected function getFlatCosts($subscriber)
{
$plan_name = $this->getNextPlanName($subscriber);
if (!$plan_name) {
//@error
return array();
}
$planObj = Billrun_Factory::plan(array('name' => $plan_name, 'time' => Billrun_Util::getStartTime(Billrun_Util::getFollowingBillrunKey($this->stamp))));
if (!$planObj->get('_id')) {
Billrun_Factory::log("Couldn't get plan {$plan_name} data", Zend_Log::ALERT);
return array();
}
$plan_price = $planObj->get('price');
return array('vatable' => $plan_price, 'vat_free' => 0);
}
示例4: addPlanRef
/**
* Add plan reference to line
* @param Mongodloid_Entity $row
* @param string $plan
*/
protected function addPlanRef($row, $plan)
{
$planObj = Billrun_Factory::plan(array('name' => $plan, 'time' => $row['urt']->sec, 'disableCache' => true));
if (!$planObj->get('_id')) {
Billrun_Factory::log("Couldn't get plan for CDR line : {$row['stamp']} with plan {$plan}", Zend_Log::ALERT);
return;
}
$row['plan_ref'] = $planObj->createRef();
return $row->get('plan_ref', true);
}