Ejemplo n.º 1
0
 public function postWalletDraw()
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $amount = Input::get('amount');
     $payment = Input::get('payment', '');
     $account = Input::get('account', '');
     $b_id = Input::get('b_id', 0);
     $holder = Input::get('holder', '');
     DB::beginTransaction();
     try {
         if ($payment == 1 && (!$b_id || !$holder)) {
             throw new Exception("提现到银行卡需要填写持卡人姓名并选择银行", 9008);
         }
         $user = User::chkUserByToken($token, $u_id);
         $draw = new UsersDraw();
         $draw->u_id = $u_id;
         $draw->d_payment = $payment;
         $draw->d_account = $account;
         $draw->d_amount = $amount;
         $draw->b_id = $b_id;
         $draw->b_holder_name = $holder;
         $d_id = $draw->addDraw();
         $wallet = UsersWalletBalances::find($u_id);
         $wallet->freez($amount);
         $data['id'] = $d_id;
         $re = Tools::reTrue('提现申请成功', $data);
         DB::commit();
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '提现申请失败:' . $e->getMessage());
         DB::rollback();
     }
     return Response::json($re);
 }