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); }
public function add(Request $request) { $this->validate($request, Demand::addRules()); $demand = new Demand(); $demand->user_id = Auth::user()->id; if ($request->get('esCate') != 0) { $demand->category_id = $request->get('esCate'); } else { if ($request->get('sCate') == 0) { $demand->category_id = $request->get('fCate'); } else { $demand->category_id = $request->get('sCate'); } } $helper = new Helper(); $demand->sn = 'DE' . time() . $helper->mt_rand_str(4, '0123456789'); //单号算法:DE+当前时间戳10位数字+4位随机数 $demand->url = $request->get('url'); $demand->title = $request->get('title'); $demand->price = $request->get('price'); $demand->ip = $_SERVER["REMOTE_ADDR"]; $cate2 = Category::find($demand->category_id); $demand->cat2 = $cate2->parent_id; $cate1 = Category::find($cate2->parent_id); $demand->cat1 = $cate1->parent_id; $demand->cat3 = $request->get("esCate"); $demand->bid = $request->get("esbrand"); //品牌的ID // $demand->expire_time = $request->get('expire_time');这个从支付时间算起 $demand->avltime = intval($request->get('avltime')); $demand->expire_time = date("Y-m-d H:i:s", strtotime("+ " . $demand->avltime . " hours")); //设置过期时间, $demand->addtime = date("Y-m-d H:i:s"); $demand->details = $request->get('details'); $demand->status = 0; //表示审核中 $helper = new Helper(); $demand->thumb = $helper->get_thumb($request->get('thumb')); $demand->save(); //return Redirect::to('demand/show/'.$demand->id); return Redirect::to('/pay/deposit/' . $demand->id); }
public function atest(Request $request) { /*if (Session::has('mobile_code')) { if (time() - Session::get('mobile_code_time') < 30) { return 999; } }*/ $apikey = "6152e179eb3e7018cc642ba82460303d"; //请用自己的apikey代替 $mobile = "13686355607"; $helper = new Helper(); $random_code = $helper->mt_rand_str(6, '0123456789'); $text = '【最惠购】您的验证码是' . $random_code . '。有效期为5分钟,请尽快验证'; echo send_sms($apikey, $text, $mobile); /* $mobile = "13686355607"; $yunpianSms = new YunPianSms(); $helper = new Helper(); $random_code = $helper->mt_rand_str(6, '0123456789'); $response = $yunpianSms->sendMsg($mobile, '【最惠购】您的验证码是' . $random_code . '。有效期为5分钟,请尽快验证'); //Log::error('Something is really going wrong.'); $result = json_decode(json_encode($response))->data->code; if ($result == 0) { Session::put('mobile_code', md5($random_code . $mobile)); Session::put('mobile_code_time', time()); } return $result; */ }