Ejemplo n.º 1
0
 private function setRecognizedParams(Pap_Contexts_Action $context) {
     $context->setUserObject($this->affiliate);
     $context->setBannerObject($this->banner);
     $context->setCampaignObject($this->campaign);
     $context->setAccountId($this->campaign->getAccountId(), Pap_Contexts_Tracking::ACCOUNT_RECOGNIZED_FROM_CAMPAIGN);
     $context->setTrackingMethod(Pap_Common_Transaction::TRACKING_METHOD_COUPON);
     $context->getTransaction()->setCouponId($this->coupon->getId());
     $context->getTransaction()->set(Pap_Db_Table_Transactions::BANNER_ID, $this->banner->getId());
 }
    public function process(Pap_Db_Visit $visit) {
    	Gpf_Log::debug('Action processor processing...');
        $accountContext = $this->processAccount($visit);        
        if (!$accountContext->getDoTrackerSave()) {
        	Gpf_Log::debug('Saving disabled because of account problems.');
            return;
        }
        $this->visitorAffiliateCache->setAccountId($accountContext->getAccountId());

        try {
            $actions = $this->loadActions($visit->getSaleParams());
        } catch (Gpf_Exception $e) {
            Gpf_Log::debug('Action processor: ' . $e->getMessage());
            return;
        }

        foreach ($actions as $action) {
            $context = new Pap_Contexts_Action($action, $visit);
            $context->debug('Saving sale/action for visit: '.$visit->toText());
            $context->setDoCommissionsSave(true);
            $context->setAccountId($accountContext->getAccountId(), $accountContext->getAccountRecognizeMethod());
            
            try {
                $this->processAction($context);
            } catch (Gpf_Exception $e) {
                $context->debug("Saving commission interrupted: ".$e->getMessage());
            }
        }
    }