/**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     if ($this->ismobile()) {
         $model = new Demand();
         $demands = $model->getBidding();
         $data = array('demands' => $demands);
         return view('indexm')->with($data);
     } else {
         return view('index');
     }
 }
Beispiel #2
0
 public function delDemand($id)
 {
     try {
         $demand = Demand::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         return Redirect::to('/')->withInput()->withErrors('竞购信息不存在或已被删除!');
     }
     $demand->delete();
     return Redirect::back()->withInput()->withErrors('删除成功!');
 }
Beispiel #3
0
 public function payDemand(Request $request, $id)
 {
     $demand = Demand::findOrFail($id);
     $demand->is_pay = 1;
     $demand->save();
     $winbid = Bid::whereRaw("demand_id={$id} and is_win=1")->first();
     $order = new Orders();
     $order->desn = $demand->id;
     $order->userid = Auth::user()->id;
     //这个是用户的编号用于以后检索
     $order->fee = $winbid->price - $demand->deposit;
     $order->fee = 0.01;
     //must comment
     $order->step = 2;
     //这是第二阶段来支付尾款
     $order->status = 0;
     $order->title = $demand->title . "-支付尾款";
     $order->details = $demand->title . "-支付尾款";
     $order->showurl = "http://www.51jinggou.com/demand/show/" . $id;
     $order->save();
     $paytype = $request->input("pay_type");
     if ($paytype == "alipay") {
         //  echo "this is alipay and id=".$order->id;
         //支付宝支付
         //根据不同的用户界面pc与mobile进行跳转
         if ($this->ismobile()) {
             $this->alipayapi($order->id);
         } else {
             $this->payorder($order->id);
         }
         exit;
         return;
     } elseif ($paytype == "weixin") {
         exit;
         //微信支付
         return;
     } else {
         // echo "this is bankpay";
         //网银支付
         $this->bankorder($paytype, $order->id);
     }
     /*
             return Redirect::to('/demand/show/' . $demand->id)
                 ->withInput()
                 ->withErrors('尾款支付成功,等待卖家发货!');
     */
 }
Beispiel #4
0
 public function win(Request $request)
 {
     try {
         $action = $request->get("action");
         if ($action == "") {
             $bid = Bid::findOrFail($request->get('id'));
             if ($bid->demand->stauts < 0) {
                 return Redirect::to('/demand/show/' . $bid->demand->id)->withErrors('当前状态下不能选择中标!');
             }
             if (Auth::user()->id != $bid->demand->user_id) {
                 return '没有权限';
                 return Redirect::to('/demand/show/' . $bid->demand->id)->withInput()->withErrors('没有权限!');
             }
             $bid->is_win = 1;
             $bid->demand->status = 1;
             $bid->save();
             $bid->demand->save();
             return '操作成功';
             return Redirect::to('/demand/show/' . $bid->demand->id)->withInput()->withErrors('操作成功!');
         }
         if ($action == "drop") {
             $deid = $request->get("deid");
             $demand = Demand::findOrFail($deid);
             $demand->status = "-3";
             //取消,放弃
             $demand->deposit = 0;
             //扣除保证金
             $demand->save();
             return '操作成功';
         }
     } catch (ModelNotFoundException $e) {
         return '删除';
         return Redirect::to('/')->withInput()->withErrors('竞购信息不存在或已被删除!');
     }
 }
Beispiel #5
0
 public function getBidding($nums = 10)
 {
     $demands = Demand::whereRaw(" status=0 and is_pay=1  and expire_time>now() ")->orderby("id", "desc")->take(8)->get();
     return $demands;
 }
Beispiel #6
0
 public function shoukuan($id)
 {
     try {
         $userid = Auth::user()->id;
         $demand = Demand::findOrFail($id);
         $bid = Bid::whereRaw(" demand_id=" . $demand->id . " and user_id=" . $userid . " and is_win=1")->get()->first();
         if (!$bid) {
             return redirect()->back()->withInput()->withErrors('没有找到相关的订单,收款失败。');
         }
         $demand->status = 5;
         $demand->save();
         //收款
         return redirect()->back()->withInput()->withErrors('收款成功。');
     } catch (ModelNotFoundException $e) {
         return Redirect::to('/')->withInput()->withErrors('竞购信息不存在或已被删除!');
     }
 }
Beispiel #7
0
 public function ajax_demand(Request $request)
 {
     header("Content-Type:text/html;charset=utf-8");
     if (!isset($_GET['id']) || empty($_GET['id'])) {
         echo $this->ecm_json_encode(false);
         return;
     }
     $id = $_GET['id'];
     $bids = isset($_GET['bid']) ? $_GET['bid'] : '';
     $key = isset($_GET['key']) ? $_GET['key'] : '';
     $demandmode = new Demand();
     $demands = $demandmode->getDemands($id, $bids, $key);
     //取得当前正在进行的竞购
     $data = array();
     foreach ($demands as $key => $val) {
         $onedata = array();
         $onedata['sn'] = $val['sn'];
         $onedata['id'] = $val['id'];
         $onedata['title'] = $val['title'];
         $onedata['price'] = $val['price'];
         $onedata['paytime'] = $val['paytime'];
         $onedata['thumb'] = $val['thumb'];
         $onedata['url'] = $val['url'];
         $onede = Demand::find($val['id']);
         $onedata['exptime'] = $onede->getexptime();
         //当前竞购的状态
         $onedata['bidnum'] = count($onede->bids);
         $data[] = $onedata;
     }
     echo $this->ecm_json_encode(array_values($data));
     return;
 }