public function myDemandsByType($type = "all") { header("Content-Type:text/html;charset=utf-8"); if (!isset(Auth::user()->id)) { return Redirect::to('/auth/login')->withErrors('你没有登录!'); } //定义支付状态,0为未支付保证金,1为已支付保证金,2为支付货款, //状态0为未选标,1为选标,2已经付款,3为已经发货,4为收到货了 $condition = "user_id=" . Auth::user()->id; switch ($type) { case 'all': break; case 'deposit': $condition .= " and is_pay = 0 and status>=0"; break; case 'active': $condition .= " and is_pay=1 and status = 0 and expire_time>CURRENT_TIMESTAMP()"; break; case 'choose': $condition .= " and is_pay=1 and status = 0 and expire_time<CURRENT_TIMESTAMP()"; break; case 'pay': $condition .= " and is_pay=1 and status = 1 "; break; case 'delivery': $condition .= " and is_pay=2 and status in(2, 3) "; break; case 'getted': $condition .= " and is_pay=2 and status in( 4,5)"; break; case 'cancelled': $condition .= " and status in( -3,-4) "; break; } //$demands = Demand::whereRaw('user_id=? and status = 1',[Auth::user()->id])->get(); $demands = Demand::whereRaw($condition)->orderBy('id', 'desc')->get(); if ($this->ismobile()) { return view('demand.mobile.my', ['demands' => $demands, 'type' => $type]); } else { return view('demand.my', ['demands' => $demands, 'type' => $type]); } }
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; }