private function getUserCommissionTypes($campaignId = null) { $userId = null; if (Gpf_Session::getAuthUser()->isAffiliate()) { $userId = Gpf_Session::getAuthUser()->getPapUserId(); } return Pap_Db_Table_CommissionTypes::getInstance()->getAllUserCommissionTypes($campaignId, Pap_Common_Constants::TYPE_ACTION, $userId); }
/** * returns commission types for a campaign * * @service commission read * @param $fields */ public function loadCommissionTypes(Gpf_Rpc_Params $params) { $campaignId = $params->get("campaignid"); if($campaignId == "") { throw new Exception($this->_("Campaign ID cannot be empty!")); } return Pap_Db_Table_CommissionTypes::getInstance()->getAllCommissionTypes($campaignId); }
private function getUserCommissionTypes($campaignId = null) { $userId = null; if (Gpf_Session::getAuthUser()->isAffiliate()) { $userId = Gpf_Session::getAuthUser()->getPapUserId(); } if (!array_key_exists($campaignId.'_'.$userId, self::$userCommissionTypes)) { self::$userCommissionTypes[$campaignId.'_'.$userId] = Pap_Db_Table_CommissionTypes::getInstance()->getAllUserCommissionTypes($campaignId, Pap_Common_Constants::TYPE_ACTION, $userId); } return self::$userCommissionTypes[$campaignId.'_'.$userId]; }
private function getCommissionTypeSelect($commissionType, $code = '',$countryCode = '') { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_CommissionTypes::getInstance()); $select->from->add(Pap_Db_Table_CommissionTypes::getName()); $select->where->add(Pap_Db_Table_CommissionTypes::CAMPAIGNID, '=', $this->getId()); $select->where->add(Pap_Db_Table_CommissionTypes::TYPE, '=', $commissionType); $select->where->add(Pap_Db_Table_CommissionTypes::STATUS, '=', Pap_Db_CommissionType::STATUS_ENABLED); if ($code != null && $code != '') { $select->where->add(Pap_Db_Table_CommissionTypes::CODE, '=', $code); } if (!strlen($countryCode)) { $compoundCondition = new Gpf_SqlBuilder_CompoundWhereCondition(); $compoundCondition->add(Pap_Db_Table_CommissionTypes::PARENT_COMMISSIONTYPE_ID, '=', null, 'OR'); $compoundCondition->add(Pap_Db_Table_CommissionTypes::PARENT_COMMISSIONTYPE_ID, '=', '', 'OR'); $select->where->addCondition($compoundCondition); } else { $select->where->add(Pap_Db_Table_CommissionTypes::PARENT_COMMISSIONTYPE_ID, '!=', null); $select->where->add(Pap_Db_Table_CommissionTypes::COUNTRYCODES, 'like', '%' . $countryCode . '%'); } return $select; }
public function execute() { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add(Pap_Db_Table_CommissionTypes::ID); $selectBuilder->from->add(Pap_Db_Table_CommissionTypes::getName()); $selectBuilder->where->add(Pap_Db_Table_CommissionTypes::TYPE, '=', Pap_Common_Constants::TYPE_REFERRAL); try { $selectBuilder->getOneRow(); return; } catch (Gpf_Exception $e) { } $insert = new Gpf_SqlBuilder_InsertBuilder(); $insert->setTable(Pap_Db_Table_CommissionTypes::getInstance()); $insert->add(Pap_Db_Table_CommissionTypes::ID, 'refercom'); $insert->add(Pap_Db_Table_CommissionTypes::TYPE, Pap_Common_Constants::TYPE_REFERRAL); $insert->add(Pap_Db_Table_CommissionTypes::STATUS, Pap_Db_CommissionType::STATUS_ENABLED); $insert->add(Pap_Db_Table_CommissionTypes::APPROVAL, Pap_Db_CommissionType::APPROVAL_AUTOMATIC); $insert->add(Pap_Db_Table_CommissionTypes::ZEROORDERSCOMMISSION, Gpf::NO); try { $insert->execute(); } catch (Exception $e) { } }
public function init() { $this->setTable(Pap_Db_Table_CommissionTypes::getInstance()); parent::init(); }
public function getCommissionType(Pap_Contexts_Action $context) { $context->debug("Begin recognizing country specific commission type"); if(!strlen($context->getTransactionObject()->getCountryCode())) { $context->debug("STOPPING recognizing country specific commission type eneded: country code not recognized or empty"); return; } $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_CommissionTypes::getInstance()); $select->from->add(Pap_Db_Table_CommissionTypes::getName()); $select->where->add(Pap_Db_Table_CommissionTypes::PARENT_COMMISSIONTYPE_ID, '=', $context->getCommissionTypeObject()->getId()); $compoundContext = new Gpf_Data_Record(array(Pap_Db_Table_RawImpressions::IP, Pap_Db_Table_Impressions::COUNTRYCODE), array($context->getVisit()->getIp(), '')); $this->getCountryCode($compoundContext); $countryCode = $compoundContext->get(Pap_Db_Table_Impressions::COUNTRYCODE); if (!strlen($countryCode)) { $context->debug("STOPPING recognizing country specific commission type eneded: country code not recognized or empty"); return; } $select->where->add(Pap_Db_Table_CommissionTypes::COUNTRYCODES, 'LIKE', '%'.$countryCode.'%'); try { $commType = new Pap_Db_CommissionType(); $collection = $commType->loadCollectionFromRecordset($select->getAllRows()); $context->setCommissionTypeObject($collection->get(0)); } catch (Gpf_DbEngine_NoRowException $e) { $context->debug("Recognizing country specific commission type eneded - no country secpific commission defined"); return; } catch (Gpf_DbEngine_TooManyRowsException $e) { $context->debug("STOPPING ecognizing country specific commission type eneded: more than one commision type is defined for country " . $context->getTransactionObject()->getCountryCode()); return; } catch (Gpf_Exception $e) { $context->debug("STOPPING recognizing country specific commission type eneded: " . $e->getMessage()); } }
/** * @service commission read * @param Gpf_Rpc_Params $params */ public function loadReferralCommissions(Gpf_Rpc_Params $params) { return Pap_Db_Table_CommissionTypes::getInstance()->getAllCommissionTypes(null, Pap_Common_Constants::TYPE_REFERRAL); }