public function getRelatedRelpies()
 {
     $cate = Input::get('cate', '');
     $id = Input::get('id', 0);
     $last_id = Input::get('last_id', 0);
     $per_page = Input::get('per_page', 30);
     $mapping = Reply::getRepliableCate();
     try {
         if (array_key_exists($cate, $mapping)) {
             $cate = $mapping[$cate];
         } else {
             throw new Exception("需要传入有效的评论分类", 2001);
         }
         $query = Reply::with(['user'])->select('replies.*')->where('replies.status', '=', 1);
         if ($last_id) {
             $query = $query->where('replies.id', '<', $last_id);
         }
         $query = $query->join('repliables', function ($q) use($cate, $id) {
             $q->on('repliables.reply_id', '=', 'replies.id')->where('repliables.repliable_type', '=', $cate)->where('repliables.repliable_id', '=', $id);
         });
         $list = $query->orderBy('replies.id', 'DESC')->paginate($per_page);
         $data = [];
         foreach ($list as $key => $reply) {
             $data[] = $reply->showInList();
         }
         $re = Tools::reTrue('获取评论成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取评论失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Example #2
0
 public function listIndexTop()
 {
     $base = Config::get('app.url');
     $data = [['url' => $base . 'banner/1', 'img' => 'http://qnck001.oss-cn-hangzhou.aliyuncs.com/banner/1.png', 'title' => '青年创'], ['url' => $base . 'banner/2', 'img' => 'http://qnck001.oss-cn-hangzhou.aliyuncs.com/banner/2.png', 'title' => '青年创']];
     $re = Tools::reTrue('获取首页广告成功', $data);
     return Response::json($re);
 }
 public function sendOrders()
 {
     set_time_limit(60000);
     try {
         $user = User::find(5);
         if ($user->u_priase_count == 0) {
             throw new Exception("已经执行过了", 30001);
         } else {
             $user->u_priase_count = 0;
             $user->save();
         }
         $str_text = '恭喜“双11不怕剁手”众筹活动已成功,您被众筹发起者选中,请于12日18时前凭此信息到零栋铺子领取众筹回报。4006680550';
         $str_push = '恭喜“双11不怕剁手”众筹活动已成功,您被众筹发起者选中,请于12日18时前凭此信息到零栋铺子领取众筹回报。4006680550';
         $orders = Order::selectRaw('right(`t_orders`.`o_number`, 4) AS seed, `t_orders`.*')->join('carts', function ($q) {
             $q->on('orders.o_id', '=', 'carts.o_id');
         })->where('carts.c_type', '=', 2)->where('carts.p_id', '=', 4)->orderBy('seed', 'DESC')->limit(111)->get();
         foreach ($orders as $key => $order) {
             if (empty($order)) {
                 continue;
             }
             $phones = $order->o_shipping_phone;
             $pushObj = new PushMessage($order->u_id);
             $pushObj->pushMessage($str_push);
             echo 'pushed to ' . $order->u_id . ' </br>';
             $phoneObj = new Phone($order->o_shipping_phone);
             $phoneObj->sendText($str_text);
             echo 'texted to ' . $order->o_shipping_phone . ' </br>';
         }
         File::put('/var/www/qingnianchuangke/phones', implode(',', $phones));
         $re = Tools::reTrue('发送中奖信息成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '发送中奖信息失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function postFavorite($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $type = Input::get('type', 0);
     try {
         $user = User::chkUserByToken($token, $u_id);
         $booth = Booth::find($id);
         if (empty($booth)) {
             throw new Exception("请求的店铺不存在", 2001);
         }
         $chk = $booth->favorites()->where('favorites.u_id', '=', $u_id)->first();
         if ($type == 1) {
             if (empty($chk)) {
                 $data = ['u_id' => $u_id, 'created_at' => Tools::getNow(), 'u_name' => $user->u_nickname];
                 $favorite = new Favorite($data);
                 $booth->favorites()->save($favorite);
             }
         } else {
             if (!empty($chk)) {
                 $booth->favorites()->detach($chk->id);
                 $chk->delete();
             }
         }
         $re = Tools::reTrue('操作成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '操作失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Example #5
0
 public function postImg()
 {
     $cate = Input::get('cate', '');
     $token = Input::get('img_token', '');
     try {
         $oss = new AliyunOss($cate, $token);
         $data = $oss->upload();
         $re = Tools::reTrue('上传图片成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '上传图片失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function getSign()
 {
     $noncestr = Input::get('noncestr', '');
     $timestamp = Input::get('timestamp', '');
     $url = Input::get('url', '');
     try {
         $curl = new CurlRequest();
         $request_url = 'http://qnckwx.54qnck.com/GetjsapiInfo.ashx?noncestr=' . $noncestr . '&timestamp=' . $timestamp . '&url=' . urlencode($url);
         $data = $curl->get($request_url);
         $data = $data['content'];
         $re = Tools::reTrue('获取签名成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getMessage(), '获取签名失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Example #7
0
 public function postFeedback()
 {
     $u_id = Input::get('u_id', 0);
     $comment = Input::get('comment', '');
     $app_ver = Input::get('app_ver', '');
     try {
         $feedback = new AppFeedback();
         $feedback->u_id = $u_id;
         $feedback->comment = $comment;
         $feedback->app_ver = $app_ver;
         $feedback->addFeedback();
         $re = Tools::reTrue('提交成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '提交失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function getBooth($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     try {
         $user = User::chkUserByToken($token, $u_id);
         $booth = Booth::find($id);
         if (empty($booth) || $booth->u_id != $u_id) {
             throw new Exception("无法获取请求的店铺", 7001);
         }
         $data = $booth->showDetail();
         $re = Tools::reTrue('获取店铺信息成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取店铺信息失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function listClubs()
 {
     $per_page = Input::get('per_page', 100000);
     try {
         $list = Club::with(['user'])->paginate($per_page);
         $data = [];
         $data['rows'] = [];
         foreach ($list as $key => $club) {
             $data['rows'][] = $club->showInList();
         }
         $data['total'] = $list->getTotal();
         $re = Tools::reTrue('获取社团成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取社团失败:' . $e->getMessage());
     }
     return Responce::json($re);
 }
 public function countNots()
 {
     $u_id = Input::get('u_id', 0);
     $token = Input::get('token', '');
     try {
         $user = User::chkUserByToken($token, $u_id);
         $list = Notification::join('notification_receivers', function ($q) {
             $q->on('notifications.n_id', '=', 'notification_receivers.n_id');
         })->leftJoin('notification_reads', function ($q) {
             $q->on('notification_reads.n_id', '=', 'notifications.n_id');
         })->where('notification_reads.u_id', '=', $u_id)->where('notifications.n_status', '=', 1)->where('notification_receivers.to_type', '=', '2')->where('notification_receivers.to_id', '=', 0)->orWhere('notification_receivers.to_id', '=', $u_id)->havingRaw('(`t_notification_reads`.`is_read` <> 1 AND `t_notification_reads`.`is_del` <> 1) OR (`t_notification_reads`.`is_read` IS NULL AND `t_notification_reads`.`is_del` IS NULL )')->get();
         $count = count($list);
         $data = ['count' => $count];
         $re = Tools::reTrue('获取消息成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取消息失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Example #11
0
 public function listUser()
 {
     $token = Input::get('token', '');
     $ids = Input::get('ids', '');
     $ids = explode(',', $ids);
     try {
         $user = User::chkUserByToken($token);
         $friends = User::whereIn('u_id', $ids)->get();
         // return all users without any restriction case IM will use all users
         $data = [];
         foreach ($friends as $key => $friend) {
             $data[] = $friend->showInImList();
         }
         $re = Tools::reTrue('获取信息成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取信息失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function updateBooth($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $lat = Input::get('lat', 0);
     $lng = Input::get('lng', 0);
     try {
         $user = User::chkUserByToken($token, $u_id);
         $booth = Booth::find($id);
         if ($booth->u_id != $user->u_id) {
             throw new Exception("您无法操作该店铺", 7001);
         }
         $booth->latitude = $lat;
         $booth->longitude = $lng;
         $booth->save();
         $re = Tools::reTrue('更新店铺地址成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '更新店铺地址:' . $e->getMessage());
     }
 }
 public function confirmDraw($id)
 {
     $confirm = Input::get('confirm', 0);
     $comment = Input::get('comment', '');
     $img_token = Input::get('img_token', '');
     DB::beginTransaction();
     try {
         $draw = UsersDraw::find($id);
         if (empty($draw)) {
             throw new Exception("请求的数据不存在", 10001);
         }
         $balance = UsersWalletBalances::find($draw->u_id);
         if (empty($balance)) {
             $balance = new UsersWalletBalances();
             $balance->u_id = $draw->u_id;
         }
         if ($confirm == 1) {
             $balance->deFreez($draw->d_amount);
             $draw->d_status = 1;
             $balance->getOut($draw->d_amount);
         } elseif ($confirm == 0) {
             $draw->d_status = 2;
         } else {
             throw new Exception("只有确认提现/不确认提现", 10001);
         }
         $draw->confirm($comment);
         if ($img_token) {
             $imgObj = new Img('draw', $img_token);
             $imgs = $imgObj->getSavedImg($draw->d_id);
             $draw->imgs = $imgs;
             $draw->save();
         }
         $re = Tools::reTrue('确认提现成功');
         DB::commit();
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '确认提现失败:' . $e->getMessage());
         DB::rollback();
     }
     return Response::json($re);
 }
 public function enable($id)
 {
     $status = Input::get('status', 0);
     $remark = Input::get('remark', '');
     try {
         $product = Product::find($id);
         if (empty($product)) {
             throw new Exception("没有找到可用的产品", 10001);
         }
         if ($status == 1) {
             $product->p_status = 1;
         } else {
             $product->p_status = -1;
         }
         $product->p_remark = $remark;
         $product->save();
         $re = Tools::reTrue('修改产品状态成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '修改产品状态失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function postRoleUser($id)
 {
     $users = Input::get('users', '');
     try {
         SysUserRole::clearRoleUser($id);
         if (!empty($users)) {
             if (!is_array($users)) {
                 $role = SysRole::find($id);
                 if (empty($role)) {
                     throw new Exception("没有找到请求的角色", 1);
                 }
                 $users = explode(',', $users);
                 foreach ($users as $key => $user) {
                     if (!$user) {
                         continue;
                     }
                     $role->addUser($user);
                 }
             }
         }
         $re = Tools::reTrue('设置用户成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '设置用户失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function removeInvite($id)
 {
     try {
         $log = UserFriendInviteLog::find($id);
         if (empty($log)) {
             throw new Exception("好友邀请已删除", 3001);
         }
         $u_id = $log->u_id;
         $friend = $log->friend_id;
         $userFriend = UsersFriend::findLinkById($u_id, $friend);
         if ($userFriend === UsersFriend::$RELATION_NONE) {
         } elseif ($userFriend->t_status == 1) {
             $userFriend->remove();
         }
         $log->delete();
         $re = Tools::reTrue('删除好友邀请成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '删除好友邀请失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Example #17
0
 public function getUserType()
 {
     $data = User::getUserType();
     $re = Tools::reTrue('获取用户类型成功', $data);
     return Response::json($re);
 }
 public function enable($id)
 {
     $status = Input::get('status', 0);
     $remark = Input::get('remark', '');
     try {
         $booth = booth::find($id);
         if (empty($booth)) {
             throw new Exception("没有找到请求的店铺", 10001);
         }
         if ($status == 1) {
             $status = 1;
             $msg = '您的店铺[' . $booth->b_title . ']已被启用';
         } else {
             $status = -1;
             $msg = '您的店铺[' . $booth->b_title . ']已被禁用';
         }
         $obj = new MessageDispatcher($booth->u_id);
         $obj->fireTextToUser($msg);
         $booth->b_status = $status;
         $booth->remark = $remark;
         $booth->save();
         $re = Tools::reTrue('用户状态修改成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '用户状态修改失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Example #19
0
 public function putHeadImg()
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $img_token = Input::get('img_token');
     try {
         $user = User::chkUserByToken($token, $u_id);
         if ($img_token) {
             $imgObj = new Img('user', $img_token);
             $imgs = $imgObj->getSavedImg($u_id, implode(',', [$user->u_head_img]), true);
             $head_img = Img::filterKey('head_img', $imgs);
             $user->u_head_img = implode(',', $head_img);
             $user->save();
         } else {
             throw new Exception("请上传头像", 2001);
         }
         $data['head_img'] = $head_img;
         $re = Tools::reTrue('修改头像成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '修改头像失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function retriveLoan($id)
 {
     DB::beginTransaction();
     $now = new DateTime();
     try {
         $current_loan = Repayment::find($id);
         if (empty($current_loan)) {
             throw new Exception("没有找到请求的放款", 6001);
         }
         $fund = Fund::find($current_loan->f_id);
         if (empty($fund)) {
             throw new Exception("没有找到相关的基金", 6001);
         }
         $fund->load('loans');
         $current_income = $fund->getCurrentPeriodIncome();
         $current_loan->f_income = $current_income;
         $profit = $current_income - $current_loan->f_re_money;
         if ($profit > 0) {
             $wallet = UsersWalletBalances::find($fund->u_id);
             if (empty($wallet)) {
                 throw new Exception("没有获取到用户钱包", 6001);
             }
             $wallet->putIn($profit);
             $current_loan->f_status = 4;
             $current_loan->f_money = $current_loan->f_re_money;
         } elseif ($profit == 0) {
             $current_loan->f_status = 3;
             $current_loan->f_money = $current_loan->f_re_money;
         } elseif ($profit < 0) {
             $current_loan->f_status = 2;
             $current_loan->f_money = $current_loan->f_income;
         }
         $current_loan->repaied_at = $now->format('Y-m-d H:i:s');
         $current_loan->save();
         $fund->load('loans');
         $all_repaied = true;
         $total_loan = 0;
         $total_repay = 0;
         foreach ($fund->loans as $key => $loan) {
             if ($loan->f_status < 3) {
                 $all_repaied = false;
             }
             $total_loan += $loan->f_re_money;
             $total_repay += $loan->f_money;
         }
         if ($all_repaied) {
             $total_profit = $total_repay - $total_loan;
             if ($profit > 0) {
                 $qnck_profit = $total_loan * (100 + $fund->t_profit_rate) / 500;
                 $wallet = UsersWalletBalances::find($fund->u_id);
                 if (empty($wallet)) {
                     throw new Exception("没有获取到用户钱包", 6001);
                 }
                 $wallet->getOut($qnck_profit);
             }
             $fund->t_is_close = 1;
             $fund->closed_at = $now->format('Y-m-d H:i:s');
         } else {
             $fund->t_is_close = 0;
         }
         $msg = new MessageDispatcher($fund->u_id);
         $msg->fireTextToUser('您基金的第' . $current_loan->f_schema . '次已结账, 金额:' . $current_income);
         $fund->save();
         $re = Tools::reTrue('回收放款成功');
         DB::commit();
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '回收放款失败:' . $e->getMessage());
         DB::rollback();
     }
     return Response::json($re);
 }
 public function listParticipates($id)
 {
     $per_page = Input::get('per_page');
     try {
         $funding = CrowdFunding::find($id);
         if (empty($funding) || $funding->c_status < 3) {
             throw new Exception("没有找到请求的众筹信息", 1);
         }
         $participates = $funding->getParticipates($per_page);
         $data = [];
         foreach ($participates as $key => $user) {
             $tmp = $user->showInList();
             $tmp['o_id'] = $user->o_id;
             $tmp['shipping_address'] = $user->o_shipping_address;
             $tmp['comment'] = $user->o_comment;
             $tmp['shipping_phone'] = $user->o_shipping_phone;
             $tmp['quantity'] = $user->c_quantity;
             $data[] = $tmp;
         }
         $re = Tools::reTrue('获取参与用户成功', $data, $participates);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取参与用户失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function postReply($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $content = Input::get('content', '');
     $to_u_id = Input::get('to', 0);
     $to = Input::get('parent', 0);
     try {
         $product = Product::find($id);
         $product->p_reply_count += 1;
         $user = User::chkUserByToken($token, $u_id);
         $to_user = User::find($to_u_id);
         if (empty($to_user)) {
             $to_u_id = 0;
             $to_u_name = '';
         } else {
             $to_u_name = $to_user->u_nickname;
             if ($product->p_type == 2) {
                 $cate = Notification::$CATE_FLEA;
             } else {
                 $cate = Notification::$CATE_PRODUCT_PROMO;
             }
             $msg = new MessageDispatcher();
             $msg->fireCateToUser('您有新的用户回复', $cate, $id);
         }
         $data = ['to_id' => $to, 'created_at' => Tools::getNow(), 'content' => $content, 'u_id' => $u_id, 'u_name' => $user->u_nickname, 'status' => 1, 'to_u_id' => $to_u_id, 'to_u_name' => $to_u_name];
         $reply = new Reply($data);
         $product->replies()->save($reply);
         $product->save();
         $re = Tools::reTrue('回复成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '回复失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Example #23
0
 public function payFailed()
 {
     $order_no = Input::get('order_no', '');
     $u_id = Input::get('u_id', '');
     $token = Input::get('token', '');
     DB::beginTransaction();
     try {
         $orders = Order::getGroupOrdersByNo($order_no);
         foreach ($orders as $key => $order) {
             $carts = Cart::where('o_id', '=', $order->o_id)->get();
             foreach ($carts as $cart) {
                 $cart->delete();
             }
             $order->delete();
         }
         $re = Tools::reTrue('取消成功');
         DB::commit();
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '取消失败:' . $e->getMessage());
         DB::rollback();
     }
     return Response::json($re);
 }
 public function listFlea()
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $per_page = Input::get('per_page', 30);
     try {
         $user = User::chkUserByToken($token, $u_id);
         $query = Product::with(['booth' => function ($q) {
             $q->with(['user', 'school']);
         }, 'quantity', 'praises' => function ($q) {
             $q->where('praises.u_id', '=', $this->u_id);
         }])->where('u_id', '=', $u_id)->where('p_type', '=', 2);
         $list = $query->orderBy('created_at', 'DESC')->paginate($per_page);
         $data = [];
         foreach ($list as $key => $product) {
             $tmp = $product->showInList();
             if (count($product->praises) > 0) {
                 $tmp['is_praised'] = 1;
             } else {
                 $tmp['is_praised'] = 0;
             }
             $data[] = $tmp;
         }
         $re = Tools::reTrue('获取我发布的产品成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取我发布的产品失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function getAuction($id)
 {
     try {
         $auction = Auction::find($id);
         if (empty($auction)) {
             throw new Exception("没有找到请求的数据", 2001);
         }
         $auction->load('eventItem');
         $data = $auction->showDetail();
         $re = Tools::reTrue('获取竞拍成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取竞拍失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function listBuyCrowdFunding()
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $per_page = Input::get('per_page', 30);
     try {
         $user = User::chkUserByToken($token, $u_id);
         $query = CrowdFunding::select('crowd_fundings.*')->with(['city', 'school', 'user', 'product', 'eventItem', 'praises' => function ($q) {
             $q->where('praises.u_id', '=', $this->u_id);
         }])->join('crowd_funding_products', function ($q) {
             $q->on('crowd_fundings.cf_id', '=', 'crowd_funding_products.cf_id');
         })->join('carts', function ($q) {
             $q->on('carts.p_id', '=', 'crowd_funding_products.p_id')->where('carts.c_type', '=', 2)->where('carts.u_id', '=', $this->u_id)->where('carts.c_status', '=', 3);
         });
         $list = $query->orderBy('created_at', 'DESC')->paginate($per_page);
         $data = [];
         foreach ($list as $key => $funding) {
             $tmp = $funding->showInList();
             $tmp['is_praised'] = 0;
             if (count($funding->praises) > 0) {
                 $tmp['is_praised'] = 1;
             }
             $data[] = $tmp;
         }
         $re = Tools::reTrue('获取众筹成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取众筹失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function enable($id)
 {
     $status = Input::get('status', 0);
     $remark = Input::get('remark', '');
     try {
         $user = User::find($id);
         if (empty($user)) {
             throw new Exception("没有找到请求的用户", 10001);
         }
         $log = new LogUserProfileCensors();
         $log->u_id = $user->u_id;
         $log->cate = 'base';
         $log->admin_id = Tools::getAdminId();
         if ($status == 1) {
             $status = 1;
             $log->content = '用户状态修改为: 启用';
         } else {
             $status = -1;
             $log->content = '用户状态修改为: 禁用';
         }
         $log->addLog();
         $user->u_status = $status;
         $user->u_remark = $remark;
         $user->save();
         $re = Tools::reTrue('用户状态修改成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '用户状态修改失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function delAd($id)
 {
     DB::beginTransaction();
     try {
         $ad = Advertisement::find($id);
         $ad->delAd();
         $re = Tools::reTrue('删除成功');
         DB::commit();
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '删除失败:' . $e->getMessage());
         DB::rollback();
     }
     return Response::json($re);
 }
 public function postBank()
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', '');
     // id bank
     $bankId = Input::get('bank', 0);
     // bank card number
     $cardNum = Input::get('card_num', '');
     // card holder name
     $cardHolderName = Input::get('holder_name', '');
     // card holder phone
     $cardHolderPhone = Input::get('holder_phone', '');
     // card holder identy
     $cardHolderID = Input::get('holder_id', '');
     try {
         $user = User::chkUserByToken($token, $u_id);
         $card = TmpUserProfileBankcard::find($u_id);
         if (!isset($card->u_id)) {
             $card = new TmpUserProfileBankcard();
         }
         if ($card->u_status == 1) {
             throw new Exception("您的审核已经通过", 3002);
         }
         $card->u_id = $u_id;
         $card->b_id = $bankId;
         $card->b_card_number = $cardNum;
         $card->b_holder_name = $cardHolderName;
         $card->b_holder_phone = $cardHolderPhone;
         $card->b_holder_id_number = $cardHolderID;
         $card->register();
         $re = Tools::reTrue('提交银行卡信息成功');
     } catch (Exception $e) {
         // TmpUserProfileBankcard::clearByUser($u_id);
         $re = Tools::reFalse($e->getCode(), '提交银行卡信息失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
 public function logout()
 {
     Session::forget('admin_id');
     $re = Tools::reTrue('登出成功');
     return Response::json($re);
 }