/** * Select downline tree state on the given datestamp. * * @param Request\GetStateOnDate $request * * @return Response\GetStateOnDate */ public function getStateOnDate(Request\GetStateOnDate $request) { $result = new Response\GetStateOnDate(); $this->_logger->info("'Get Downline Tree state' operation is requested."); $dateOn = $request->getDatestamp(); $rows = $this->_repoSnap->getStateOnDate($dateOn); $result->setData($rows); $result->markSucceed(); $this->_logger->info("'Get Downline Tree state' operation is completed."); return $result; }
/** * Get Downline Tree snapshot on the $ds (datestamp). Result is an array [$customerId => [...], ...] * * @param $dstamp 'YYYYMMDD' * * @return array|null */ private function _getDownlineSnapshot($dstamp) { $req = new DownlineSnapGetStateOnDateRequest(); $req->setDatestamp($dstamp); $resp = $this->_callDownlineSnap->getStateOnDate($req); $result = $resp->getData(); return $result; }
private function _checkSnapsForC13() { $period = $this->_toolPeriod; $today = $this->_dtToday; $customerId = $this->_mapCustomerMageIdByIndex[13]; $customer7Id = $this->_mapCustomerMageIdByIndex[7]; $customer9Id = $this->_mapCustomerMageIdByIndex[9]; /* today should be root */ $reqSnap = new SnapGetStateOnDateRequest(); $reqSnap->setDatestamp($today); $respSnap = $this->_callSnap->getStateOnDate($reqSnap); $data = $respSnap->getData($customerId); $path = $data[Snap::ATTR_PATH]; $this->assertEquals(Cfg::DTPS, $path); $this->_logger->debug("Customer C13 is root node today."); /* day before should be under C7 */ $dayBefore = $period->getPeriodPrev($today); $reqSnap->setDatestamp($dayBefore); $respSnap = $this->_callSnap->getStateOnDate($reqSnap); $data = $respSnap->getData($customerId); $path = $data[Snap::ATTR_PATH]; $this->assertTrue(strpos($path, Cfg::DTPS . $customer7Id . Cfg::DTPS) !== false); $this->_logger->debug("Customer C13 is under C7 day before."); /* 2 days before should be under C7 */ $twoDaysBefore = $period->getPeriodPrev($dayBefore); $reqSnap->setDatestamp($twoDaysBefore); $respSnap = $this->_callSnap->getStateOnDate($reqSnap); $data = $respSnap->getData($customerId); $path = $data[Snap::ATTR_PATH]; $this->assertTrue(strpos($path, Cfg::DTPS . $customer9Id . Cfg::DTPS) !== false); $this->_logger->debug("Customer C13 is under C9 2 days before."); /* 3 days before should be under C9 */ $threeDaysBefore = $period->getPeriodPrev($twoDaysBefore); $reqSnap->setDatestamp($threeDaysBefore); $respSnap = $this->_callSnap->getStateOnDate($reqSnap); $data = $respSnap->getData($customerId); $path = $data[Snap::ATTR_PATH]; $this->assertTrue(strpos($path, Cfg::DTPS . $customer7Id . Cfg::DTPS) !== false); $this->_logger->debug("Customer C13 is under C7 again 3 days before."); }