public function run() { $time1 = microtime(); Pap3Compatibility_Migration_OutputWriter::logOnce("Deleting migrated data from existing PAP4 tables<br/>"); try { $this->deleteTable(Pap_Db_Table_Campaigns::getName()); $this->deleteTable(Pap_Db_Table_CommissionGroups::getName()); $this->deleteTable(Pap_Db_Table_CommissionTypes::getName()); $this->deleteTable(Pap_Db_Table_Commissions::getName()); $this->deleteTable(Pap_Db_Table_UserInCommissionGroup::getName()); $this->deleteTable(Gpf_Db_Table_FormFields::getName()); $this->deleteTable(Gpf_Db_Table_FieldGroups::getName()); $this->deleteTable(Pap_Db_Table_Transactions::getName()); $this->deleteTable(Pap_Db_Table_Clicks::getName()); $this->deleteTable(Pap_Db_Table_RawClicks::getName()); $this->deleteTable(Pap_Db_Table_Impressions::getName()); $this->deleteTable(Pap_Db_Table_Banners::getName()); $this->deleteTable(Gpf_Db_Table_FieldGroups::getName()); $this->deleteTable(Pap_Db_Table_PayoutsHistory::getName()); $this->deleteTable(Pap_Db_Table_Payouts::getName()); $this->deleteTable(Gpf_Db_Table_Currencies::getName()); $this->deleteTable(Gpf_Db_Table_MailAccounts::getName()); } catch(Exception $e) { Pap3Compatibility_Migration_OutputWriter::log(" Errror: ".$e->getMessage()."<br/>"); } $time2 = microtime(); Pap3Compatibility_Migration_OutputWriter::logDone($time1, $time2); }
/** * @return Gpf_Data_RecordSet */ public function getReferralCommissions() { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('c.'.Pap_Db_Table_Commissions::ID, Pap_Db_Table_Commissions::ID); $select->select->add('c.'.Pap_Db_Table_Commissions::TIER, Pap_Db_Table_Commissions::TIER); $select->select->add('c.'.Pap_Db_Table_Commissions::SUBTYPE, Pap_Db_Table_Commissions::SUBTYPE); $select->select->add('c.'.Pap_Db_Table_Commissions::TYPE, 'commissiontype'); $select->select->add('c.'.Pap_Db_Table_Commissions::VALUE, 'commissionvalue'); $select->select->add('c.'.Pap_Db_Table_Commissions::TYPE_ID, 'commtypeid'); $select->from->add(Pap_Db_Table_Commissions::getName(), 'c'); $select->from->addInnerJoin(Pap_Db_Table_CommissionTypes::getName(), 'ct', 'c.'.Pap_Db_Table_Commissions::TYPE_ID.'=ct.'.Pap_Db_Table_CommissionTypes::ID); $select->where->add(Pap_Db_Table_CommissionTypes::TYPE, '=', Pap_Db_Transaction::TYPE_REFERRAL); $select->orderBy->add(Pap_Db_Table_Commissions::TIER); return $select->getAllRows(); }
private function getCommission() { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add(Pap_Db_Table_Commissions::ID, Pap_Db_Table_Commissions::ID); $selectBuilder->select->add(Pap_Db_Table_Commissions::TIER, Pap_Db_Table_Commissions::TIER); $selectBuilder->select->add(Pap_Db_Table_Commissions::SUBTYPE, Pap_Db_Table_Commissions::SUBTYPE); $selectBuilder->select->add(Pap_Db_Table_Commissions::TYPE, Pap_Db_Table_Commissions::TYPE); $selectBuilder->select->add(Pap_Db_Table_Commissions::VALUE, Pap_Db_Table_Commissions::VALUE); $selectBuilder->select->add(Pap_Db_Table_Commissions::TYPE_ID, Pap_Db_Table_Commissions::TYPE_ID); $selectBuilder->select->add(Pap_Db_Table_Commissions::GROUP_ID, Pap_Db_Table_Commissions::GROUP_ID); $selectBuilder->from->add(Pap_Db_Table_Commissions::getName()); return $selectBuilder; }
/** * deletes tier commission * if deleteType == exact, it will delete only given tier * if deleteType == above, it will delete given tier and all above * * @param unknown_type $fromTier * @param unknown_type $subType * @param unknown_type $commGroupId * @param unknown_type $commTypeId * @param unknown_type $deleteType */ public function deleteUnusedCommissions($fromTier, $subType, $commGroupId, $commTypeId, $deleteType = 'extact') { $deleteBuilder = new Gpf_SqlBuilder_DeleteBuilder(); $deleteBuilder->from->add(Pap_Db_Table_Commissions::getName()); $deleteBuilder->where->add('subtype', '=', $subType); if($deleteType == 'above') { $deleteBuilder->where->add('tier', '>', $fromTier); } else { $deleteBuilder->where->add('tier', '=', $fromTier); } $deleteBuilder->where->add('commtypeid', '=', $commTypeId); $deleteBuilder->where->add('commissiongroupid', '=', $commGroupId); $deleteBuilder->delete(); }
protected function initTransactionSql(Gpf_SqlBuilder_SelectBuilder $transactionsSql) { $transactionsSql->from->add(Pap_Db_Table_Transactions::getName(), 't'); $transactionsSql->from->addInnerJoin(Pap_Db_Table_Commissions::getName(), 'c', 'c.'.Pap_Db_Table_Commissions::TYPE_ID.'=t.'. Pap_Db_Table_Transactions::COMMISSIONTYPEID.' AND c.'.Pap_Db_Table_Commissions::TIER.'=t.'.Pap_Db_Table_Transactions::TIER); $transactionsSql->where->add('c.'.Pap_Db_Table_Commissions::GROUP_ID, '=',$this->rule->getCommissionGroupId()); $transactionsSql->where->add('t.'.Pap_Db_Table_Transactions::R_STATUS, '!=', Pap_Common_Constants::STATUS_DECLINED); $transactionsSql->where->add('t.'.Pap_Db_Table_Transactions::COMMISSIONTYPEID, '!=', null); $transactionsSql->where->add('t.'.Pap_Db_Table_Transactions::PAYOUT_STATUS, '=', Pap_Common_Constants::PSTATUS_UNPAID); $transactionsSql->where->add('t.'.Pap_Db_Table_Transactions::R_TYPE, 'NOT IN', array(Pap_Db_Transaction::TYPE_REFUND, Pap_Db_Transaction::TYPE_CHARGE_BACK)); }