コード例 #1
0
 /**
  * Distribute provisions for member signup.
  *
  * ATTENTION: This method does NOT save changes to $advertisedMember. The
  * caller is required to save this object!
  *
  * @param  Member    $advertisedMember
  * @param  PropelPDO $con
  */
 public function payAdvertisingFor(\Member $referrer, \Tbmt\MemberFee $memberFee, \Member $advertisedMember, $currency, $when, \PropelPDO $con)
 {
     $advertisedMemberId = $advertisedMember->getId();
     $transfer = $referrer->getCurrentTransferBundle($currency, $con);
     if ($referrer->getFundsLevel() === \Member::FUNDS_LEVEL1) {
         // @see resources/snowball.txt - processes - P1
         $transaction = $transfer->createTransactionForReason($referrer, \Transaction::REASON_ADVERTISED_LVL1, $advertisedMemberId, $when, $con);
         $memberFee->subtract($transaction->getAmount(), \Transaction::REASON_ADVERTISED_LVL1);
         $parent = $referrer->getMemberRelatedByParentId($con);
         if ($parent) {
             $parentTransfer = $parent->getCurrentTransferBundle($currency, $con);
             $parentTransaction = $parentTransfer->createTransactionForReason($parent, \Transaction::REASON_ADVERTISED_INDIRECT, $advertisedMemberId, $when, $con);
             $memberFee->subtract($parentTransaction->getAmount(), \Transaction::REASON_ADVERTISED_INDIRECT);
             $parentTransfer->save($con);
             $parent->save($con);
         }
     } else {
         // if ( $this->getFundsLevel() >= Member::FUNDS_LEVEL2 ) {
         // @see resources/snowball.txt - processes - P3
         $transaction = $transfer->createTransactionForReason($referrer, \Transaction::REASON_ADVERTISED_LVL2, $advertisedMemberId, $when, $con);
         $memberFee->subtract($transaction->getAmount(), \Transaction::REASON_ADVERTISED_LVL2);
     }
     $transfer->save($con);
     \MemberBonusIds::payBonuses($memberFee, $advertisedMember, $currency, $when, $con);
 }
コード例 #2
0
 /**
  * Distribute provisions for member signup.
  *
  * ATTENTION: This method does NOT save changes to $advertisedMember. The
  * caller is required to save this object!
  *
  * @param  Member    $advertisedMember
  * @param  PropelPDO $con
  */
 public function payAdvertisingFor(\Member $referrer, \Tbmt\MemberFee $memberFee, \Member $advertisedMember, $currency, $when, $freeFromInvitation, \PropelPDO $con)
 {
     $advertisedMemberId = $advertisedMember->getId();
     $transfer = $referrer->getCurrentTransferBundle($currency, $con);
     $transaction = $transfer->createTransactionForReason($referrer, \Transaction::REASON_ADVERTISED_LVL1, $advertisedMemberId, $when, $con);
     $memberFee->subtract($transaction->getAmount(), \Transaction::REASON_ADVERTISED_LVL1);
     $transfer->save($con);
     \MemberBonusIds::payBonuses($memberFee, $advertisedMember, $currency, $when, $con);
 }
コード例 #3
0
ファイル: Transaction.php プロジェクト: nikonehauser/ptclient
 public static function activity_createBonusTransaction(Member $login, Member $recipient, array $data, PropelPDO $con)
 {
     $currentTransfer = $recipient->getCurrentTransferBundle(self::$BASE_CURRENCY, $con);
     $when = time();
     $amount = $data['amount'];
     $recipient->addOutstandingTotal($amount, self::$BASE_CURRENCY);
     $transaction = $currentTransfer->addAmount($amount)->setReason(Transaction::REASON_CUSTOM_BONUS)->setPurpose($data['purpose'])->setRelatedId($login->getId())->setDate($when)->save($con);
     $currentTransfer->save($con);
     $recipient->save($con);
 }
コード例 #4
0
ファイル: Transaction.php プロジェクト: nikonehauser/pt
 public static function createBonusTransaction(Member $login, Member $recipient, array $data, PropelPDO $con)
 {
     $currentTransfer = $recipient->getCurrentTransferBundle(self::$BASE_CURRENCY, $con);
     $when = time();
     if (!$con->beginTransaction()) {
         throw new Exception('Could not begin transaction');
     }
     try {
         $amount = $data['amount'];
         $recipient->addOutstandingTotal($amount, self::$BASE_CURRENCY);
         $transaction = $currentTransfer->addAmount($amount)->setReason(Transaction::REASON_CUSTOM_BONUS)->setPurpose($data['purpose'])->setRelatedId($login->getId())->setDate($when)->save($con);
         $currentTransfer->save($con);
         $recipient->save($con);
         if (!$con->commit()) {
             throw new Exception('Could not commit transaction');
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
コード例 #5
0
ファイル: helper.php プロジェクト: nikonehauser/ptclient
 public static function getCurrentTransferBundle(Member $member)
 {
     return $member->getCurrentTransferBundle(self::$currency, self::$con);
 }
コード例 #6
0
ファイル: Member.php プロジェクト: nikonehauser/pt
 private static function doPay(\Tbmt\MemberFee $memberFee, $transfer, Member $member, $reason, $relatedId, $currency, $when, PropelPDO $con)
 {
     if ($transfer === null) {
         $transfer = $member->getCurrentTransferBundle($currency, $con);
     }
     $transaction = $transfer->createTransactionForReason($member, $reason, $relatedId, $when, $con);
     $memberFee->subtract($transaction->getAmount(), $reason);
     return $transfer;
 }