Esempio n. 1
0
    /**
     *
     * @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;
    }
    /**
     * @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;
    }
    /**
     * @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;
    }