protected function computeCommission(Pap_Contexts_Action $context, Pap_Common_Transaction $transaction, Pap_Common_User $user, $tier){ if (Gpf_Settings::get(TopLevelAffiliateFixedCommision_PluginConfig::USE_FIRST_TIER_COMMISSION)==Gpf::YES && $tier == 1) { return null; } $commissionPercentage = $this->getFixedCommissionPercentage($transaction->getCommissionTypeId()); if ($commissionPercentage == TopLevelAffiliateFixedCommision_Config::UNDEFINED_PERCENTAGE) { return null; } return ($context->getRealTotalCost()-$context->getFixedCost()) / 100 * $commissionPercentage; }
public function getTransactionFieldValue($code) { if($this->transaction == null) { throw new Gpf_Exception("You have to set Transaction before getting transaction fields value!"); } if($code == self::TRANSACTIONID) { return $this->transaction->get(Pap_Db_Table_Transactions::TRANSACTION_ID); } else if($code == self::COMMISSION) { return $this->transaction->getCommissionAsText(); } else if($code == self::TOTALCOST) { return $this->transaction->getTotalCostAsText(); } else if($code == self::ORDERID) { return $this->transaction->getOrderId(); } else if($code == self::PRODUCTID) { return $this->transaction->getProductId(); } else if($code == self::TIER) { return $this->transaction->getTier(); } else if($code == self::CAMPAIGNID) { return $this->transaction->getCampaignId(); } else if($code == self::CAMPAIGNNAME) { return $this->getCampaignName($this->transaction->getCampaignId()); } else if($code == self::STATUS) { return $this->getStatus($this->transaction->getStatus()); } else if($code == self::STATUSCODE) { return $this->transaction->getStatus(); } else if($code == self::TYPE) { return $this->getType($this->transaction->getType()); } else if($code == self::RAWTYPE) { return $this->transaction->getType(); } else if($code == self::ACTIONNAME) { return $this->getActionName($this->transaction->getType(), $this->transaction->getCommissionTypeId()); } else if($code == self::SALEDATA1) { return $this->transaction->getData1(); } else if($code == self::SALEDATA2) { return $this->transaction->getData2(); } else if($code == self::SALEDATA3) { return $this->transaction->getData3(); } else if($code == self::SALEDATA4) { return $this->transaction->getData4(); } else if($code == self::SALEDATA5) { return $this->transaction->getData5(); } else if($code == self::ORIGINALCURRENCY) { return $this->getOriginalCurrencyName($this->transaction->get(Pap_Db_Table_Transactions::ORIGINAL_CURRENCY_ID)); } try { return $this->transaction->get($code); } catch (Gpf_Exception $e) { } return ''; }
/** * @return String */ private function recognizeCommissionTypeId(Pap_Common_Transaction $transaction) { if ($transaction->getCommissionTypeId() != null && $transaction->getCommissionTypeId() != '') { return $transaction->getCommissionTypeId(); } $campaignId = $transaction->getCampaignId(); if ($campaignId == null || $campaignId == '') { return null; } $commissionTypeObject = $this->getCommissionType($campaignId, $transaction->getType()); return $commissionTypeObject->getId(); }