/** * * @service traffic_stats read * @param $data */ public function load(Gpf_Rpc_Params $params) { $data = new Gpf_Rpc_Data($params); $filters = $this->checkFilters($data); $statsParameters = new Pap_Stats_Params(); $statsParameters->initFrom($filters); $imps = new Pap_Stats_Impressions($statsParameters); $clicks = new Pap_Stats_Clicks($statsParameters); $sales = new Pap_Stats_Sales($statsParameters); $actions = new Pap_Stats_Actions($statsParameters); $transactions = new Pap_Stats_Transactions($statsParameters); $data->setValue("countImpressions", $imps->getCount()->getAll()); $data->setValue("countClicks", $clicks->getCount()->getAll()); $data->setValue("countSales", $sales->getCount()->getAll() + $actions->getCount()->getAll()); $data->setValue("sumSales", $sales->getTotalCost()->getAll() + $actions->getTotalCost()->getAll()); $data->setValue("sumCommissions", $transactions->getCommission()->getAll()); return $data; }
public function traficOverview($session,$today){ $this->loginFromSession($session); $homeData = new Pap_Merchants_HomeData(); if($today){ $statParams = $homeData->getStatsParams('T'); }else{ $statParams = $homeData->getStatsParams('TM'); } $response = new Pap_Mobile_Response(true); $impressions = new Pap_Stats_Impressions($statParams); $response->impressionsraw = (int)$impressions->getCount()->getRaw(); $response->impressionsunique = (int)$impressions->getCount()->getUnique(); $clicks = new Pap_Stats_Clicks($statParams); $response->clicksraw = (int)$clicks->getCount()->getRaw(); $response->clicksunique = (int)$clicks->getCount()->getUnique(); $sales = new Pap_Stats_Sales($statParams); $response->salespaid = (int)$sales->getCount()->getPaid(); $response->salespending = (int)$sales->getCount()->getPending(); $response->salesapproved = (int)$sales->getCount()->getApproved(); $response->salescostpaid = $this->toCurency($sales->getTotalCost()->getPaid()); $response->salescostpending = $this->toCurency($sales->getTotalCost()->getPending()); $response->salescostapproved = $this->toCurency($sales->getTotalCost()->getApproved()); $commisions = new Pap_Stats_Transactions($statParams); $response->commisionspaid = $this->toCurency($commisions->getCommission()->getPaid()); $response->commisionspending = $this->toCurency($commisions->getCommission()->getPending()); $response->commisionsapproved = $this->toCurency($commisions->getCommission()->getApproved()); $refunds = new Pap_Stats_Refunds($statParams); $response->refundspaid = $this->toCurency($refunds->getCommission()->getPaid()); $response->refundspending = $this->toCurency($refunds->getCommission()->getPending()); $response->refundsapproved = $this->toCurency($refunds->getCommission()->getApproved()); $chargebacks = new Pap_Stats_Chargebacks($statParams); $response->chargebackspaid = $this->toCurency($chargebacks->getCommission()->getPaid()); $response->chargebackspending = $this->toCurency($chargebacks->getCommission()->getPending()); $response->chargebacksapproved = $this->toCurency($chargebacks->getCommission()->getApproved()); return $response; }