正在显示
2 个修改的文件
包含
126 行增加
和
17 行删除
| @@ -14,11 +14,11 @@ class Car extends Api | @@ -14,11 +14,11 @@ class Car extends Api | ||
| 14 | protected $noNeedRight = ['*']; | 14 | protected $noNeedRight = ['*']; |
| 15 | 15 | ||
| 16 | /** | 16 | /** |
| 17 | - * 查询所有路线 | 17 | + * 查询常用路线 |
| 18 | * @return void | 18 | * @return void |
| 19 | */ | 19 | */ |
| 20 | public function selectroute(){ | 20 | public function selectroute(){ |
| 21 | - $res=Db::name("route")->field("id,name,start_address,end_address")->select(); | 21 | + $res=Db::name("route")->field("id,name,start_address,end_address")->limit(2)->select(); |
| 22 | return $this->success($res); | 22 | return $this->success($res); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| @@ -28,37 +28,127 @@ class Car extends Api | @@ -28,37 +28,127 @@ class Car extends Api | ||
| 28 | */ | 28 | */ |
| 29 | public function selectcarbyroute(){ | 29 | public function selectcarbyroute(){ |
| 30 | $route_id = $this->request->param("route_id"); | 30 | $route_id = $this->request->param("route_id"); |
| 31 | + $time = $this->request->param("time"); | ||
| 31 | $res=Db::name("car") | 32 | $res=Db::name("car") |
| 32 | - ->field("id,car_model,license_plate,route_id,driver_id,route_id,seat,DATE_FORMAT(FROM_UNIXTIME(start_time),'%H:%i') as start_time") | 33 | + ->alias("a") |
| 34 | + ->join("route b","a.route_id=b.id") | ||
| 35 | + ->field("a.id,b.id as route_id,DATE_FORMAT(FROM_UNIXTIME(a.start_time), '%H:%i') AS start_time ,b.price") | ||
| 33 | ->where("route_id",$route_id) | 36 | ->where("route_id",$route_id) |
| 37 | + ->group("start_time") | ||
| 34 | ->select(); | 38 | ->select(); |
| 39 | + | ||
| 40 | + $start_time=strtotime(date("Y-m-d",$time)); | ||
| 41 | + $end_time=$start_time+86400; | ||
| 42 | + $newtime=time(); | ||
| 43 | + foreach ($res as $k=>$v){ | ||
| 44 | + $res[$k]['order']=Db::name("order") | ||
| 45 | + ->where("car_id",$res[$k]['id']) | ||
| 46 | + ->where("is_pay",1) | ||
| 47 | + ->where("reservation_time",">",$start_time) | ||
| 48 | + ->where("reservation_time","<",$end_time) | ||
| 49 | + ->count(); | ||
| 50 | + | ||
| 51 | + } | ||
| 35 | return $this->success($res); | 52 | return $this->success($res); |
| 36 | } | 53 | } |
| 37 | 54 | ||
| 38 | 55 | ||
| 39 | /** | 56 | /** |
| 40 | - *认证声明 | 57 | + * 创建订单 |
| 41 | * @return void | 58 | * @return void |
| 42 | */ | 59 | */ |
| 43 | - public function authentication_statement(){ | ||
| 44 | - $content = config("site.content");//微信小程序AppID | ||
| 45 | - return $this->success($content); | 60 | + public function createorder(){ |
| 61 | + $number=$this->request->param("number"); | ||
| 62 | + $phone = $this->request->param("phone"); | ||
| 63 | + $position = $this->request->param("position"); | ||
| 64 | + $lat = $this->request->param("lat"); | ||
| 65 | + $lng = $this->request->param("lng"); | ||
| 66 | + $remarks = $this->request->param("remarks"); | ||
| 67 | + $intended_driver_id = $this->request->param("intended_driver_id"); | ||
| 68 | + $route_id = $this->request->param("route_id"); | ||
| 69 | + $car_id = $this->request->param("car_id"); | ||
| 70 | + | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * 查询乘车人信息 | ||
| 75 | + * @return void | ||
| 76 | + */ | ||
| 77 | + public function passengerlist(){ | ||
| 78 | + $res=Db::name("passenger")->where("user_id",$this->auth->id)->select(); | ||
| 79 | + return $this->success("请求成功",$res); | ||
| 80 | + } | ||
| 81 | + /** | ||
| 82 | + * 增加乘车人信息 | ||
| 83 | + * @return void | ||
| 84 | + */ | ||
| 85 | + public function addpassenger(){ | ||
| 86 | + $name=$this->request->param("name"); | ||
| 87 | + $IDcard=$this->request->param("IDcard"); | ||
| 88 | + $phone=$this->request->param("phone"); | ||
| 89 | + $is_adult=$this->request->param("is_adult"); | ||
| 90 | + $res=Db::name("passenger")->insert([ | ||
| 91 | + "name"=>$name, | ||
| 92 | + "IDcard"=>$IDcard, | ||
| 93 | + "phone"=>$phone, | ||
| 94 | + "user_id"=>$this->auth->id, | ||
| 95 | + "is_adult"=>$is_adult | ||
| 96 | + ]); | ||
| 97 | + return $this->success("添加成功",$res); | ||
| 46 | } | 98 | } |
| 47 | 99 | ||
| 48 | /** | 100 | /** |
| 49 | - *车主认证 | 101 | + * 修改乘车人信息 |
| 50 | * @return void | 102 | * @return void |
| 51 | */ | 103 | */ |
| 52 | - public function driver_authentication(){ | 104 | + public function updatepassenger(){ |
| 53 | $name=$this->request->param("name"); | 105 | $name=$this->request->param("name"); |
| 106 | + $IDcard=$this->request->param("IDcard"); | ||
| 54 | $phone=$this->request->param("phone"); | 107 | $phone=$this->request->param("phone"); |
| 55 | - $is_work=$this->request->param("is_work"); | ||
| 56 | - $colour=$this->request->param("colour"); | ||
| 57 | - $car_model=$this->request->param("car_model"); | ||
| 58 | - $license_plate=$this->request->param("license_plate"); | ||
| 59 | - $route_id=$this->request->param("route_id"); | ||
| 60 | - $seat=$this->request->param("seat"); | ||
| 61 | - $driver_license_img=$this->request->param("driver_license_img"); | ||
| 62 | - $driving_license_img=$this->request->param("driving_license_img"); | 108 | + $is_adult=$this->request->param("is_adult"); |
| 109 | + $id=$this->request->param("id"); | ||
| 110 | + $res=Db::name("passenger")->where("id",$id)->update([ | ||
| 111 | + "name"=>$name, | ||
| 112 | + "IDcard"=>$IDcard, | ||
| 113 | + "phone"=>$phone, | ||
| 114 | + "is_adult"=>$is_adult | ||
| 115 | + ]); | ||
| 116 | + return $this->success("添加成功",$res); | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + /** | ||
| 120 | + * 查询订单 | ||
| 121 | + * @return void | ||
| 122 | + */ | ||
| 123 | + public function selectorder(){ | ||
| 124 | + $is_pay=$this->request->param("is_pay"); //是否支付:1=已支付,2=未支付,3=已退款,4=已取消 | ||
| 125 | + $res=Db::name("order") | ||
| 126 | + ->where("is_pay",$is_pay) | ||
| 127 | + ->where("user_id",$this->auth->id) | ||
| 128 | + ->select(); | ||
| 129 | + return $this->success("请求成功",$res); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + | ||
| 133 | + /** | ||
| 134 | + * | ||
| 135 | + * @return void | ||
| 136 | + */ | ||
| 137 | + public function selectbydriver(){ | ||
| 138 | + //$driver | ||
| 139 | + $res=Db::name("order") | ||
| 140 | + ->where("user_id",$this->auth->id) | ||
| 141 | + ->select(); | ||
| 63 | } | 142 | } |
| 143 | + | ||
| 144 | + /** | ||
| 145 | + *认证声明 | ||
| 146 | + * @return void | ||
| 147 | + */ | ||
| 148 | + public function authentication_statement(){ | ||
| 149 | + $content = config("site.content");//微信小程序AppID | ||
| 150 | + return $this->success($content); | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + | ||
| 64 | } | 154 | } |
-
请 注册 或 登录 后发表评论