コード例 #1
0
 public function getLastDate(Request\GetLastDate $request)
 {
     $result = new Response\GetLastDate();
     $assetTypeId = $request->getAssetTypeId();
     $assetTypeCode = $request->getAssetTypeCode();
     if (is_null($assetTypeId)) {
         $assetTypeId = $this->_repoTypeAsset->getIdByCode($assetTypeCode);
     }
     /* get the maximal date for balance */
     $balanceMaxDate = $this->_repoMod->getBalanceMaxDate($assetTypeId);
     if ($balanceMaxDate) {
         /* there is balance data */
         $dayBefore = $this->_toolPeriod->getPeriodPrev($balanceMaxDate, IPeriod::TYPE_DAY);
         $result->setData([Response\GetLastDate::LAST_DATE => $dayBefore]);
         $result->markSucceed();
     } else {
         /* there is no balance data yet, get transaction with minimal date */
         $transactionMinDate = $this->_repoMod->getTransactionMinDateApplied($assetTypeId);
         if ($transactionMinDate) {
             $period = $this->_toolPeriod->getPeriodCurrent($transactionMinDate);
             $dayBefore = $this->_toolPeriod->getPeriodPrev($period, IPeriod::TYPE_DAY);
             $result->setData([Response\GetLastDate::LAST_DATE => $dayBefore]);
             $result->markSucceed();
         }
     }
     return $result;
 }
コード例 #2
0
 /**
  * Calculate the last date for existing downline snap or the "yesterday" for the first change log entry.
  *
  * @param Request\GetLastDate $request
  *
  * @return Response\GetLastDate
  */
 public function getLastDate(Request\GetLastDate $request)
 {
     $result = new Response\GetLastDate();
     $this->_logger->info("'Get Last Data' operation is requested.");
     /* get the maximal date for existing snapshot */
     $snapMaxDate = $this->_repoSnap->getMaxDatestamp();
     if ($snapMaxDate) {
         /* there is snapshots data */
         $result->setData([Response\GetLastDate::LAST_DATE => $snapMaxDate]);
         $result->markSucceed();
     } else {
         /* there is no snapshot data yet, get change log minimal date  */
         $changelogMinDate = $this->_repoChange->getChangelogMinDate();
         if ($changelogMinDate) {
             $period = $this->_toolPeriod->getPeriodCurrent($changelogMinDate);
             $dayBefore = $this->_toolPeriod->getPeriodPrev($period);
             $this->_logger->info("The last date for downline snapshot is '{$dayBefore}'.");
             $result->setData([Response\GetLastDate::LAST_DATE => $dayBefore]);
             $result->markSucceed();
         }
     }
     $this->_logger->info("'Get Last Data' operation is completed.");
     return $result;
 }