protected function addFillBonus(Pap_Common_User $user, $fillCount, $commission) {
		$transaction = new Pap_Common_Transaction();
		$transaction->setCommission($commission);
		$transaction->setType(Pap_Db_Transaction::TYPE_EXTRA_BONUS);
		$transaction->setDateInserted(Gpf_Common_DateUtils::now());
		$transaction->setStatus(Pap_Common_Constants::STATUS_APPROVED);
		$transaction->setPayoutStatus(Pap_Common_Constants::PSTATUS_UNPAID);
		$transaction->setUserId($user->getId());
		$transaction->setSystemNote($this->_('Matrix %sx fill bonus', $fillCount));
		$transaction->insert();
	}
 protected function insertBonusTransaction($commissionValue) {
     $transaction = new Pap_Common_Transaction();
     $transaction->setCommission($commissionValue);
     $transaction->setType(Pap_Db_Transaction::TYPE_EXTRA_BONUS);
     $transaction->setDateInserted(Gpf_Common_DateUtils::now());
     $transaction->setStatus('A');
     $transaction->setPayoutStatus('U');
     $transaction->setUserId($this->getCurrentUserId());
     $transaction->setCampaignId($this->transaction->getCampaignId());
     $transaction->setSystemNote('Commission of rule: ' . $this->rule->getString());
     $transaction->setData1($this->rule->getId());
     $transaction->setData2($this->getToDateRange());
     $transaction->insert();
 }
    public function createCommissions() {
        $comissionEntry = new Pap_Db_RecurringCommissionEntry();
        $comissionEntry->setRecurringCommissionId($this->getId());
        try {
            $parentTransaction = $this->getTransaction();
        } catch (Gpf_Exception $e) {
            $parentTransaction = null;
        }
        foreach ($comissionEntry->loadCollection() as $comissionEntry) {
            if (!$this->isExistsUser($comissionEntry->getUserId())) {
                Gpf_log::error('Recurring commissions - createCommissions: user does not exist: ' . $comissionEntry->getUserId());
                if ($comissionEntry->getTier() == '1') {
                    return;
                } else {
                    continue;
                }
            }
            $transaction = new Pap_Common_Transaction();
            $transaction->setDateInserted(Gpf_Common_DateUtils::now());
            $transaction->setType(Pap_Common_Constants::TYPE_RECURRING);
            $transaction->setTier($comissionEntry->getTier());
            $transaction->setUserId($comissionEntry->getUserId());
            $transaction->setCommissionTypeId($this->getCommissionTypeId());
            $transaction->setParentTransactionId($this->getTransactionId());
            $transaction->setCommission($comissionEntry->getCommission());
            $transaction->setPayoutStatus(Pap_Common_Transaction::PAYOUT_UNPAID);
            $transaction->setStatus(Pap_Common_Constants::STATUS_APPROVED);
            $transaction->setOrderId($this->getOrderId());

            if ($parentTransaction != null) {
                if ($transaction->getOrderId() == '') {
                    $transaction->setOrderId($parentTransaction->getOrderId());
                }
                $transaction->setProductId($parentTransaction->getProductId());
                $transaction->setTotalCost($parentTransaction->getTotalCost());
                $transaction->setCampaignId($parentTransaction->getCampaignId());
                $transaction->setBannerId($parentTransaction->getBannerId());
                $transaction->setParentBannerId($parentTransaction->getParentBannerId());
                $transaction->setCountryCode($parentTransaction->getCountryCode());
                $transaction->setData1($parentTransaction->getData1());
                $transaction->setData2($parentTransaction->getData2());
                $transaction->setData3($parentTransaction->getData3());
                $transaction->setData4($parentTransaction->getData4());
                $transaction->setData5($parentTransaction->getData5());
            }

            $transaction->save();
        }
    }
    protected function insertSummarizedTransaction($record) {
    	$obj = new Pap_Common_Transaction();
    	
    	$obj->setUserId($record->get('affiliateid'));
    	$obj->setCampaignId($record->get('campaignid'));
		$obj->setDateInserted($record->get('dateinserted'));
		$obj->setType(Pap3Compatibility_Migration_Pap3Constants::translateTransType($record->get('transtype')));
		$obj->setAllowFirstClickData(GPF::YES);
        $obj->setAllowLastClickData(GPF::YES);
		$obj->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus')));
		
		if($record->get('rstatus') == Pap3Compatibility_Migration_Pap3Constants::STATUS_APPROVED) {
			$obj->setDateApproved($record->get('dateinserted'));
		}
		
		$obj->setCommission($record->get('commission'));
		$obj->setSystemNote("Migrated from PAP3");
		if($record->get('payoutstatus') == 2) {
			$obj->setPayoutStatus('P');
		} else {
			$obj->setPayoutStatus('U');
		}
		$obj->setClickCount($record->get('count'));

		$transKind = $record->get('transkind');
		if($transKind > Pap3Compatibility_Migration_Pap3Constants::TRANSKIND_SECONDTIER) {
			$tier = $transKind - Pap3Compatibility_Migration_Pap3Constants::TRANSKIND_SECONDTIER;
		} else {
			$tier = 1;
		}
		$obj->setTier($tier);
		$obj->set('commtypeid', $record->get('campcategoryid'));
		
    	$obj->save();
    }
    private function setTransactionStatus(Pap_Common_Transaction $transaction, $transactionHeader, $transactionData) {
        if($this->form->getFieldValue(self::TRANSACTION_STATUS) != 'F') {
            Gpf_Log::info('Setting status form file to: ' . $this->form->getFieldValue(self::TRANSACTION_STATUS));
            $transaction->setStatus($this->form->getFieldValue(self::TRANSACTION_STATUS));
            return $transaction;
        }

        $data = array_flip($transactionHeader);
        $stat = $transactionData[$data[Pap_Db_Table_Transactions::R_STATUS]];
        if($stat == Pap_Common_Constants::STATUS_PENDING || $stat == Pap_Common_Constants::STATUS_APPROVED || $stat == Pap_Common_Constants::STATUS_DECLINED){
            Gpf_Log::info('Setting status form preset to: ' . $stat);
            $transaction->set(Pap_Db_Table_Transactions::R_STATUS, $stat);
            return $transaction;
        }
        Gpf_Log::error('Invalid transaction status in import data');
        throw new Gpf_Exception('Invalid transaction status in import data');
    }
Пример #6
0
 protected function insertTransaction($affiliateId, $type, $commissionValue, $status, Gpf_Data_Record $commission = null) {
     if ($affiliateId == null) {
         return;
     }
     $transaction = new Pap_Common_Transaction();
     $transaction->setUserId($affiliateId);
     $transaction->setType($type);
     if ($commission != null) {
         $transaction->setTier($commission->get(Pap_Db_Table_Commissions::TIER));
     } else {
         $transaction->setTier('1');
     }
     $transaction->setStatus($status);
     $transaction->setPayoutStatus('U');
     $transaction->setDateInserted(Gpf_Common_DateUtils::now());
     $transaction->setCommission($commissionValue);
     $transaction->setData5($this->user->getId());
     $transaction->setIp(Gpf_Http::getRemoteIp());
     $transaction->insert();
 }