protected function addRefundChargeback(Pap_Db_Transaction $refundChargeback, $type, $note = '', $orderId = '', $fee = 0) {
     foreach ($this as $name => $value) {
         $refundChargeback->set($name, $value);
     }
     $refundChargeback->setId(Gpf_Common_String::generateId());
     $refundChargeback->setCommission(($this->getCommission() * -1) - $fee);
     $refundChargeback->setType($type);
     if ($orderId != '') {
         $refundChargeback->setOrderId($orderId);
     }
     $refundChargeback->setParentTransactionId($this->getId());
     $refundChargeback->setDateInserted(Gpf_Common_DateUtils::now());
     $refundChargeback->setPayoutStatus(Pap_Common_Constants::PSTATUS_UNPAID);
     $refundChargeback->setMerchantNote($note);
     if ($refundChargeback->getStatus() == Pap_Common_Constants::STATUS_APPROVED) {
         $refundChargeback->setDateApproved($refundChargeback->getDateInserted());
     } else {
         $refundChargeback->setDateApproved('');
     }
     $refundChargeback->insert();
 }
示例#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;
 }