protected function insertTransaction($record) {
    	$obj = new Pap_Db_Transaction();
    	
    	$obj->setId($record->get('transid'));
    	$obj->setUserId($record->get('affiliateid'));
    	$obj->setCampaignId($record->get('campaignid'));
		$obj->setDateInserted($record->get('dateinserted'));
		if($record->get('dateapproved') != '') {
			$obj->setDateApproved($record->get('dateapproved'));
		}
		$obj->setSystemNote("Migrated from PAP3");
		$obj->set('countrycode', $record->get('countrycode'));
		$obj->set('ip', $record->get('ip'));
		$obj->set('refererurl', $record->get('refererurl'));
		$obj->set('browser', $record->get('browser'));
		$obj->setCommission($record->get('commission'));
		$obj->set('data1', $record->get('data1'));
		$obj->set('data2', $record->get('data2'));
		$obj->set('data3', $record->get('data3'));
		$obj->setFixedCost(0);
		$obj->setTotalCost($record->get('totalcost'));
		$obj->setOrderId($record->get('orderid'));
		$obj->setProductId($record->get('productid'));
		$obj->setAllowFirstClickData(GPF::YES);
		$obj->setAllowLastClickData(GPF::YES);
		if($record->get('payoutstatus') == 2) {
			$obj->setPayoutStatus('P');
		} else {
			$obj->setPayoutStatus('U');
		}
		$obj->setClickCount(1);
		$obj->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus')));
		$obj->setType(Pap3Compatibility_Migration_Pap3Constants::translateTransType($record->get('transtype')));

		$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('bannerid', $record->get('bannerid'));
		$obj->set('commtypeid', $record->get('campcategoryid'));
		if($record->get('accountingid') != '') {
			$obj->set('payouthistoryid', $record->get('accountingid'));
		}
    	$obj->save();
    	
//bannerid               char(8)              utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
//parentbannerid         varchar(8)           utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
//parenttransid          char(8)              utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
//recurringcommid        char(8)              utf8_general_ci  YES             (NULL)           select,insert,update,references
//firstclicktime         datetime             (NULL)           YES             (NULL)           select,insert,update,references
//firstclickreferer      varchar(250)         utf8_general_ci  YES             (NULL)           select,insert,update,references
//firstclickip           varchar(15)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//firstclickdata1        varchar(40)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//firstclickdata2        varchar(40)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//lastclicktime          datetime             (NULL)           YES             (NULL)           select,insert,update,references
//lastclickreferer       varchar(250)         utf8_general_ci  YES             (NULL)           select,insert,update,references
//lastclickip            varchar(15)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//lastclickdata1         varchar(40)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//lastclickdata2         varchar(40)          utf8_general_ci  YES             (NULL)           select,insert,update,references
//trackmethod            char(1)              utf8_general_ci  YES             U                select,insert,update,references
//commtypeid             char(8)              utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
//payouthistoryid        char(8)              utf8_general_ci  YES     MUL     (NULL)           select,insert,update,references
    	
    	$this->countSales++;
    }
示例#2
0
 private function addRemainingCommissionsForParents($tier, $maxTier, $lastUserId, Pap_Db_Transaction $lastTransaction, $simulation) {
     $output = '';
     $output .= $this->outputln($this->_('Creating remaining commissions for tiers: '. $tier . ' - '. $maxTier));
     for ($tier; $tier <= $maxTier; $tier++) {
         $reachedConditionUserIds = $this->getReachedConditionAffiliateIds();
         if (is_null($userId = $this->getParentWhoReachedCondition($lastUserId, $reachedConditionUserIds))) {
             $output .= $this->outputln($this->_('No next parent affiliate who reached condition.'));
             return $output;
         }
     
         $lastTransaction->setParentTransactionId($lastTransaction->getId());
         $lastTransaction->setId('');
         
         $lastTransaction->setTier($tier);
         $lastTransaction->setUserId($userId);
         try {
             $commission = $this->getCommissionForTransaction($lastTransaction);
             $lastTransaction->recompute($commission);
             if (!$simulation) {
                 $this->log('Inserting new transaction commission: ' . $lastTransaction->getCommission() . ', new tier: ' . $lastTransaction->getTier() . 'for userId: ' . $lastTransaction->getUserId());
                 $lastTransaction->insert();
             }
             $this->addedTransactionsCount++;
             $output .= $this->outputAddedTransacion($lastTransaction);
             $lastUserId = $userId;
         } catch (Gpf_Exception $e) {
             $output .= $this->outputln($this->_('Error during performing compression model calculations: %s, probably commission settings are changed.', $e->getMessage()));
             Gpf_Log::error($this->_('Error during performing compression model calculations: %s, probably commission settings are changed.', $e->getMessage()));
             return $output; 
         } 
     }
     return $output;
 }