コード例 #1
0
ファイル: PaymentMapper.php プロジェクト: blozixdextr/adtw
 public static function transfersTwitcher(User $user, $limit = 50)
 {
     return UserTransfer::whereSellerId($user->id)->paginate($limit);
 }
コード例 #2
0
ファイル: StreamMapper.php プロジェクト: blozixdextr/adtw
 public static function pay(User $user, Banner $banner, Stream $stream)
 {
     $pivot = self::getPivot($banner, $stream);
     $amount = round($pivot->amount, 2);
     $share = Config::get('banner.withdrawal_share');
     $twitcherShare = (100 - $share) / 100;
     $paymentForTwitcher = $pivot->amount * $twitcherShare;
     $twitcher = $stream->user;
     $twitcher->balance = $twitcher->balance + $paymentForTwitcher;
     $twitcher->save();
     $user->balance_blocked = $user->balance_blocked - $amount;
     if ($user->balance_blocked < 0) {
         $user->balance_blocked = 0;
     }
     $user->balance = $user->balance - $amount;
     if ($user->balance < 0) {
         $user->balance = 0;
     }
     $user->save();
     $transfer = UserTransfer::create(['buyer_id' => $user->id, 'seller_id' => $twitcher->id, 'title' => 'Paid banner#' . $banner->id, 'amount' => $paymentForTwitcher, 'currency' => 'USD']);
     self::referrerPay($transfer);
     $pivot->status = 'accepted';
     $pivot->transfer_id = $transfer->id;
     $pivot->save();
     return $transfer;
 }