public function bid($id) { $token = Input::get('token', ''); $u_id = Input::get('u_id', 0); $price = Input::get('price', 0); try { $user = User::chkUserByToken($token, $u_id); if (!$price) { throw new Exception("请输入价格", 2001); } $auction = Auction::find($id); $auction->load(['eventItem']); $now = Tools::getNow(); if ($auction->eventItem->e_start_at > $now) { throw new Exception("还没开始", 2001); } if ($auction->eventItem->e_end_at < $now) { throw new Exception("已经结束", 2001); } if ($auction->a_cost < $price) { throw new Exception("竞拍价格不能超过市场价", 2001); } if (!AuctionBid::checkBlacklist($u_id)) { throw new Exception("现在还无法出价", 2001); } $bid = new AuctionBid(); $bid->a_id = $id; $bid->u_id = $u_id; $bid->b_price = $price; $bid->addBid(); $re = Tools::reTrue('出价成功'); } catch (Exception $e) { $re = Tools::reFalse($e->getCode(), '出价失败:' . $e->getMessage()); } return Response::json($re); }