protected function recomputeCommissions() {
        $transactions = $this->getTransactionsSelect();
        $this->rule->setTransactionsWhere($transactions->where, 't');

        foreach ($transactions->getAllRowsIterator() as $record) {       	
            $newCommission = new Pap_Db_Commission();
            $newCommission->setTypeId($record->get(Pap_Db_Table_Transactions::COMMISSIONTYPEID));
            $newCommission->setTier($record->get(Pap_Db_Table_Transactions::TIER));
            $newCommission->setGroupId($this->rule->getCommissionGroupId());          
            if ($record->get(Pap_Db_Table_Transactions::R_TYPE) == Pap_Common_Constants::TYPE_RECURRING) { 
            	$newCommission->setSubtype(Pap_Db_Table_Commissions::SUBTYPE_RECURRING);
            } else {
            	$newCommission->setSubtype(Pap_Db_Table_Commissions::SUBTYPE_NORMAL);
            }
            try {
            	$newCommission->loadFromData();
            } catch (Exception $e) {
            	$this->logMessage(sprintf("Error loading commission (%s)", $e->getMessage()));
            	return;
            }            
            $transaction = new Pap_Db_Transaction();
            $transaction->fillFromRecord($record);
            $transaction->recompute($newCommission);            
            $transaction->update();         
            $refundTransaction = $transaction->getRefundOrChargebackTransaction();
            if (!is_null($refundTransaction) &&
                    $refundTransaction->getStatus() != Pap_Common_Constants::STATUS_DECLINED &&
                    $refundTransaction->getPayoutStatus() == Pap_Common_Constants::PSTATUS_UNPAID) {
                $refundTransaction->recompute($newCommission);
                $refundTransaction->update();
            }
        }
        $this->logMessage(sprintf("Transactions were updated based on new commission group %s", $this->rule->getCommissionGroupId()));
    }
示例#2
0
 public function finishTransaction($newStatus) {      
     $transaction = new Pap_Db_Transaction();
     $transaction->setOrderId($_POST['LMI_PAYMENT_NO']);
     $transaction->setData5($_POST['LMI_SYS_TRANS_NO']);
     try {
         $transaction->loadFromData(array(Pap_Db_Table_Transactions::ORDER_ID, Pap_Db_Table_Transactions::DATA5));
     } catch (Gpf_DbEngine_NoRowException $e) {
         $this->debug('No such transaction with order id: ' . $transaction->getOrderId() . ' and data5: ' . $transaction->getData5() . '. Changing status ended.');
         return;
     }
     $transaction->setStatus($newStatus);
     $transaction->update();
 }
 /**
  * @return bool true if it is new transaction
  */
 protected function saveTransactionToDb($updateColumns) {
     if($updateColumns === null) {
         parent::insert();
         return true;
     }
     parent::update($updateColumns);
     return false;
 }
示例#4
0
 /**
  * @param Pap_Db_Transaction $transaction
  */
 private function declineTransaction(Pap_Db_Transaction $transaction) {
     $this->log('Decline transaction: ' . $transaction->getId());
     $transaction->setStatus(Pap_Common_Constants::STATUS_DECLINED);
     $transaction->setParentTransactionId('');
     $transaction->update(array(Pap_Db_Table_Transactions::R_STATUS, Pap_Db_Table_Transactions::PARRENT_TRANSACTION_ID));
 }