コード例 #1
0
 public function qualification(Request\Qualification $req)
 {
     $result = new Response\Qualification();
     $datePerformed = $req->getDatePerformed();
     $dateApplied = $req->getDateApplied();
     $gvMaxLevels = $req->getGvMaxLevels();
     $psaaLevel = $req->getPsaaLevel();
     $this->_logger->info("'Qualification for Loyalty' calculation is started. Performed at: {$datePerformed}, applied at: {$dateApplied}.");
     $reqGetPeriod = new PeriodGetForDependentCalcRequest();
     $calcTypeBase = Cfg::CODE_TYPE_CALC_COMPRESSION;
     $calcType = Cfg::CODE_TYPE_CALC_QUALIFICATION;
     $reqGetPeriod->setBaseCalcTypeCode($calcTypeBase);
     $reqGetPeriod->setDependentCalcTypeCode($calcType);
     $respGetPeriod = $this->_callBasePeriod->getForDependentCalc($reqGetPeriod);
     if ($respGetPeriod->isSucceed()) {
         $def = $this->_manTrans->begin();
         try {
             $periodDataDepend = $respGetPeriod->getDependentPeriodData();
             $calcDataDepend = $respGetPeriod->getDependentCalcData();
             $calcIdDepend = $calcDataDepend->getId();
             $calcDataBase = $respGetPeriod->getBaseCalcData();
             $dsBegin = $periodDataDepend->getDstampBegin();
             $dsEnd = $periodDataDepend->getDstampEnd();
             $calcIdBase = $calcDataBase->getId();
             $tree = $this->_repoBonusCompress->getTreeByCalcId($calcIdBase);
             $qualData = $this->_repoMod->getQualificationData($dsBegin, $dsEnd);
             $updates = $this->_subQualification->calcParams($tree, $qualData, $gvMaxLevels, $psaaLevel);
             $this->_repoMod->saveQualificationParams($updates);
             $this->_repoBonusService->markCalcComplete($calcIdDepend);
             $this->_manTrans->commit($def);
             $result->setPeriodId($periodDataDepend->getId());
             $result->setCalcId($calcIdDepend);
             $result->markSucceed();
         } finally {
             $this->_manTrans->end($def);
         }
     }
     $this->_logger->info("'Qualification for Loyalty' calculation is complete.");
     return $result;
 }