/** * * @return Gpf_SqlBuilder_SelectBuilder */ protected function getTransactionsSelect() { $transactions = new Gpf_SqlBuilder_SelectBuilder(); $transactions->select->addAll(Pap_Db_Table_Transactions::getInstance(), 't'); $transactions->select->add('c.'.Pap_Db_Table_Commissions::TYPE); $transactions->select->add('c.'.Pap_Db_Table_Commissions::VALUE); $transactions->where->add('t.'.Pap_Db_Table_Transactions::USER_ID, '=', $this->getCurrentUserId()); $this->initTransactionSql($transactions); return $transactions; }
/** * * @return Pap_Common_Transaction */ protected function getParentTransaction($futurePayId) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_Transactions::getInstance()); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add(Pap_Db_Table_Transactions::DATA5, "=", $futurePayId); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "IN", array(Pap_Common_Constants::TYPE_SALE, Pap_Common_Constants::TYPE_ACTION, Pap_Common_Constants::TYPE_LEAD)); $select->where->add(Pap_Db_Table_Transactions::TIER, "=", "1"); $select->limit->set(0, 1); $t = new Pap_Common_Transaction(); $t->fillFromRecord($select->getOneRow()); return $t; }
protected function getTransactionsList() { $types = array(Pap_Common_Constants::TYPE_SALE, Pap_Common_Constants::TYPE_ACTION, Pap_Common_Constants::TYPE_LEAD, Pap_Common_Constants::TYPE_RECURRING); $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_Transactions::getInstance(), 't'); $select->from->add(Pap_Db_Table_Transactions::getName(), 't'); $select->from->addInnerJoin(Pap_Db_Table_CommissionTypeAttributes::getName(), 'cta', 'cta.'.Pap_Db_Table_CommissionTypeAttributes::COMMISSION_TYPE_ID.'=t.'.Pap_Db_Table_Transactions::COMMISSIONTYPEID. ' and (cta.'.Pap_Db_Table_CommissionTypeAttributes::NAME."='".AutoApprovalCommissions_Main::AUTO_APPROVAL_COMMISSIONS_DAYS."' and ".Pap_Db_Table_CommissionTypeAttributes::VALUE . '<>0) and (unix_timestamp(t.dateinserted) + (cta.'.Pap_Db_Table_CommissionTypeAttributes::VALUE.' * 86400)) <= unix_timestamp() '); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "IN", $types); $select->where->add(Pap_Db_Table_Transactions::R_STATUS, "=", Pap_Common_Constants::STATUS_PENDING); $transaction = new Pap_Common_Transaction(); return $transaction->loadCollectionFromRecordset($select->getAllRows()); }
/** * @throws Gpf_DbEngine_NoRowException * @return Pap_Common_Transcation */ protected function getClonedTransactionFromDb(Pap_Common_Transaction $transaction) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_Transactions::getInstance()); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add(Pap_Db_Table_Transactions::USER_ID, '=', $transaction->getUserId()); $select->where->add(Pap_Db_Table_Transactions::CAMPAIGN_ID, '=', $transaction->getCampaignId()); $select->where->add(Pap_Db_Table_Transactions::BANNER_ID, '=', $transaction->getBannerId()); $select->where->add(Pap_Db_Table_Transactions::CHANNEL, '=', $transaction->getChannel()); $select->where->add(Pap_Db_Table_Transactions::R_STATUS, '=', $transaction->getStatus()); $select->where->add(Pap_Db_Table_Transactions::TIER, '=', $transaction->getTier()); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, '=', $transaction->getType()); $select->where->add(Pap_Db_Table_Transactions::COUNTRY_CODE, '=', $transaction->getCountryCode()); $select->where->add(Pap_Db_Table_Transactions::PAYOUT_STATUS, '=', $transaction->getPayoutStatus()); $select->where->add(Pap_Db_Table_Transactions::DATE_INSERTED, 'like', $this->dateTimeToDate($transaction->getDateInserted()).'%'); $select->orderBy->add(Pap_Db_Table_Transactions::DATE_INSERTED, false); $select->limit->set(0, 1); $transaction = new Pap_Common_Transaction(); $transaction->fillFromRecord($select->getOneRow()); return $transaction; }
/** * @param array $userIds * @param array $orderIds * @return Gpf_DbEngine_Row_Collection */ public function getAffectedTransactionsList($userIds, $orderIds = array()) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_Transactions::getInstance()); $select->from->add(Pap_Db_Table_Transactions::getName()); $dateRangeFilter = new Gpf_SqlBuilder_Filter(); $dateRange = $dateRangeFilter->decodeDatePreset(Pap_Features_CompressedCommissionPlacementModel_Processor::getRecurrencePreset()); $select->where->add(Pap_Db_Table_Transactions::DATE_INSERTED, '>', $dateRange['dateFrom']); $select->where->add(Pap_Db_Table_Transactions::DATE_INSERTED, '<', $dateRange['dateTo']); $select->where->add(Pap_Db_Table_Transactions::USER_ID, 'IN', $userIds); if (!is_null($orderIds) && count($orderIds) > 0) { $compoundCondition = new Gpf_SqlBuilder_CompoundWhereCondition(); foreach ($orderIds as $orderId) { $compoundCondition->add(Pap_Db_Table_Transactions::ORDER_ID, 'LIKE', '%'.$orderId.'%', 'OR'); } $select->where->addCondition($compoundCondition); } $select->orderBy->add(Pap_Db_Table_Transactions::TIER); $transaction = new Pap_Db_Transaction(); $transactionsRecordSet = $select->getAllRows(); $unpaidTransactions = new Gpf_Data_RecordSet(); $unpaidTransactions->setHeader($transactionsRecordSet->getHeader()); foreach ($transactionsRecordSet as $trans) { if ($trans->get(Pap_Db_Table_Transactions::PAYOUT_STATUS) == Pap_Common_Constants::PSTATUS_UNPAID) { $unpaidTransactions->add($trans); } else { $this->log('Removing paid transaction from affected transactions: ' . $trans->get(Pap_Db_Table_Transactions::TRANSACTION_ID)); } } return $transaction->loadCollectionFromRecordset($unpaidTransactions); }
protected function loadResultData() { $this->doMossoHack(Pap_Db_Table_Transactions::getInstance(), 't', Pap_Db_Table_Transactions::TRANSACTION_ID); return parent::loadResultData(); }
/** * @return Pap_Db_Transaction */ public function getRefundOrChargebackTransaction() { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_Transactions::getInstance()); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add(Pap_Db_Table_Transactions::PARRENT_TRANSACTION_ID, '=', $this->getId()); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, 'IN', array(Pap_Db_Transaction::TYPE_REFUND, Pap_Db_Transaction::TYPE_CHARGE_BACK)); try { $record = $select->getOneRow(); $transaction = new Pap_Db_Transaction(); $transaction->fillFromRecord($record); return $transaction; } catch (Gpf_Exception $e) { return null; } }
public function __construct(Pap_Stats_Params $params) { parent::__construct(Pap_Db_Table_Transactions::getInstance(), $params); }
/** * * @param $orderId * @param $includeRefund * @return Gpf_DbEngine_Row_Collection<Pap_Common_Transaction> */ private function getAllTransactionIdsWithOrderId($orderId, $includeRefund){ $status = array (Pap_Common_Constants::STATUS_APPROVED, Pap_Common_Constants::STATUS_PENDING); $types = array(Pap_Common_Constants::TYPE_SALE, Pap_Common_Constants::TYPE_ACTION, Pap_Common_Constants::TYPE_LEAD); if ($includeRefund == true) { $types[] = Pap_Common_Constants::TYPE_REFUND; } $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_Transactions::getInstance()); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add(Pap_Db_Table_Transactions::ORDER_ID, "=", $orderId); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "IN", $types); $select->where->add(Pap_Db_Table_Transactions::R_STATUS, "IN", $status); $transaction = new Pap_Common_Transaction(); return $transaction->loadCollectionFromRecordset($select->getAllRows()); }
/** * @return Gpf_DbEngine_Row_Collection */ protected function getTransactionsCollection() { $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->addAll(Pap_Db_Table_Transactions::getInstance()); $selectBuilder->from->add(Pap_Db_Table_Transactions::getName()); $selectBuilder->where->add(Pap_Db_Table_Transactions::SALE_ID,'=',$this->saleId); $recordSet = $selectBuilder->getAllRows(); $transaction = new Pap_Common_Transaction(); return $transaction->loadCollectionFromRecordset($recordSet); }
public function readRequestVariables() { $input = $this->readXmlData(); if (Gpf_Settings::get(Recurly_Config::RESEND_URL) != "") { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, Gpf_Settings::get(Recurly_Config::RESEND_URL)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); //curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $input); curl_exec($ch); /* $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, Gpf_Settings::get(Recurly_Config::RESEND_URL)); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); curl_exec($ch); */ } $this->debug("Input get: " . $input); try { $xml = new SimpleXMLElement($input); } catch (Exception $e) { $this->setPaymentStatus("Failed"); $this->debug('Wrong XML format!'); return false; } // read last tag to find out what kind of request this is, e.g. </new_subscription_notification> $status = strrpos($input,"</"); $status = substr($input,$status+2,strlen($input)-1); $status = substr($status,0,strrpos($status,">")); $this->setType($status); if ($this->getType() == self::NEWPAYMENT) { $totalcost_name = "amount_in_cents"; $this->setData1((string)$xml->{"transaction"}->{"invoice_number"}); } else { $totalcost_name = "total_amount_in_cents"; $this->setProductID((string)$xml->{"transaction"}->{"plan_code"}); } $this->setTransactionID((string)$xml->{"account"}->{"account_code"}); $this->setTotalCost((string)$xml->{"transaction"}->{$totalcost_name}/100)*(((string)$xml->{"transaction"}->{"quantity"})?(string)$xml->{"transaction"}->{"quantity"}:1); // get original Affiliate $status = array(Pap_Common_Constants::STATUS_APPROVED, Pap_Common_Constants::STATUS_PENDING); $types = array(Pap_Common_Constants::TYPE_SALE, Pap_Common_Constants::TYPE_ACTION, Pap_Common_Constants::TYPE_LEAD); $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_Transactions::getInstance()); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add(Pap_Db_Table_Transactions::ORDER_ID, "=", $this->getOrderID()); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "IN", $types); $select->where->add(Pap_Db_Table_Transactions::R_STATUS, "IN", $status); $transaction = new Pap_Common_Transaction(); $transaction->fillFromSelect($select); if (($transaction->getUserId() == null) OR ($transaction->getUserId() == "")) { $this->debug('No affiliate found for order ID: '.$this->getOrderID()); } else { $this->setAccountId($transaction->getAccountId()); $this->setAffiliateID($transaction->getUserId()); $this->setProductID($transaction->getProductId()); $this->setCampaignId($transaction->getCampaignId()); } }
public function __construct(Pap_Stats_Params $params, $dataType, $timeGroupBy) { parent::__construct(Pap_Db_Table_Transactions::getInstance(), $params, $timeGroupBy); $this->dataType = $dataType; }
protected function addOnlyPossibleFilters(Gpf_Rpc_FilterCollection $filters, Gpf_SqlBuilder_WhereClause $where) { $filterIterator = $filters->getIterator(); $columns = Pap_Db_Table_Transactions::getInstance()->getColumns(); while($filterIterator->valid()) { $filter = $filterIterator->current(); if ($this->filterIsValid($filter->getCode(), $columns)) { $filter->addTo($where); } $filterIterator->next(); } }
/** * @returns Pap_Common_Transaction * */ public function getFirstRecordWith($columnName, $value, $status = Pap_Common_Constants::STATUS_DECLINED) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_Transactions::getInstance()); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add($columnName, "=", $value); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "IN", array(Pap_Common_Constants::TYPE_SALE, Pap_Common_Constants::TYPE_ACTION, Pap_Common_Constants::TYPE_LEAD)); $select->where->add(Pap_Db_Table_Transactions::TIER, "=", "1"); if (is_array($status)) { $select->where->add(Pap_Db_Table_Transactions::R_STATUS, "IN", $status); }else{ $select->where->add(Pap_Db_Table_Transactions::R_STATUS, "=", $status); } $select->limit->set(0, 1); $t = new Pap_Common_Transaction(); $t->fillFromRecord($select->getOneRow()); return $t; }