本文整理汇总了PHP中Perf::perf方法的典型用法代码示例。如果您正苦于以下问题:PHP Perf::perf方法的具体用法?PHP Perf::perf怎么用?PHP Perf::perf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Perf
的用法示例。
在下文中一共展示了Perf::perf方法的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);
}
示例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);
}
示例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');
}