作者 郭文星

123

  1 +/nbproject/
  2 +/thinkphp/
  3 +/application/database.php
  4 +/vendor/
  5 +/runtime/*
  6 +/addons/*
  7 +/public/assets/libs/
  8 +/public/assets/addons/*
  9 +/public/uploads/*
  10 +.idea
  11 +composer.lock
  12 +*.log
  13 +*.css.map
  14 +!.gitkeep
  15 +.env
  16 +.svn
  17 +.vscode
  18 +node_modules
  19 +.user.ini
@@ -14,51 +14,141 @@ class Car extends Api @@ -14,51 +14,141 @@ 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(){  
21 - $res=Db::name("route")->field("id,name,start_address,end_address")->select();  
22 - return $this->success($res);  
23 - } 20 + public function selectroute(){
  21 + $res=Db::name("route")->field("id,name,start_address,end_address")->limit(2)->select();
  22 + return $this->success($res);
  23 + }
24 24
25 /** 25 /**
26 * 通过线路查询车辆 26 * 通过线路查询车辆
27 * @return void 27 * @return void
28 */ 28 */
29 - public function selectcarbyroute(){  
30 - $route_id = $this->request->param("route_id");  
31 - $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 - ->where("route_id",$route_id)  
34 - ->select();  
35 - return $this->success($res);  
36 - } 29 + public function selectcarbyroute(){
  30 + $route_id = $this->request->param("route_id");
  31 + $time = $this->request->param("time");
  32 + $res=Db::name("car")
  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")
  36 + ->where("route_id",$route_id)
  37 + ->group("start_time")
  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 + }
  52 + return $this->success($res);
  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);  
46 - } 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 + }
47 72
48 /** 73 /**
49 - *车主认证 74 + * 查询乘车人信息
50 * @return void 75 * @return void
51 */ 76 */
52 - public function driver_authentication(){ 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(){
53 $name=$this->request->param("name"); 86 $name=$this->request->param("name");
  87 + $IDcard=$this->request->param("IDcard");
54 $phone=$this->request->param("phone"); 88 $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"); 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);
63 } 98 }
64 -} 99 +
  100 + /**
  101 + * 修改乘车人信息
  102 + * @return void
  103 + */
  104 + public function updatepassenger(){
  105 + $name=$this->request->param("name");
  106 + $IDcard=$this->request->param("IDcard");
  107 + $phone=$this->request->param("phone");
  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();
  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 +
  154 +}