示例#1
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     \Tbmt\DistributionStrategy::resetInstance();
     \Tbmt\Config::set('distribution.strategy', 'Waterfall');
 }
示例#2
0
 /**
  * Set user as paid and spread provisions.
  *
  * Update all current Transfers with state Transfer::STATE_RESERVED to
  * Transfer::STATE_COLLECT making them ready for processing.
  *
  * NOTE: Caller is responsible for transactional processing.
  *
  */
 public function onReceivedMemberFee($currency, $when, $freeFromInvitation, PropelPDO $con)
 {
     if (!$this->isExtended()) {
         return;
     }
     if ($this->hadPaid()) {
         throw new \Exception('Paid member receiving fee again!');
     }
     $referrer = $this->getReferrerMember();
     if (!$referrer) {
         throw new Exception('Member (' . $this->getId() . ') has no referrer!');
     }
     if (!$this->isMarkedAsPaid()) {
         // Prevent multiple income of the same message. Because this situation
         // can ocure more often because of the removal of not paying members
         // {@see $this->fireReservedReceivedMemberFeeEvents}
         if (!$freeFromInvitation) {
             \Tbmt\MailHelper::sendFeeIncome($this);
         }
     }
     if (!$freeFromInvitation) {
         \Tbmt\MailHelper::sendFeeIncomeReferrer($referrer, $this);
     }
     if ($referrer && !$referrer->hadPaid()) {
         // if the parent hasnt paid yet. reserve this event until his fee is
         // comming in or we kick him from the list.
         $referrer->reserveReceivedMemberFeeEvent($this, $currency, $when, $freeFromInvitation, $con);
         return;
     }
     $this->setPaidDate($when);
     TransferQuery::create()->filterByState(Transfer::STATE_RESERVED)->filterByMember($this)->update(['State' => Transfer::STATE_COLLECT], $con);
     \Tbmt\DistributionStrategy::getInstance()->onReceivedMemberFee($this, $referrer, $currency, $when, $freeFromInvitation, $con);
     $this->fireReservedReceivedMemberFeeEvents($con);
     $this->save($con);
 }