Пример #1
0
 public function myBidsByType($type = 'all')
 {
     header("Content-Type:text/html;charset=utf-8");
     $bidcondition = " bids.user_id=" . Auth::user()->id;
     $demandcon = " 1=1 ";
     switch ($type) {
         case 'all':
             break;
         case 'active':
             $demandcon .= " and demands.status=0 and expire_time>CURRENT_TIMESTAMP()";
             break;
         case 'win':
             $bidcondition .= " and bids.is_win=1 ";
             $demandcon .= " and demands.status=1 ";
             break;
         case "notchoose":
             //已经结束但是没有选标的
             $demandcon .= " and demands.status=0  and  expire_time<CURRENT_TIMESTAMP()";
             break;
         case "notpayed":
             //未付尾款的
             $demandcon .= " and demands.status=1 and demands.is_pay=1 ";
             $bidcondition .= " and bids.is_win=1 ";
             break;
         case "notsend":
             $demandcon .= " and demands.status=2 and demands.is_pay=2";
             break;
         case "notreceive":
             $demandcon .= "  and demands.status in(3,4) and bids.is_win=1";
             break;
         case "lose":
             $bidcondition .= " and bids.is_win<>1 ";
             $demandcon .= " and demands.is_pay>0 ";
             break;
         case 'finish':
             $demandcon .= " and demands.status=5 and  bids.is_win=1";
             break;
     }
     $bids = Bid::leftJoin('demands', 'bids.demand_id', '=', 'demands.id')->select("bids.*", "demands.price as dprice")->whereRaw($bidcondition)->whereRaw($demandcon)->orderBy('demands.id', 'desc')->get();
     //        print_r($bids);exit();
     $data = array('bids' => $bids, 'type' => $type);
     if ($this->ismobile()) {
         return view('bid.mobile.my')->with($data);
     } else {
         return view('bid.my')->with($data);
     }
 }