Esempio n. 1
0
 /**
  * 
  * @param TBT_Rewards_Model_Customer $customer
  * @return boolean
  */
 public function maxLikesReached($customer)
 {
     $max_likes = Mage::helper('rewardssocial/facebook_config')->getMaxLikeRewardsPerDay($customer->getStore());
     $current_time = time();
     $h24 = 60 * 60 * 24;
     $oldest_req_time = $current_time - $h24;
     $all_likes_since_time = Mage::getModel('rewardssocial/facebook_like')->getCollection()->addFilter('customer_id', $customer->getId())->addFieldToFilter('UNIX_TIMESTAMP(created_time)', array('gteq' => $oldest_req_time));
     if ($all_likes_since_time->count() > $max_likes) {
         return true;
     }
     $like_transfers = Mage::getResourceModel('rewardssocial/facebook_like_transfer_collection')->filterCustomerRewardsSince($customer->getId(), $oldest_req_time);
     if ($like_transfers->load()->count() > $max_likes) {
         return true;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Do the points transfer for the review
  *
  * @param  TBT_Rewards_Model_Customer $customer
  * @param  int $rule Special Rule
  * @return boolean whether or not the point-transfer succeeded
  */
 public function transferBirthdayPoints($customer, $rule)
 {
     $currencyId = $rule->getPointsCurrencyId();
     $pointAmount = $rule->getPointsAmount();
     $customerId = $customer->getId();
     //$ruleId = $rule->getId();
     $transfercomment = $this->getTransferComment();
     $transferStatus = $this->getInitialTransferStatus();
     $transfer = $this->create($customerId, $pointAmount, $currencyId, $transfercomment, $transferStatus);
     return null != $transfer;
 }
Esempio n. 3
0
 protected function getTotalPointsSpentInLast365Days(TBT_Rewards_Model_Customer $c)
 {
     $yearStart = date("Y-m-d", time() - self::SECS_IN_YEAR);
     // get current year
     $filteredTransferes = $c->getCustomerPointsCollectionAll()->addFieldToFilter("quantity", array('lt' => 0))->addFieldToFilter("creation_ts", array('gteq' => $yearStart))->addFieldToFilter("reason_id", array('eq' => TBT_Rewards_Model_Transfer_Reason::REASON_CUSTOMER_REDEMPTION))->addFieldToFilter("customer_id", $c->getId());
     $points_spent = $filteredTransferes->sumPoints()->getFirstItem()->getPointsCount();
     return $points_spent;
 }