public function process(Pap_Common_TransactionCompoundContext $context) { $transaction = $context->getTransaction(); $context->getContext()->debug("SubaffiliateFirstSaleBonus started"); if($transaction->getTier() != 2) { $context->getContext()->debug("SubaffiliateFirstSaleBonus ended - Not 2. tier"); return; } $row = $this->getChildAffiliateInfo($transaction); $date = new Gpf_DateTime(time()); $date->addDay(-Gpf_Settings::get(SubaffiliateFirstSaleBonus_Config::VALIDITY_DAYS)); if(Gpf_Common_DateUtils::getDateTime($date->toTimeStamp()) > $row->get(Pap_Db_Table_Users::DATEINSERTED)) { $context->getContext()->debug("SubaffiliateFirstSaleBonus ended - Date Inserted is older than defined days."); return; } if($this->getChildAffiliateTransactionsCount($row->get(Pap_Db_Table_Transactions::USER_ID)) > 1) { $context->getContext()->debug("SubaffiliateFirstSaleBonus ended - Not user's first transaction."); return; } if(Gpf_Settings::get(SubaffiliateFirstSaleBonus_Config::BONUS_TYPE) == '%') { $transaction->setCommission($transaction->getCommission()+(Gpf_Settings::get(SubaffiliateFirstSaleBonus_Config::BONUS_AMOUNT)/100)*$transaction->getTotalCost()); } else{ $transaction->setCommission(Gpf_Settings::get(SubaffiliateFirstSaleBonus_Config::BONUS_AMOUNT)+$transaction->getCommission()); } $context->getContext()->debug("SubaffiliateFirstSaleBonus ended - Success."); return; }
public function cleanupOldRegistrations() { $notificationRegistrationRow = new Gpf_Db_NotificationRegistration(); $rowCollection = $notificationRegistrationRow->loadCollection(); foreach ($rowCollection as $notificationRegistrationRow) { $notificationRegistrationTime = new Gpf_DateTime($notificationRegistrationRow->getRegistrationTime()); if ($notificationRegistrationTime->toTimeStamp() < time() - self::MONTH * 3) { $notificationRegistrationRow->delete(); } } }
/** * @return boolean */ protected function isValidDate() { $date = new Gpf_DateTime(); $timeStamp = $date->toTimeStamp(); // $validFrom = strtotime($this->getValidFrom()); // $validTo = strtotime($this->getValidTo()); $validFrom = Gpf_Common_DateUtils::getTimestamp($this->getValidFrom()); $validTo = Gpf_Common_DateUtils::getTimestamp($this->getValidTo()); if ($validFrom == false || $validTo == false) { return false; } if ($timeStamp > $validFrom && $timeStamp < $validTo) { return true; } return false; }
public function isAllTime() { return $this->from->toTimeStamp() == Gpf_DateTime::min()->toTimeStamp() && $this->to->toTimeStamp() == Gpf_DateTime::min()->toTimeStamp(); }
private function processAllRefunds() { $targetTime = new Gpf_DateTime(); $targetTime->addMonth(-Gpf_Settings::get(ccBill_Config::PROCESS_REBILL_TIMEFRAME)); $targetTimeFlag = strftime('%Y%m%d', $targetTime->toTimeStamp()); while ($targetTimeFlag != $this->getTimeProgress()) { Gpf_Log::debug('ccBill rebill process task progress: ' . $this->getTimeProgress()); $progress = $this->getProgress(); $ansver = $this->getTransactionsListForPeriod($progress); if (strpos($ansver, 'Too many requests')) { Gpf_Log::debug('Postponding task for one more hour'); $this->interrupt(3700); } else { $this->processCsvList($ansver); } $this->setProgress($this->getNextTimeProgress($progress)); } }