public function getTransactionFieldValue($code) { if($this->transaction == null) { throw new Gpf_Exception("You have to set Transaction before getting transaction fields value!"); } if($code == self::TRANSACTIONID) { return $this->transaction->get(Pap_Db_Table_Transactions::TRANSACTION_ID); } else if($code == self::COMMISSION) { return $this->transaction->getCommissionAsText(); } else if($code == self::TOTALCOST) { return $this->transaction->getTotalCostAsText(); } else if($code == self::ORDERID) { return $this->transaction->getOrderId(); } else if($code == self::PRODUCTID) { return $this->transaction->getProductId(); } else if($code == self::TIER) { return $this->transaction->getTier(); } else if($code == self::CAMPAIGNID) { return $this->transaction->getCampaignId(); } else if($code == self::CAMPAIGNNAME) { return $this->getCampaignName($this->transaction->getCampaignId()); } else if($code == self::STATUS) { return $this->getStatus($this->transaction->getStatus()); } else if($code == self::STATUSCODE) { return $this->transaction->getStatus(); } else if($code == self::TYPE) { return $this->getType($this->transaction->getType()); } else if($code == self::RAWTYPE) { return $this->transaction->getType(); } else if($code == self::ACTIONNAME) { return $this->getActionName($this->transaction->getType(), $this->transaction->getCommissionTypeId()); } else if($code == self::SALEDATA1) { return $this->transaction->getData1(); } else if($code == self::SALEDATA2) { return $this->transaction->getData2(); } else if($code == self::SALEDATA3) { return $this->transaction->getData3(); } else if($code == self::SALEDATA4) { return $this->transaction->getData4(); } else if($code == self::SALEDATA5) { return $this->transaction->getData5(); } else if($code == self::ORIGINALCURRENCY) { return $this->getOriginalCurrencyName($this->transaction->get(Pap_Db_Table_Transactions::ORIGINAL_CURRENCY_ID)); } try { return $this->transaction->get($code); } catch (Gpf_Exception $e) { } return ''; }
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(); } }