/**
	 * returns commission group for user (if not set already)
	 * Commission group can be set previously in the checkCampaignType() function
	 *
	 */
	protected function getCommissionGroup(Pap_Contexts_Tracking $context) {
		$context->debug('Recognizing commission group started');

		if (($user = $context->getUserObject()) == null) {
		    $context->debug('STOPPING, user is not set - cannot find commission group');
		    return;
		}
		
		$commGroupId = $this->getUserCommissionGroupFromCache($context->getCampaignObject(), $user->getId());
		if($commGroupId == false) {
			$context->debug("STOPPING, Cannot find commission group for this affiliate and campaign! ".$context->getCampaignObject()->getId().' - '.$user->getId());
			$context->setDoCommissionsSave(false);
			$context->setDoTrackerSave(false);
			return;
		}
			
		Gpf_Plugins_Engine::extensionPoint('PostAffiliate.RecognizeCommGroup.getCommissionGroup', $context);

        $commissionGroup = $this->getCommissionGroupFromCache($commGroupId);
        if ($commissionGroup == null) {
        	$context->debug('    Commission group with ID '.$commGroupId . ' does not exist');
        	return;
        }

		$context->setCommissionGroup($commissionGroup);
	    $context->debug('Received commission group ID = '.$commGroupId);
	}
 private function checkZeroOrdersCommissions(Pap_Contexts_Tracking $context) {
     if ($context->getRealTotalCost() == 0 &&
     $context->getCommissionTypeObject()->getZeroOrdersCommissions() != Gpf::YES) {
         $context->debug("    STOPPING (setting setDoCommissionsSave(false), because TotalCost is 0 and zero order commissions should not be saved.");
         $context->setDoCommissionsSave(false);
     }
 }
    public function process(Pap_Contexts_Tracking $context) {
        $context->debug('  Preparing commissions for the click started');

        $context->setDoCommissionsSave($this->isValidCommission($context));
        if (!$context->getDoCommissionsSave()) {
            return;
        }

        $this->recognizeCommissions($context);

        if($context->getDoCommissionsSave() && $context->getDoTrackerSave()
        && $context->getClickStatus() != Pap_Db_ClickImpression::STATUS_DECLINED) {
            $this->saveCommissions($context);
        }

        $context->debug('  Preparing commissions for the click ended');
        $context->debug('');
    }
Ejemplo n.º 4
0
 public function getCommissionGroup(Pap_Contexts_Tracking $context) {
     if ($context->getCampaignObject()->getCampaignType() != Pap_Db_Campaign::CAMPAIGN_TYPE_PUBLIC) {
         try {
             $status = Pap_Db_Table_UserInCommissionGroup::getStatus($context->getCampaignObject()->getId(), $context->getUserObject()->getId());
             if ($status != Pap_Features_PerformanceRewards_Condition::STATUS_APPROVED &&
             $status != Pap_Features_PerformanceRewards_Condition::STATUS_FIXED) {
                 throw new Gpf_Exception('');
             }
         } catch (Gpf_Exception $e) {
             $context->debug('    STOPPING, User is not approved in this campaign!');
             $context->setDoCommissionsSave(false);
             $context->setDoTrackerSave(false);
         }
     }
 }