当前位置: 首页>>代码示例>>PHP>>正文


PHP Perf::calTotal方法代码示例

本文整理汇总了PHP中Perf::calTotal方法的典型用法代码示例。如果您正苦于以下问题:PHP Perf::calTotal方法的具体用法?PHP Perf::calTotal怎么用?PHP Perf::calTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Perf的用法示例。


在下文中一共展示了Perf::calTotal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: earning

 /**
  * @before _secure
  * @after _cleanUp
  */
 public function earning($id = null)
 {
     $view = $this->getActionView();
     if (!$id) {
         return $this->failure('20');
     }
     $org = $this->_org;
     $perfFields = ['clicks', 'revenue', 'impressions', 'conversions', 'created'];
     $publisher = User::first(['_id' => $id, 'org_id' => $org->_id]);
     if (!$publisher) {
         return $this->failure('30');
     }
     $publisher = User::objectArr($publisher, Usr::fields());
     $publisher = array_shift($publisher);
     $start = RequestMethods::get("start", date('Y-m-d', strtotime("-5 day")));
     $end = RequestMethods::get("end", date('Y-m-d', strtotime('-1 day')));
     $pubPerf = Perf::perf($org, 'publisher', ['meta' => true, 'publishers' => [$publisher->_id], 'start' => $start, 'end' => $end]);
     $perf = [];
     Perf::payout($pubPerf, $perf);
     $data = ['user' => $publisher, 'stats' => $perf, 'total' => Perf::calTotal($perf)];
     $view->set('data', $data);
 }
开发者ID:vNative,项目名称:vnative,代码行数:26,代码来源:api.php

示例2: advertisers

 /**
  * @before _secure
  * @after setDate
  */
 public function advertisers()
 {
     $this->seo(["title" => "Advertiser Stats"]);
     $view = $this->getActionView();
     $org = $this->org;
     if ($this->user_id) {
         $advertiser = User::first(['_id' => $this->user_id, 'org_id' => $org->_id, 'type' => 'advertiser']);
         if (!$advertiser) {
             $this->_404();
         }
         $in = [$advertiser->_id];
     } else {
         $in = $org->users('advertiser');
     }
     $fields = ['clicks', 'impressions', 'conversions', 'revenue', 'created'];
     $advertPerf = Perf::perf($org, 'advertiser', ['advertisers' => $in, 'start' => $this->start, 'end' => $this->end, 'fields' => $fields]);
     $perf = [];
     Perf::revenue($advertPerf, $perf);
     $data = ['stats' => $perf, 'total' => Perf::calTotal($perf)];
     $view->set($data);
 }
开发者ID:vNative,项目名称:vnative,代码行数:25,代码来源:insight.php

示例3: _invoice

 public function _invoice()
 {
     $orgs = Organization::all(['live' => true]);
     $today = date('Y-m-d');
     $this->log('Started Invoices');
     foreach ($orgs as $o) {
         $start = date('Y-m-d', strtotime("-1 day"));
         // check auto invoice
         $aff = $o->billing['aff'] ?? [];
         if (!isset($aff['auto']) || !$aff['auto']) {
             continue;
         }
         $this->log('Checking Invoices for Org: ' . $o->name);
         // make invoice for all publishers b/w $start and $today
         $pubs = User::all(['org_id' => $o->_id, 'live' => true, 'type' => 'publisher']);
         foreach ($pubs as $p) {
             $invoice = Invoice::first(['org_id' => $o->_id, 'user_id' => $p->_id], ['created'], 'created', 'desc');
             if ($invoice) {
                 // check no of days
                 $lastCreated = $invoice->created->format('Y-m-d');
                 $diff = date_diff(date_create($lastCreated), date_create($today));
                 if ($diff->d !== (int) $aff['freq']) {
                     continue;
                 }
                 $start = date('Y-m-d', strtotime("-" . $aff['freq'] . " day"));
             } else {
                 $start = $o->created->format('Y-m-d');
             }
             // check if invoice exists for the date range
             $inv = Invoice::exists($p->_id, $start, $today);
             if ($inv) {
                 continue;
             }
             $pubPerf = Perf::perf($o, 'publisher', ['publishers' => [$p->_id], 'fields' => ['revenue', 'created'], 'start' => $start, 'end' => $today]);
             $perf = [];
             Perf::payout($pubPerf, $perf);
             $total = Perf::calTotal($perf);
             $payout = $total['payout'] ?? 0;
             $keys = array_keys($perf);
             if ($payout < $aff['minpay']) {
                 continue;
             }
             // create a new invoice
             $inv = new Invoice(['org_id' => $o->_id, 'user_id' => $p->_id, 'utype' => $p->type, 'amount' => $payout, 'start' => $keys[0], 'end' => end($keys), 'live' => false]);
             $inv->save();
             $this->log('Invoice saved for User: ' . $p->name . ' email: ' . $p->email);
         }
     }
     $this->log('End Invoices');
 }
开发者ID:vNative,项目名称:vnative,代码行数:50,代码来源:cron.php


注:本文中的Perf::calTotal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。