示例#1
0
 public static function transfer($transaction_id, $fromUser, $toUser, $ammount)
 {
     Zend_Registry::get('logger')->entering();
     $klass = get_class($toUser);
     Zend_Registry::get('logger')->debug("toUser is a {$klass}");
     $swapbuckEntry = new SwapbuckEntry();
     Zend_Registry::get('logger')->info("increment debitor:{$toUser->id} swapbucks points");
     $toUser->balance += $ammount;
     $toUser->save();
     Zend_Registry::get('logger')->info("record credit to debitor:{$toUser->id} swapbucks account");
     $credit = array('transaction_id' => $transaction_id, 'user_id' => $toUser->id, 'ammount' => $ammount);
     $swapbuckEntry->insert($credit);
     Zend_Registry::get('logger')->info("decrement debitor:{$fromUser->id} swapbucks points");
     $fromUser->balance += -1 * $ammount;
     $fromUser->save();
     Zend_Registry::get('logger')->info("record debit to creditor:{$toUser->id} swapbucks account");
     $debit = array('transaction_id' => $transaction_id, 'user_id' => $fromUser->id, 'ammount' => -1 * $ammount);
     $swapbuckEntry->insert($debit);
     Zend_Registry::get('logger')->exiting();
 }
示例#2
0
 public function signupUser($user)
 {
     Zend_Registry::get('logger')->entering();
     $transactionId = $this->create();
     $users = new User();
     $swaplady = $users->fetchRow('username = "******"');
     Zend_Registry::get('logger')->debug('Transfer signup bonus from swaplady to user');
     SwapbuckEntry::transfer($transactionId, $swaplady, $user, self::SIGNUP_BONUS);
     Zend_Registry::get('logger')->exiting();
     return $transactionId;
 }