Пример #1
0
 public function addBid(Request $request)
 {
     $this->validate($request, Bid::addRules());
     if (!isset(Auth::user()->id)) {
         return Redirect::to('/auth/login')->withErrors('你没有登录,请登录后再出价!');
     }
     $cert = Certification::where('user_id', '=', Auth::user()->id)->first();
     if ($cert == null) {
         return Redirect::to('auth/cert')->with('cert', $cert)->withErrors('你没有通过审核,请审核后再出价!');
     }
     if ($cert->is_identity == "1" && $cert->is_license == "1") {
         $user = User::where("id", "=", Auth::user()->id)->get()->first();
         if ($user->deposit == "0") {
             $demand = new Demand();
             $demand->title = "商家" . $user->username . "支付保证金 - ";
             $lastPrice = 2000;
             $showtitle = "支付保证金";
             $step = 3;
             //商家的保证金为3
             $purl = "/pay/payorder/bidder";
             return view('pay.demand', ['demand' => $demand, 'lastPrice' => $lastPrice, 'showtitle' => $showtitle, 'step' => $step, 'purl' => $purl])->withErrors('请缴纳保证金后出价!');
         }
     } else {
         return Redirect::to('auth/cert')->with('cert', $cert)->withErrors('你没有通过审核,请审核后再出价!');
     }
     //       return Redirect::to('/auth/cert')
     //          ->withErrors('删除成功!');
     if ($request->bid_id == 0) {
         $bid = new Bid();
         $bid->user_id = Auth::user()->id;
         $bid->demand_id = $request->get('demand_id');
         $helper = new Helper();
         $bid->sn = 'DE' . time() . $helper->mt_rand_str(4, '0123456789');
         //单号算法:DE+当前时间戳10位数字+4位随机数
         $bid->url = $request->get('url');
         $bid->price = $request->get('price');
         $bid->details = $request->get('details');
         $bid->area_id = 110000;
         $bid->save();
     } else {
         $bid = Bid::find($request->bid_id);
         $bid->price = $request->get('price');
         $bid->details = $request->get('details');
         $bid->url = $request->get('url');
         $bid->save();
     }
     return Redirect::to('demand/show/' . $bid->demand_id);
 }
Пример #2
0
 public function biddersaudit(Request $request)
 {
     header("Content-Type:text/html;charset=utf-8");
     $audit = $request->get('audit');
     $items = $request->get('itemid');
     $itemids = implode(",", $items);
     //echo "user_id in($itemids)";
     $res = Certification::whereRaw("user_id in({$itemids})")->update(array('is_identity' => 1, 'is_license' => 1));
     User::whereRaw("id in ({$itemids})")->update(array("valid" => 1));
     //->get();
     //var_dump($res);
     return Redirect::to('admin/bidders')->withErrors("成功审核通过" . $res . "供应商!");
 }
Пример #3
0
 public function certPost()
 {
     $data = array();
     $path = date("Ym", time()) . '/' . date("d", time()) . '/' . Auth::user()->id;
     $cert = Certification::where('user_id', '=', Auth::user()->id)->first();
     if ($cert == null) {
         $cert = new Certification();
         $cert->user_id = Auth::user()->id;
     }
     if ($file = Input::file('identity_card_front')) {
         $extension = $file->getClientOriginalExtension() ?: 'png';
         $safeName = str_random(10) . '.' . $extension;
         $file->move(base_path() . '/storage/certfiles/' . $path, $safeName);
         $cert->identity_card_front = $path . '/' . $safeName;
         $data['msg'] = "身份证正面照片上传成功";
     } else {
         if ($file = Input::file('identity_card_back')) {
             $extension = $file->getClientOriginalExtension() ?: 'png';
             $safeName = str_random(10) . '.' . $extension;
             $file->move(base_path() . '/storage/certfiles/' . $path, $safeName);
             $cert->identity_card_back = $path . '/' . $safeName;
             $data['msg'] = "身份证反面照片上传成功";
         } else {
             if ($file = Input::file('business_license')) {
                 $extension = $file->getClientOriginalExtension() ?: 'png';
                 $safeName = str_random(10) . '.' . $extension;
                 $file->move(base_path() . '/storage/certfiles/' . $path, $safeName);
                 $cert->business_license = $path . '/' . $safeName;
                 $data['msg'] = "营业执照上传成功";
             } else {
                 $data['error'] = "上传失败";
             }
         }
     }
     $cert->save();
     return json_encode($data);
     //'{"files":[{"url":"https://jquery-file-upload.appspot.com/image%2Fpng/888465575/lm00.png","thumbnailUrl":"https://jquery-file-upload.appspot.com/image%2Fpng/888465575/lm00.png.80x80.png","name":"lm00.png","type":"image/png","size":17903,"deleteUrl":"https://jquery-file-upload.appspot.com/image%2Fpng/888465575/lm00.png","deleteType":"DELETE"}]}';
 }