/** * @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); }