Пример #1
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;
 }