作者 郭文星

123

@@ -20,8 +20,9 @@ class Car extends Base @@ -20,8 +20,9 @@ class Car extends Base
20 * 查询常用路线 20 * 查询常用路线
21 * @return void 21 * @return void
22 */ 22 */
23 - public function selectroute(){  
24 - $res=Db::name("route")->field("id,name,price,start_address,end_address")->limit(2)->select(); 23 + public function selectroute()
  24 + {
  25 + $res = Db::name("route")->field("id,name,price,start_address,end_address")->limit(2)->select();
25 return $this->success($res); 26 return $this->success($res);
26 } 27 }
27 28
@@ -29,55 +30,56 @@ class Car extends Base @@ -29,55 +30,56 @@ class Car extends Base
29 * 通过线路查询车辆 30 * 通过线路查询车辆
30 * @return void 31 * @return void
31 */ 32 */
32 - public function selectcarbyroute(){ 33 + public function selectcarbyroute()
  34 + {
33 $route_id = $this->request->param("route_id"); 35 $route_id = $this->request->param("route_id");
34 $time = $this->request->param("time"); 36 $time = $this->request->param("time");
35 - $res=Db::name("car") 37 + $res = Db::name("car")
36 ->alias("a") 38 ->alias("a")
37 - ->join("route b","a.route_id=b.id")  
38 - ->join("driver c","a.driver_id=c.id") 39 + ->join("route b", "a.route_id=b.id")
  40 + ->join("driver c", "a.driver_id=c.id")
39 ->field("a.id,b.id as route_id,c.id as driver_id,DATE_FORMAT(FROM_UNIXTIME(a.reservation_time), '%H:%i') AS reservation_time ,DATE_FORMAT(FROM_UNIXTIME(a.start_time), '%H:%i') AS start_time ,b.price,a.seat,a.license_plate") 41 ->field("a.id,b.id as route_id,c.id as driver_id,DATE_FORMAT(FROM_UNIXTIME(a.reservation_time), '%H:%i') AS reservation_time ,DATE_FORMAT(FROM_UNIXTIME(a.start_time), '%H:%i') AS start_time ,b.price,a.seat,a.license_plate")
40 - ->where("route_id",$route_id)  
41 - ->where("scheduling_type",1) 42 + ->where("route_id", $route_id)
  43 + ->where("scheduling_type", 1)
42 ->group("start_time") 44 ->group("start_time")
43 ->select(); 45 ->select();
44 46
45 // 查询临时线路车次 47 // 查询临时线路车次
46 - $statr_time=strtotime(date("Y-m-d",time()));  
47 - $end_time=$statr_time+86400;  
48 - $temporary_route=Db::name("temporary_route")  
49 - ->where("create_time",">",$statr_time)  
50 - ->where("create_time","<",$end_time)  
51 - ->where("route_id",$route_id) 48 + $statr_time = strtotime(date("Y-m-d", time()));
  49 + $end_time = $statr_time + 86400;
  50 + $temporary_route = Db::name("temporary_route")
  51 + ->where("create_time", ">", $statr_time)
  52 + ->where("create_time", "<", $end_time)
  53 + ->where("route_id", $route_id)
52 ->select(); 54 ->select();
53 55
54 - $data=[];  
55 - foreach ($temporary_route as $k=>$v){  
56 - $data[]=Db::name("car") 56 + $data = [];
  57 + foreach ($temporary_route as $k => $v) {
  58 + $data[] = Db::name("car")
57 ->alias("a") 59 ->alias("a")
58 - ->join("route b","a.route_id=b.id")  
59 - ->join("driver c","a.driver_id=c.id") 60 + ->join("route b", "a.route_id=b.id")
  61 + ->join("driver c", "a.driver_id=c.id")
60 ->field("a.id,b.id as route_id,c.id as driver_id,DATE_FORMAT(FROM_UNIXTIME(a.reservation_time), '%H:%i') AS reservation_time ,DATE_FORMAT(FROM_UNIXTIME(a.start_time), '%H:%i') AS start_time ,b.price,a.seat,a.license_plate") 62 ->field("a.id,b.id as route_id,c.id as driver_id,DATE_FORMAT(FROM_UNIXTIME(a.reservation_time), '%H:%i') AS reservation_time ,DATE_FORMAT(FROM_UNIXTIME(a.start_time), '%H:%i') AS start_time ,b.price,a.seat,a.license_plate")
61 - ->where("route_id",$route_id)  
62 - ->where("a.id",$temporary_route[$k]['car_id']) 63 + ->where("route_id", $route_id)
  64 + ->where("a.id", $temporary_route[$k]['car_id'])
63 ->group("start_time") 65 ->group("start_time")
64 ->find(); 66 ->find();
65 } 67 }
66 - $res=array_merge($data,$res);  
67 -  
68 - $start_time=strtotime(date("Y-m-d",$time));  
69 - $end_time=$start_time+86400;  
70 - $newtime=time();  
71 - foreach ($res as $k=>$v){  
72 - $res[$k]['order']=Db::name("order")  
73 - ->where("car_id",$res[$k]['id'])  
74 - ->where("is_pay",1)  
75 - ->where("reservation_time",">",$start_time)  
76 - ->where("reservation_time","<",$end_time) 68 + $res = array_merge($data, $res);
  69 +
  70 + $start_time = strtotime(date("Y-m-d", $time));
  71 + $end_time = $start_time + 86400;
  72 + $newtime = time();
  73 + foreach ($res as $k => $v) {
  74 + $res[$k]['order'] = Db::name("order")
  75 + ->where("car_id", $res[$k]['id'])
  76 + ->where("is_pay", 1)
  77 + ->where("reservation_time", ">", $start_time)
  78 + ->where("reservation_time", "<", $end_time)
77 ->count(); 79 ->count();
78 80
79 } 81 }
80 - return $this->success("请求成功",$res); 82 + return $this->success("请求成功", $res);
81 } 83 }
82 84
83 85
@@ -85,8 +87,9 @@ class Car extends Base @@ -85,8 +87,9 @@ class Car extends Base
85 * 创建订单 87 * 创建订单
86 * @return void 88 * @return void
87 */ 89 */
88 - public function createorder(){  
89 - $number=$this->request->param("number");//乘车人数 90 + public function createorder()
  91 + {
  92 + $number = $this->request->param("number");//乘车人数
90 $phone = $this->request->param("phone");//联系手机号码 93 $phone = $this->request->param("phone");//联系手机号码
91 $user_name = $this->request->param("user_name");//联系人 94 $user_name = $this->request->param("user_name");//联系人
92 $position = $this->request->param("position");//上车地址 95 $position = $this->request->param("position");//上车地址
@@ -98,79 +101,79 @@ class Car extends Base @@ -98,79 +101,79 @@ class Car extends Base
98 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 101 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机
99 $route_id = $this->request->param("route_id");//线路 102 $route_id = $this->request->param("route_id");//线路
100 $car_id = $this->request->param("car_id");//车辆 103 $car_id = $this->request->param("car_id");//车辆
101 - if($number<=0){ 104 + if ($number <= 0) {
102 $this->error("人数错误"); 105 $this->error("人数错误");
103 } 106 }
104 //查询线路 107 //查询线路
105 - $route=Db::name("route")->where("id",$route_id)->find(); 108 + $route = Db::name("route")->where("id", $route_id)->find();
106 //查询车辆 109 //查询车辆
107 - $car=Db::name("car")->where("id",$car_id)->find(); 110 + $car = Db::name("car")->where("id", $car_id)->find();
108 //查询司机 111 //查询司机
109 - $driver=Db::name("driver")->where("id",$car['driver_id'])->find(); 112 + $driver = Db::name("driver")->where("id", $car['driver_id'])->find();
110 //判断总表 113 //判断总表
111 - $time=strtotime(date("Y-m-d",time()));  
112 -  
113 - $order_review=Db::name("order_review")  
114 - ->where("car_id",$car_id)  
115 - ->where("car_id",$car_id)  
116 - ->where("route_id",$route_id)  
117 - ->where("driver_id",$driver['id'])  
118 - ->where("createtime",">",$time) 114 + $time = strtotime(date("Y-m-d", time()));
  115 +
  116 + $order_review = Db::name("order_review")
  117 + ->where("car_id", $car_id)
  118 + ->where("car_id", $car_id)
  119 + ->where("route_id", $route_id)
  120 + ->where("driver_id", $driver['id'])
  121 + ->where("createtime", ">", $time)
119 ->find(); 122 ->find();
120 123
121 - if(!$order_review){  
122 - $order_review_id=Db::name("order_review") 124 + if (!$order_review) {
  125 + $order_review_id = Db::name("order_review")
123 ->insertGetId([ 126 ->insertGetId([
124 - "car_id"=>$car_id,  
125 - "route_id"=>$route_id,  
126 - "driver_id"=>$driver['id'],  
127 - "order_status"=>1,  
128 - "createtime"=>time() 127 + "car_id" => $car_id,
  128 + "route_id" => $route_id,
  129 + "driver_id" => $driver['id'],
  130 + "order_status" => 1,
  131 + "createtime" => time()
129 ]); 132 ]);
130 - }else{  
131 - $order_review_id=$order_review['id']; 133 + } else {
  134 + $order_review_id = $order_review['id'];
132 } 135 }
133 //计算价格 136 //计算价格
134 - $seatres=Db::name("seat")->where("id",$car['seat_id'])->find(); 137 + $seatres = Db::name("seat")->where("id", $car['seat_id'])->find();
135 $seat_no_array = explode(",", $seat_no); 138 $seat_no_array = explode(",", $seat_no);
136 - $seat=json_decode($seatres['seat'],true);  
137 - $newseat=[];  
138 - foreach ($seat as $k=>$v){  
139 - if( in_array($seat[$k]['seat_no'],$seat_no_array)){  
140 - $newseat[$k]=$seat[$k];  
141 - }  
142 - }  
143 - $price=0;  
144 - $specificaddress=Db::name("specificaddress")->where("id",$specificaddress_id)->find();  
145 - if($specificaddress){  
146 - $price=bcmul($number,$specificaddress['price'],2);  
147 - }else{ 139 + $seat = json_decode($seatres['seat'], true);
  140 + $newseat = [];
  141 + foreach ($seat as $k => $v) {
  142 + if (in_array($seat[$k]['seat_no'], $seat_no_array)) {
  143 + $newseat[$k] = $seat[$k];
  144 + }
  145 + }
  146 + $price = 0;
  147 + $specificaddress = Db::name("specificaddress")->where("id", $specificaddress_id)->find();
  148 + if ($specificaddress) {
  149 + $price = bcmul($number, $specificaddress['price'], 2);
  150 + } else {
148 $this->error("价格计算错误"); 151 $this->error("价格计算错误");
149 } 152 }
150 - $data=[  
151 - "order_no"=>getOrderSn(),  
152 - "price"=>$price,  
153 - "is_pay"=>"2",//未支付  
154 - "car_id"=>$car_id,  
155 - "order_review_id"=>$order_review_id,  
156 - "route_id"=>$route_id,  
157 - "specificaddress_id"=>$specificaddress_id,  
158 - "user_id"=>$this->auth->id,  
159 - "phone"=>$phone,  
160 - "user_name"=>$user_name,  
161 - "driver_id"=>$driver['id'],  
162 - "driver_name"=>$driver['name'],  
163 - "create_time"=>time(),  
164 - "reservation_time"=>time(),  
165 - "position"=>$position,  
166 - "lat"=>$lat,  
167 - "lng"=>$lng,  
168 - "number"=>$number,  
169 - "remarks"=>$remarks,  
170 - "seat_no"=>$seat_no,  
171 - "intended_driver_id"=>$intended_driver_id, 153 + $data = [
  154 + "order_no" => getOrderSn(),
  155 + "price" => $price,
  156 + "is_pay" => "2",//未支付
  157 + "car_id" => $car_id,
  158 + "order_review_id" => $order_review_id,
  159 + "route_id" => $route_id,
  160 + "specificaddress_id" => $specificaddress_id,
  161 + "user_id" => $this->auth->id,
  162 + "phone" => $phone,
  163 + "user_name" => $user_name,
  164 + "driver_id" => $driver['id'],
  165 + "driver_name" => $driver['name'],
  166 + "create_time" => time(),
  167 + "reservation_time" => time(),
  168 + "position" => $position,
  169 + "lat" => $lat,
  170 + "lng" => $lng,
  171 + "number" => $number,
  172 + "remarks" => $remarks,
  173 + "seat_no" => $seat_no,
  174 + "intended_driver_id" => $intended_driver_id,
172 ]; 175 ];
173 - $res=Db::name("order")->insertGetId($data); 176 + $res = Db::name("order")->insertGetId($data);
174 $userinfo = Db::name('user') 177 $userinfo = Db::name('user')
175 ->where(['id' => $this->auth->id]) 178 ->where(['id' => $this->auth->id])
176 ->field('id,wx_xcx_openid') 179 ->field('id,wx_xcx_openid')
@@ -185,7 +188,7 @@ class Car extends Base @@ -185,7 +188,7 @@ class Car extends Base
185 'openid' => $userinfo['wx_xcx_openid'], 188 'openid' => $userinfo['wx_xcx_openid'],
186 ]; 189 ];
187 $f = \addons\epay\library\Service::submitOrder($params); 190 $f = \addons\epay\library\Service::submitOrder($params);
188 - $this->success("请求成功",$f); 191 + $this->success("请求成功", $f);
189 192
190 193
191 } 194 }
@@ -195,58 +198,64 @@ class Car extends Base @@ -195,58 +198,64 @@ class Car extends Base
195 * 查询乘车人信息 198 * 查询乘车人信息
196 * @return void 199 * @return void
197 */ 200 */
198 - public function passengerlist(){  
199 - $res=Db::name("passenger")->where("user_id",$this->auth->id)->select();  
200 - return $this->success("请求成功",$res); 201 + public function passengerlist()
  202 + {
  203 + $res = Db::name("passenger")->where("user_id", $this->auth->id)->select();
  204 + return $this->success("请求成功", $res);
201 } 205 }
  206 +
202 /** 207 /**
203 * 增加乘车人信息 208 * 增加乘车人信息
204 * @return void 209 * @return void
205 */ 210 */
206 - public function addpassenger(){  
207 - $name=$this->request->param("name");  
208 - $IDcard=$this->request->param("IDcard");  
209 - $phone=$this->request->param("phone");  
210 - $is_adult=$this->request->param("is_adult");  
211 - $res=Db::name("passenger")->insert([  
212 - "name"=>$name,  
213 - "IDcard"=>$IDcard,  
214 - "phone"=>$phone,  
215 - "user_id"=>$this->auth->id,  
216 - "is_adult"=>$is_adult 211 + public function addpassenger()
  212 + {
  213 + $name = $this->request->param("name");
  214 + $IDcard = $this->request->param("IDcard");
  215 + $phone = $this->request->param("phone");
  216 + $is_adult = $this->request->param("is_adult");
  217 + $res = Db::name("passenger")->insert([
  218 + "name" => $name,
  219 + "IDcard" => $IDcard,
  220 + "phone" => $phone,
  221 + "user_id" => $this->auth->id,
  222 + "is_adult" => $is_adult
217 ]); 223 ]);
218 - return $this->success("添加成功",$res); 224 + return $this->success("添加成功", $res);
219 } 225 }
220 226
221 /** 227 /**
222 * 修改乘车人信息 228 * 修改乘车人信息
223 * @return void 229 * @return void
224 */ 230 */
225 - public function updatepassenger(){  
226 - $name=$this->request->param("name");  
227 - $IDcard=$this->request->param("IDcard");  
228 - $phone=$this->request->param("phone");  
229 - $is_adult=$this->request->param("is_adult");  
230 - $id=$this->request->param("id");  
231 - $res=Db::name("passenger")->where("id",$id)->update([  
232 - "name"=>$name,  
233 - "IDcard"=>$IDcard,  
234 - "phone"=>$phone,  
235 - "is_adult"=>$is_adult 231 + public function updatepassenger()
  232 + {
  233 + $name = $this->request->param("name");
  234 + $IDcard = $this->request->param("IDcard");
  235 + $phone = $this->request->param("phone");
  236 + $is_adult = $this->request->param("is_adult");
  237 + $id = $this->request->param("id");
  238 + $res = Db::name("passenger")->where("id", $id)->update([
  239 + "name" => $name,
  240 + "IDcard" => $IDcard,
  241 + "phone" => $phone,
  242 + "is_adult" => $is_adult
236 ]); 243 ]);
237 - return $this->success("修改成功",$res); 244 + return $this->success("修改成功", $res);
238 } 245 }
  246 +
239 /** 247 /**
240 * 删除乘车人信息 248 * 删除乘车人信息
241 * @return void 249 * @return void
242 */ 250 */
243 - public function deletepassenger(){  
244 - $id=$this->request->param("id");  
245 - $res=Db::name("passenger")->where("id",$id)->delete();  
246 - if($res){  
247 - return $this->success("删除成功",$res); 251 + public function deletepassenger()
  252 + {
  253 + $id = $this->request->param("id");
  254 + $res = Db::name("passenger")->where("id", $id)->delete();
  255 + if ($res) {
  256 + return $this->success("删除成功", $res);
248 257
249 - }else{ 258 + } else {
250 return $this->error("删除失败"); 259 return $this->error("删除失败");
251 } 260 }
252 } 261 }
@@ -255,30 +264,31 @@ class Car extends Base @@ -255,30 +264,31 @@ class Car extends Base
255 * 查询订单 264 * 查询订单
256 * @return void 265 * @return void
257 */ 266 */
258 - public function selectorder(){  
259 - $is_pay=$this->request->param("is_pay"); //是否支付:1=已支付,2=未支付,3=已退款,4=已取消  
260 - $page=$this->request->param("page");  
261 - $total=$this->request->param("total"); 267 + public function selectorder()
  268 + {
  269 + $is_pay = $this->request->param("is_pay"); //是否支付:1=已支付,2=未支付,3=已退款,4=已取消
  270 + $page = $this->request->param("page");
  271 + $total = $this->request->param("total");
262 $w['user_id'] = $this->auth->id; 272 $w['user_id'] = $this->auth->id;
263 - if ($is_pay!=0){ 273 + if ($is_pay != 0) {
264 $w['is_pay'] = $is_pay; 274 $w['is_pay'] = $is_pay;
265 } 275 }
266 - $res=Db::name("order") 276 + $res = Db::name("order")
267 ->alias("a") 277 ->alias("a")
268 - ->join("route b","a.route_id=b.id") 278 + ->join("route b", "a.route_id=b.id")
269 ->field("a.*,b.start_address,b.end_address") 279 ->field("a.*,b.start_address,b.end_address")
270 ->where($w) 280 ->where($w)
271 - ->page($page,$total) 281 + ->page($page, $total)
272 ->order("id desc") 282 ->order("id desc")
273 ->select(); 283 ->select();
274 - $amount=Db::name("order") 284 + $amount = Db::name("order")
275 ->alias("a") 285 ->alias("a")
276 - ->join("route b","a.route_id=b.id") 286 + ->join("route b", "a.route_id=b.id")
277 ->field("a.*,b.start_address,b.end_address") 287 ->field("a.*,b.start_address,b.end_address")
278 ->where($w) 288 ->where($w)
279 ->count(); 289 ->count();
280 - $data=["data"=>$res,"amount"=>$amount];  
281 - return $this->success("请求成功",$data); 290 + $data = ["data" => $res, "amount" => $amount];
  291 + return $this->success("请求成功", $data);
282 } 292 }
283 293
284 294
@@ -286,75 +296,78 @@ class Car extends Base @@ -286,75 +296,78 @@ class Car extends Base
286 * 切换司机 296 * 切换司机
287 * @return void 297 * @return void
288 */ 298 */
289 - public function switching_driver(){  
290 - $res=Db::name("driver")->where("user_id",$this->auth->id)->find();  
291 - $car=Db::name("car")->where("driver_id",$res['id'])->find();  
292 - if($car){ 299 + public function switching_driver()
  300 + {
  301 + $res = Db::name("driver")->where("user_id", $this->auth->id)->find();
  302 + $car = Db::name("car")->where("driver_id", $res['id'])->find();
  303 + if ($car) {
293 //本月收入 304 //本月收入
294 - $revenue_mon=sprintf('%.2f',Db::name("order") 305 + $revenue_mon = sprintf('%.2f', Db::name("order")
295 ->whereTime('create_time', 'month') 306 ->whereTime('create_time', 'month')
296 - ->where("is_pay",1)  
297 - ->where("driver_id",$res['id']) 307 + ->where("is_pay", 1)
  308 + ->where("driver_id", $res['id'])
298 ->sum("price")); 309 ->sum("price"));
299 310
300 //累计收入 311 //累计收入
301 - $all_order=sprintf('%.2f',Db::name("order")  
302 - ->where("is_pay",1)  
303 - ->where("driver_id",$res['id']) 312 + $all_order = sprintf('%.2f', Db::name("order")
  313 + ->where("is_pay", 1)
  314 + ->where("driver_id", $res['id'])
304 ->sum("price")); 315 ->sum("price"));
305 316
306 //累计订单 317 //累计订单
307 - $all_orderquantity=sprintf('%.2f',Db::name("order")  
308 - ->where("is_pay",1)  
309 - ->where("driver_id",$res['id']) 318 + $all_orderquantity = sprintf('%.2f', Db::name("order")
  319 + ->where("is_pay", 1)
  320 + ->where("driver_id", $res['id'])
310 ->count()); 321 ->count());
311 322
312 //本月订单 323 //本月订单
313 - $order_mon=Db::name("order")  
314 - ->where("is_pay",1) 324 + $order_mon = Db::name("order")
  325 + ->where("is_pay", 1)
315 ->whereTime('create_time', 'month') 326 ->whereTime('create_time', 'month')
316 - ->where("driver_id",$res['id']) 327 + ->where("driver_id", $res['id'])
317 ->count(); 328 ->count();
318 //累计接送 329 //累计接送
319 - $all_passenger=sprintf('%.2f',Db::name("order")  
320 - ->where("is_pay",1)  
321 - ->where("driver_id",$res['id']) 330 + $all_passenger = sprintf('%.2f', Db::name("order")
  331 + ->where("is_pay", 1)
  332 + ->where("driver_id", $res['id'])
322 ->sum("number")); 333 ->sum("number"));
323 //本月接送 334 //本月接送
324 - $month_passenger=sprintf('%.2f',Db::name("order")  
325 - ->where("is_pay",1) 335 + $month_passenger = sprintf('%.2f', Db::name("order")
  336 + ->where("is_pay", 1)
326 ->whereTime('create_time', 'month') 337 ->whereTime('create_time', 'month')
327 - ->where("driver_id",$res['id']) 338 + ->where("driver_id", $res['id'])
328 ->sum("number")); 339 ->sum("number"));
329 340
330 - $res['license_plate']=$car['license_plate'];  
331 - $res['car_model']=$car['car_model'];  
332 - $res['revenue_mon']=$revenue_mon;  
333 - $res['all_order']=$all_order;  
334 - $res['order_mon']=$order_mon;  
335 - $res['all_orderquantity']=$all_orderquantity;  
336 - $res['all_passenger']=$all_passenger;  
337 - $res['month_passenger']=$month_passenger;  
338 - }else{ 341 + $res['license_plate'] = $car['license_plate'];
  342 + $res['car_model'] = $car['car_model'];
  343 + $res['revenue_mon'] = $revenue_mon;
  344 + $res['all_order'] = $all_order;
  345 + $res['order_mon'] = $order_mon;
  346 + $res['all_orderquantity'] = $all_orderquantity;
  347 + $res['all_passenger'] = $all_passenger;
  348 + $res['month_passenger'] = $month_passenger;
  349 + } else {
339 return $this->error("请求失败"); 350 return $this->error("请求失败");
340 } 351 }
341 352
342 - if($res){  
343 - return $this->success("请求成功",$res);  
344 - }else{ 353 + if ($res) {
  354 + return $this->success("请求成功", $res);
  355 + } else {
345 return $this->error("请求失败"); 356 return $this->error("请求失败");
346 } 357 }
347 } 358 }
  359 +
348 /** 360 /**
349 * 切换司机 361 * 切换司机
350 * @return void 362 * @return void
351 */ 363 */
352 - public function switching_user(){  
353 - $res=Db::name("user")->where("id",$this->auth->id)->find();  
354 - if($res){  
355 - $res['avatar']=full_image($res['avatar']);  
356 - return $this->success("请求成功",$res);  
357 - }else{ 364 + public function switching_user()
  365 + {
  366 + $res = Db::name("user")->where("id", $this->auth->id)->find();
  367 + if ($res) {
  368 + $res['avatar'] = full_image($res['avatar']);
  369 + return $this->success("请求成功", $res);
  370 + } else {
358 return $this->error("请求失败"); 371 return $this->error("请求失败");
359 } 372 }
360 } 373 }
@@ -366,14 +379,15 @@ class Car extends Base @@ -366,14 +379,15 @@ class Car extends Base
366 * @throws \think\db\exception\ModelNotFoundException 379 * @throws \think\db\exception\ModelNotFoundException
367 * @throws \think\exception\DbException 380 * @throws \think\exception\DbException
368 */ 381 */
369 - public function selectroutebyname(){  
370 - $start_address=$this->request->param("start_address");  
371 - $end_address=$this->request->param("end_address");  
372 - $route=Db::name("route")  
373 - ->where("end_address",$end_address)  
374 - ->where("start_address",$start_address) 382 + public function selectroutebyname()
  383 + {
  384 + $start_address = $this->request->param("start_address");
  385 + $end_address = $this->request->param("end_address");
  386 + $route = Db::name("route")
  387 + ->where("end_address", $end_address)
  388 + ->where("start_address", $start_address)
375 ->find(); 389 ->find();
376 - return $this->success("请求成功",$route); 390 + return $this->success("请求成功", $route);
377 } 391 }
378 392
379 /** 393 /**
@@ -383,41 +397,45 @@ class Car extends Base @@ -383,41 +397,45 @@ class Car extends Base
383 * @throws \think\db\exception\ModelNotFoundException 397 * @throws \think\db\exception\ModelNotFoundException
384 * @throws \think\exception\DbException 398 * @throws \think\exception\DbException
385 */ 399 */
386 - public function selectintercityroutebyname(){  
387 - $start_address=$this->request->param("start_address");  
388 - $end_address=$this->request->param("end_address");  
389 - $route=Db::name("route")  
390 - ->where("end_address",$end_address)  
391 - ->where("start_address",$start_address) 400 + public function selectintercityroutebyname()
  401 + {
  402 + $start_address = $this->request->param("start_address");
  403 + $end_address = $this->request->param("end_address");
  404 + $route = Db::name("route")
  405 + ->where("end_address", $end_address)
  406 + ->where("start_address", $start_address)
392 ->find(); 407 ->find();
393 - return $this->success("请求成功",$route); 408 + return $this->success("请求成功", $route);
394 } 409 }
395 410
396 /** 411 /**
397 * 开始接送 412 * 开始接送
398 * @return void 413 * @return void
399 */ 414 */
400 - public function connect_order(){  
401 - $id=$this->request->param("id");  
402 - $order=Db::name("order_review")->where("id",$id)->find();  
403 - if($order['order_status']==1){  
404 - $order=Db::name("order")->where("id",$id)->update(['order_status'=>2]); 415 + public function connect_order()
  416 + {
  417 + $id = $this->request->param("id");
  418 + $order = Db::name("order_review")->where("id", $id)->find();
  419 + if ($order['order_status'] == 1) {
  420 + $order = Db::name("order")->where("id", $id)->update(['order_status' => 2]);
405 return $this->success("请求成功"); 421 return $this->success("请求成功");
406 - }else{ 422 + } else {
407 return $this->error("请求失败"); 423 return $this->error("请求失败");
408 } 424 }
409 } 425 }
  426 +
410 /** 427 /**
411 * 订单进行 428 * 订单进行
412 * @return void 429 * @return void
413 */ 430 */
414 - public function have_order(){  
415 - $id=$this->request->param("id");  
416 - $order=Db::name("order_review")->where("id",$id)->find();  
417 - if($order['order_status']==2){  
418 - $order=Db::name("order")->where("id",$id)->update(['order_status'=>3]); 431 + public function have_order()
  432 + {
  433 + $id = $this->request->param("id");
  434 + $order = Db::name("order_review")->where("id", $id)->find();
  435 + if ($order['order_status'] == 2) {
  436 + $order = Db::name("order")->where("id", $id)->update(['order_status' => 3]);
419 return $this->success("请求成功"); 437 return $this->success("请求成功");
420 - }else{ 438 + } else {
421 return $this->error("请求失败"); 439 return $this->error("请求失败");
422 } 440 }
423 } 441 }
@@ -426,30 +444,31 @@ class Car extends Base @@ -426,30 +444,31 @@ class Car extends Base
426 * 订单完成 444 * 订单完成
427 * @return void 445 * @return void
428 */ 446 */
429 - public function complete_order(){  
430 - $id=$this->request->param("id");  
431 - $order=Db::name("order")->where("id",$id)->find();  
432 - if($order['order_status']==3){  
433 - $order=Db::name("order")->where("id",$id)->update(['order_status'=>4]);  
434 - if($order){ 447 + public function complete_order()
  448 + {
  449 + $id = $this->request->param("id");
  450 + $order = Db::name("order")->where("id", $id)->find();
  451 + if ($order['order_status'] == 3) {
  452 + $order = Db::name("order")->where("id", $id)->update(['order_status' => 4]);
  453 + if ($order) {
435 //给司机加余额 454 //给司机加余额
436 - $car=Db::name("car")->where("id",$order['car_id'])->find();  
437 - $user=Db::name("user")->where("id",$car['user_id'])->find();  
438 - $money=bcadd($user['money'],$order['price'],2);  
439 - $addmoney=Db::name("user")->where("id",$id)->update(['money'=>$money]);  
440 - $data=[  
441 - "money"=>$money,  
442 - "type"=>2,  
443 - "create_time"=>time(),  
444 - "before"=>$user['money'],  
445 - "memo"=>$order['id']."订单完成",  
446 - "after"=>$user['money'], 455 + $car = Db::name("car")->where("id", $order['car_id'])->find();
  456 + $user = Db::name("user")->where("id", $car['user_id'])->find();
  457 + $money = bcadd($user['money'], $order['price'], 2);
  458 + $addmoney = Db::name("user")->where("id", $id)->update(['money' => $money]);
  459 + $data = [
  460 + "money" => $money,
  461 + "type" => 2,
  462 + "create_time" => time(),
  463 + "before" => $user['money'],
  464 + "memo" => $order['id'] . "订单完成",
  465 + "after" => $user['money'],
447 466
448 ]; 467 ];
449 - $addmoney_log=Db::name("user_money_log")->insert($data); 468 + $addmoney_log = Db::name("user_money_log")->insert($data);
450 } 469 }
451 return $this->success("请求成功"); 470 return $this->success("请求成功");
452 - }else{ 471 + } else {
453 return $this->error("请求失败"); 472 return $this->error("请求失败");
454 } 473 }
455 } 474 }
@@ -458,74 +477,77 @@ class Car extends Base @@ -458,74 +477,77 @@ class Car extends Base
458 * 查询订单总览 477 * 查询订单总览
459 * @return void 478 * @return void
460 */ 479 */
461 - public function selectorderreview(){  
462 - $order_status=$this->request->param("order_status"); //接送状态:1=未开始,2=接送中,3=进行中,4=已完成  
463 - $page=$this->request->param("page");  
464 - $total=$this->request->param("total");  
465 - $driver=Db::name("driver")->where("user_id",$this->auth->id)->find(); 480 + public function selectorderreview()
  481 + {
  482 + $order_status = $this->request->param("order_status"); //接送状态:1=未开始,2=接送中,3=进行中,4=已完成
  483 + $page = $this->request->param("page");
  484 + $total = $this->request->param("total");
  485 + $driver = Db::name("driver")->where("user_id", $this->auth->id)->find();
466 $w["a.driver_id"] = $driver["id"]; 486 $w["a.driver_id"] = $driver["id"];
467 - if ($order_status!=0){ 487 + if ($order_status != 0) {
468 $w["a.order_status"] = $order_status; 488 $w["a.order_status"] = $order_status;
469 } 489 }
470 - $res=Db::name("order_review") 490 + $res = Db::name("order_review")
471 ->alias("a") 491 ->alias("a")
472 - ->join("route b","a.route_id=b.id") 492 + ->join("route b", "a.route_id=b.id")
473 ->field("a.*,b.start_address,b.end_address") 493 ->field("a.*,b.start_address,b.end_address")
474 ->where($w) 494 ->where($w)
475 - ->page($page,$total) 495 + ->page($page, $total)
476 ->select(); 496 ->select();
477 - foreach ($res as $k=>$v){  
478 - $res[$k]['price']=sprintf('%.2f',Db::name("order")->sum("price"));  
479 - $res[$k]['number']=Db::name("order")->sum("number"); 497 + foreach ($res as $k => $v) {
  498 + $res[$k]['price'] = sprintf('%.2f', Db::name("order")->sum("price"));
  499 + $res[$k]['number'] = Db::name("order")->sum("number");
480 } 500 }
481 - $amount=Db::name("order_review") 501 + $amount = Db::name("order_review")
482 ->alias("a") 502 ->alias("a")
483 - ->join("route b","a.route_id=b.id") 503 + ->join("route b", "a.route_id=b.id")
484 ->field("a.*,b.start_address,b.end_address") 504 ->field("a.*,b.start_address,b.end_address")
485 ->where($w) 505 ->where($w)
486 ->count(); 506 ->count();
487 - $data=["data"=>$res,"amount"=>$amount]; 507 + $data = ["data" => $res, "amount" => $amount];
488 508
489 - return $this->success("请求成功",$data); 509 + return $this->success("请求成功", $data);
490 } 510 }
  511 +
491 /** 512 /**
492 *司机查询订单 513 *司机查询订单
493 * @return void 514 * @return void
494 */ 515 */
495 - public function selectbydriver(){ 516 + public function selectbydriver()
  517 + {
496 //$order_status=$this->request->param("order_status"); //接送状态:1=未开始,2=接送中,3=进行中,4=已完成 518 //$order_status=$this->request->param("order_status"); //接送状态:1=未开始,2=接送中,3=进行中,4=已完成
497 - $page=$this->request->param("page");  
498 - $total=$this->request->param("total");  
499 - $order_review_id=$this->request->param("order_review_id");  
500 - $driver=Db::name("driver")->where("user_id",$this->auth->id)->find(); 519 + $page = $this->request->param("page");
  520 + $total = $this->request->param("total");
  521 + $order_review_id = $this->request->param("order_review_id");
  522 + $driver = Db::name("driver")->where("user_id", $this->auth->id)->find();
501 $w['driver_id'] = $driver["id"]; 523 $w['driver_id'] = $driver["id"];
502 $w['order_review_id'] = $order_review_id; 524 $w['order_review_id'] = $order_review_id;
503 - $res=Db::name("order") 525 + $res = Db::name("order")
504 ->alias("a") 526 ->alias("a")
505 - ->join("route b","a.route_id=b.id") 527 + ->join("route b", "a.route_id=b.id")
506 ->field("a.*,b.start_address,b.end_address") 528 ->field("a.*,b.start_address,b.end_address")
507 ->where($w) 529 ->where($w)
508 - ->page($page,$total) 530 + ->page($page, $total)
509 ->select(); 531 ->select();
510 - $amount=Db::name("order") 532 + $amount = Db::name("order")
511 ->alias("a") 533 ->alias("a")
512 - ->join("route b","a.route_id=b.id") 534 + ->join("route b", "a.route_id=b.id")
513 ->field("a.*,b.start_address,b.end_address") 535 ->field("a.*,b.start_address,b.end_address")
514 ->where($w) 536 ->where($w)
515 ->count(); 537 ->count();
516 - $data=["data"=>$res,"amount"=>$amount];  
517 - return $this->success("请求成功",$data); 538 + $data = ["data" => $res, "amount" => $amount];
  539 + return $this->success("请求成功", $data);
518 } 540 }
519 541
520 542
521 -  
522 /** 543 /**
523 *紧急手机号 544 *紧急手机号
524 * @return void 545 * @return void
525 */ 546 */
526 - public function alarm_phone(){ 547 + public function alarm_phone()
  548 + {
527 $content = config("site.alarm_phone");//微信小程序AppID 549 $content = config("site.alarm_phone");//微信小程序AppID
528 - return $this->success("请求成功",$content); 550 + return $this->success("请求成功", $content);
529 } 551 }
530 552
531 /** 553 /**
@@ -538,15 +560,16 @@ class Car extends Base @@ -538,15 +560,16 @@ class Car extends Base
538 * @throws \think\exception\DbException 560 * @throws \think\exception\DbException
539 * @throws \think\exception\PDOException 561 * @throws \think\exception\PDOException
540 */ 562 */
541 - public function refund(){  
542 - $id=$this->request->param("id"); 563 + public function refund()
  564 + {
  565 + $id = $this->request->param("id");
543 //查询订单 566 //查询订单
544 - $order=Db::name("order")->where("id",$id)->find();  
545 - if($order['is_pay']==1){  
546 - if($order['order_status']!=1){ 567 + $order = Db::name("order")->where("id", $id)->find();
  568 + if ($order['is_pay'] == 1) {
  569 + if ($order['order_status'] != 1) {
547 $this->error("该订单无法退款"); 570 $this->error("该订单无法退款");
548 } 571 }
549 - if($order['pay_type']=="offlinepay"){ 572 + if ($order['pay_type'] == "offlinepay") {
550 $relogs['update_time'] = time(); 573 $relogs['update_time'] = time();
551 $relogs['is_pay'] = 4; 574 $relogs['is_pay'] = 4;
552 $relogs['refund_time'] = time(); 575 $relogs['refund_time'] = time();
@@ -580,7 +603,7 @@ class Car extends Base @@ -580,7 +603,7 @@ class Car extends Base
580 $this->error('退款失败'); 603 $this->error('退款失败');
581 } 604 }
582 $this->success("退款成功"); 605 $this->success("退款成功");
583 - }else{ 606 + } else {
584 $relogs['is_pay'] = 4; 607 $relogs['is_pay'] = 4;
585 $rs2 = Db::name('order') 608 $rs2 = Db::name('order')
586 ->where(['id' => $order['id']]) 609 ->where(['id' => $order['id']])
@@ -593,134 +616,140 @@ class Car extends Base @@ -593,134 +616,140 @@ class Car extends Base
593 * 添加临时车辆路线 616 * 添加临时车辆路线
594 * @return void 617 * @return void
595 */ 618 */
596 - public function addtemporaryroute(){  
597 - $user_id=$this->auth->id;  
598 - $driver=Db::name("driver")->where("user_id",$user_id)->find();  
599 - $car=Db::name("car")->where("driver_id",$driver['id'])->find();  
600 - $data=[  
601 - 'user_id'=>$user_id,  
602 - 'car_id'=>$car['id'],  
603 - 'route_id'=>$car['route_id'],  
604 - 'driver_id'=>$driver['id'],  
605 - 'create_time'=>time(), 619 + public function addtemporaryroute()
  620 + {
  621 + $user_id = $this->auth->id;
  622 + $driver = Db::name("driver")->where("user_id", $user_id)->find();
  623 + $car = Db::name("car")->where("driver_id", $driver['id'])->find();
  624 + $data = [
  625 + 'user_id' => $user_id,
  626 + 'car_id' => $car['id'],
  627 + 'route_id' => $car['route_id'],
  628 + 'driver_id' => $driver['id'],
  629 + 'create_time' => time(),
606 ]; 630 ];
607 //判断是否重复 631 //判断是否重复
608 //开始时间 632 //开始时间
609 - $statr_time=strtotime(date("Y-m-d",time()));  
610 - $end_time=$statr_time+86400;  
611 - $is_repeat=Db::name("temporary_route")  
612 - ->where("user_id",$user_id)  
613 - ->where("car_id",$car['id'])  
614 - ->where("create_time",">",$statr_time)  
615 - ->where("create_time","<",$end_time)  
616 - ->where("driver_id",$driver['id']) 633 + $statr_time = strtotime(date("Y-m-d", time()));
  634 + $end_time = $statr_time + 86400;
  635 + $is_repeat = Db::name("temporary_route")
  636 + ->where("user_id", $user_id)
  637 + ->where("car_id", $car['id'])
  638 + ->where("create_time", ">", $statr_time)
  639 + ->where("create_time", "<", $end_time)
  640 + ->where("driver_id", $driver['id'])
617 ->find(); 641 ->find();
618 - if($is_repeat){ 642 + if ($is_repeat) {
619 return $this->error("添加失败"); 643 return $this->error("添加失败");
620 } 644 }
621 - $res=Db::name("temporary_route")->insert($data);  
622 - return $this->success("添加成功",$res); 645 + $res = Db::name("temporary_route")->insert($data);
  646 + return $this->success("添加成功", $res);
623 } 647 }
624 648
625 /** 649 /**
626 * 意向司机 650 * 意向司机
627 * @return void 651 * @return void
628 */ 652 */
629 - public function intention_driver(){  
630 - $route_id=$this->request->param("route_id");  
631 - $car=Db::name("car") 653 + public function intention_driver()
  654 + {
  655 + $route_id = $this->request->param("route_id");
  656 + $car = Db::name("car")
632 ->alias("a") 657 ->alias("a")
633 - ->join("driver b","a.driver_id=b.id")  
634 - ->where("route_id",$route_id) 658 + ->join("driver b", "a.driver_id=b.id")
  659 + ->where("route_id", $route_id)
635 ->field("b.id,b.name,a.license_plate") 660 ->field("b.id,b.name,a.license_plate")
636 ->select(); 661 ->select();
637 - return $this->success("请求成功",$car); 662 + return $this->success("请求成功", $car);
638 } 663 }
639 664
640 /** 665 /**
641 * 添加紧急联系人手机 666 * 添加紧急联系人手机
642 * @return void 667 * @return void
643 */ 668 */
644 - public function emergency_phone(){  
645 - $emergency_phone=$this->request->param("emergency_phone");  
646 - $user_id=$this->auth->id;  
647 - $res=Db::name("user")  
648 - ->where("id",$user_id)  
649 - ->update(['emergency_phone'=>$emergency_phone]);  
650 - return $this->success("修改成功",$res); 669 + public function emergency_phone()
  670 + {
  671 + $emergency_phone = $this->request->param("emergency_phone");
  672 + $user_id = $this->auth->id;
  673 + $res = Db::name("user")
  674 + ->where("id", $user_id)
  675 + ->update(['emergency_phone' => $emergency_phone]);
  676 + return $this->success("修改成功", $res);
651 } 677 }
652 678
653 /** 679 /**
654 * 获取轮播图 680 * 获取轮播图
655 * @return void 681 * @return void
656 */ 682 */
657 - public function getimage(){  
658 - $res=Db::name("image")->where("is_show",1)->select();  
659 - foreach ($res as $k=>$v){  
660 - $res[$k]['image']=full_image($res[$k]['image']); 683 + public function getimage()
  684 + {
  685 + $res = Db::name("image")->where("is_show", 1)->select();
  686 + foreach ($res as $k => $v) {
  687 + $res[$k]['image'] = full_image($res[$k]['image']);
661 } 688 }
662 - return $this->success("请求成功",$res); 689 + return $this->success("请求成功", $res);
663 } 690 }
664 691
665 /** 692 /**
666 * 获取座位详情 693 * 获取座位详情
667 * @return void 694 * @return void
668 */ 695 */
669 - public function car_seat(){  
670 - $car_id=$this->request->param("car_id");  
671 - $specificaddress_id=$this->request->param("specificaddress_id"); 696 + public function car_seat()
  697 + {
  698 + $car_id = $this->request->param("car_id");
  699 + $specificaddress_id = $this->request->param("specificaddress_id");
672 //查询车辆信息 700 //查询车辆信息
673 - $specificaddress=Db::name("specificaddress")->where("id",$specificaddress_id)->find();  
674 - $car=Db::name("car")->where("id",$car_id)->find();  
675 - $seat=Db::name("seat")->where("id",$car['seat_id'])->find();  
676 - $seat['seat']=json_decode($seat['seat'],true); 701 + $specificaddress = Db::name("specificaddress")->where("id", $specificaddress_id)->find();
  702 + $car = Db::name("car")->where("id", $car_id)->find();
  703 + $seat = Db::name("seat")->where("id", $car['seat_id'])->find();
  704 + $seat['seat'] = json_decode($seat['seat'], true);
677 //查询当日订单 705 //查询当日订单
678 - $statr_time=strtotime(date("Y-m-d",time()));  
679 - $end_time=$statr_time+86400;  
680 - $order=Db::name("order")  
681 - ->where("create_time",">",$statr_time)  
682 - ->where("create_time","<",$end_time)  
683 - ->where('type',1)  
684 - ->where('car_id',$car_id) 706 + $statr_time = strtotime(date("Y-m-d", time()));
  707 + $end_time = $statr_time + 86400;
  708 + $order = Db::name("order")
  709 + ->where("create_time", ">", $statr_time)
  710 + ->where("create_time", "<", $end_time)
  711 + ->where('type', 1)
  712 + ->where('car_id', $car_id)
685 ->field("seat_no") 713 ->field("seat_no")
686 ->select(); 714 ->select();
687 - if($order){  
688 - foreach ($order as $k=>$v){  
689 - $seat_no[$k]=$order[$k]["seat_no"];  
690 - $seat_no[$k]['seat_price']=$specificaddress["price"]; 715 + if ($order) {
  716 + foreach ($order as $k => $v) {
  717 + $seat_no[$k] = $order[$k]["seat_no"];
  718 + $seat_no[$k]['seat_price'] = $specificaddress["price"];
691 } 719 }
692 - $seat_no = array_filter($seat_no, function($value) { 720 + $seat_no = array_filter($seat_no, function ($value) {
693 return !empty($value); 721 return !empty($value);
694 }); 722 });
695 $seat_no = implode(',', $seat_no); 723 $seat_no = implode(',', $seat_no);
696 724
697 $seat_no = explode(",", $seat_no); 725 $seat_no = explode(",", $seat_no);
698 } 726 }
699 - foreach ($seat['seat'] as $k=>$v){  
700 - if($order){  
701 - if( in_array($seat['seat'][$k]['seat_no'],$seat_no)){  
702 - $seat['seat'][$k]['is_sale']=1;  
703 - }else{  
704 - $seat['seat'][$k]['is_sale']=0; 727 + foreach ($seat['seat'] as $k => $v) {
  728 + if ($order) {
  729 + if (in_array($seat['seat'][$k]['seat_no'], $seat_no)) {
  730 + $seat['seat'][$k]['is_sale'] = 1;
  731 + } else {
  732 + $seat['seat'][$k]['is_sale'] = 0;
705 } 733 }
706 - }else{  
707 - $seat['seat'][$k]['is_sale']=0; 734 + } else {
  735 + $seat['seat'][$k]['is_sale'] = 0;
708 } 736 }
709 737
710 } 738 }
711 - return $this->success("请求成功",$seat); 739 + return $this->success("请求成功", $seat);
712 } 740 }
713 741
714 /** 742 /**
715 * 支付信息 743 * 支付信息
716 * @return void 744 * @return void
717 */ 745 */
718 - public function order_log(){  
719 - $page=$this->request->param("page");  
720 - $total=$this->request->param("total");  
721 - $res=Db::name("order_log")->where("user_id",$this->auth->id)  
722 - ->page($page,$total)->select();  
723 - return $this->success("请求成功",$res); 746 + public function order_log()
  747 + {
  748 + $page = $this->request->param("page");
  749 + $total = $this->request->param("total");
  750 + $res = Db::name("order_log")->where("user_id", $this->auth->id)
  751 + ->page($page, $total)->select();
  752 + return $this->success("请求成功", $res);
724 } 753 }
725 754
726 755
@@ -728,49 +757,51 @@ class Car extends Base @@ -728,49 +757,51 @@ class Car extends Base
728 * 钱包金额 757 * 钱包金额
729 * @return void 758 * @return void
730 */ 759 */
731 - public function mywallet(){  
732 - $res=Db::name("user")->where("id",$this->auth->id)->field("money")->find();  
733 - return $this->success("请求成功",$res); 760 + public function mywallet()
  761 + {
  762 + $res = Db::name("user")->where("id", $this->auth->id)->field("money")->find();
  763 + return $this->success("请求成功", $res);
734 } 764 }
735 765
736 /** 766 /**
737 * 提现接口 767 * 提现接口
738 * @return void 768 * @return void
739 */ 769 */
740 - public function withdrawal(){  
741 - $money=$this->request->param("money");  
742 - $name=$this->request->param("name");  
743 - $bank_card=$this->request->param("bank_card");  
744 - $user_id=$this->auth->id;  
745 - $user=Db::name("user")->where("id",$user_id)->find();  
746 - if($user['money']<$money){ 770 + public function withdrawal()
  771 + {
  772 + $money = $this->request->param("money");
  773 + $name = $this->request->param("name");
  774 + $bank_card = $this->request->param("bank_card");
  775 + $user_id = $this->auth->id;
  776 + $user = Db::name("user")->where("id", $user_id)->find();
  777 + if ($user['money'] < $money) {
747 $this->error("金额不足"); 778 $this->error("金额不足");
748 } 779 }
749 //减少金额 780 //减少金额
750 - $newmoney=bcsub($user['money'],$money,2);  
751 - $updatemoney=Db::name("user")->where("id",$user_id)->update(['money'=>$newmoney]);  
752 - if($updatemoney){ 781 + $newmoney = bcsub($user['money'], $money, 2);
  782 + $updatemoney = Db::name("user")->where("id", $user_id)->update(['money' => $newmoney]);
  783 + if ($updatemoney) {
753 //添加提现记录 784 //添加提现记录
754 - $data=[  
755 - "user_id"=>$user_id,  
756 - "bank_card"=>$bank_card,  
757 - "name"=>$name,  
758 - "create_time"=>time(),  
759 - "money"=>$money,  
760 - "newmoney"=>$newmoney, 785 + $data = [
  786 + "user_id" => $user_id,
  787 + "bank_card" => $bank_card,
  788 + "name" => $name,
  789 + "create_time" => time(),
  790 + "money" => $money,
  791 + "newmoney" => $newmoney,
761 ]; 792 ];
762 - $res=Db::name("withdrawal")->insert($data);  
763 - $data=[  
764 - "money"=>$money,  
765 - "type"=>2,  
766 - "create_time"=>time(),  
767 - "before"=>$user['money'],  
768 - "memo"=>"提现",  
769 - "after"=>$newmoney, 793 + $res = Db::name("withdrawal")->insert($data);
  794 + $data = [
  795 + "money" => $money,
  796 + "type" => 2,
  797 + "create_time" => time(),
  798 + "before" => $user['money'],
  799 + "memo" => "提现",
  800 + "after" => $newmoney,
770 ]; 801 ];
771 - $addmoney_log=Db::name("user_money_log")->insert($data);  
772 - return $this->success("提现成功",$res);  
773 - }else{ 802 + $addmoney_log = Db::name("user_money_log")->insert($data);
  803 + return $this->success("提现成功", $res);
  804 + } else {
774 return $this->error("提现失败"); 805 return $this->error("提现失败");
775 } 806 }
776 } 807 }
@@ -779,52 +810,55 @@ class Car extends Base @@ -779,52 +810,55 @@ class Car extends Base
779 * 提现金额列表 810 * 提现金额列表
780 * @return void 811 * @return void
781 */ 812 */
782 - public function withdrawallist(){  
783 - $page=$this->request->param("page");  
784 - $total=$this->request->param("total");  
785 - $user_money_log=Db::name("withdrawal")  
786 - ->where("user_id",$this->auth->id)  
787 - ->page($page,$total) 813 + public function withdrawallist()
  814 + {
  815 + $page = $this->request->param("page");
  816 + $total = $this->request->param("total");
  817 + $user_money_log = Db::name("withdrawal")
  818 + ->where("user_id", $this->auth->id)
  819 + ->page($page, $total)
788 ->select(); 820 ->select();
789 - return $this->success("请求成功",$user_money_log); 821 + return $this->success("请求成功", $user_money_log);
790 } 822 }
791 823
792 /** 824 /**
793 * 司机认证 825 * 司机认证
794 * @return void 826 * @return void
795 */ 827 */
796 - public function driverauthentication(){  
797 - $license_plate=$this->request->param("license_plate");//车牌号  
798 - $car_model=$this->request->param("car_model");//车型  
799 - $colour=$this->request->param("colour");//颜色  
800 - $name=$this->request->param("name");//名字  
801 - $driving_license=$this->request->param("driving_license");//行驶证  
802 - $driver_license=$this->request->param("driver_license");//驾照  
803 - $driving_license=$this->uploadBase64($driving_license);  
804 - $driver_license=$this->uploadBase64($driver_license); 828 + public function driverauthentication()
  829 + {
  830 + $license_plate = $this->request->param("license_plate");//车牌号
  831 + $car_model = $this->request->param("car_model");//车型
  832 + $colour = $this->request->param("colour");//颜色
  833 + $name = $this->request->param("name");//名字
  834 + $driving_license = $this->request->param("driving_license");//行驶证
  835 + $driver_license = $this->request->param("driver_license");//驾照
  836 + $driving_license = $this->uploadBase64($driving_license);
  837 + $driver_license = $this->uploadBase64($driver_license);
805 //判断是否已有 838 //判断是否已有
806 - $isdriver=Db::name("driver")->where("user_id",$this->auth->id)->find();  
807 - if($isdriver){ 839 + $isdriver = Db::name("driver")->where("user_id", $this->auth->id)->find();
  840 + if ($isdriver) {
808 return $this->error("已认证"); 841 return $this->error("已认证");
809 } 842 }
810 - $driver=Db::name("driver") 843 + $driver = Db::name("driver")
811 ->insertGetId([ 844 ->insertGetId([
812 - "user_id"=>$this->auth->id,  
813 - "name"=>$name,  
814 - "phone"=>$this->auth->mobile 845 + "user_id" => $this->auth->id,
  846 + "name" => $name,
  847 + "phone" => $this->auth->mobile
815 ]); 848 ]);
816 - $res=Db::name("car") 849 + $res = Db::name("car")
817 ->insert([ 850 ->insert([
818 - "license_plate"=>$license_plate,  
819 - "car_model"=>$car_model,  
820 - "colour"=>$colour,  
821 - "driver_id"=>$driver,  
822 - "driving_license"=>$driving_license,  
823 - "driver_license"=>$driver_license,  
824 - "status"=>2, 851 + "license_plate" => $license_plate,
  852 + "car_model" => $car_model,
  853 + "colour" => $colour,
  854 + "driver_id" => $driver,
  855 + "driving_license" => $driving_license,
  856 + "driver_license" => $driver_license,
  857 + "status" => 2,
825 ]); 858 ]);
826 - return $this->success("请求成功",$res); 859 + return $this->success("请求成功", $res);
827 } 860 }
  861 +
828 public function uploadBase64($base64Str) 862 public function uploadBase64($base64Str)
829 { 863 {
830 // 将Base64字符串转换为文件并保存 864 // 将Base64字符串转换为文件并保存
@@ -851,18 +885,20 @@ class Car extends Base @@ -851,18 +885,20 @@ class Car extends Base
851 * 乘车须知 885 * 乘车须知
852 * @return void 886 * @return void
853 */ 887 */
854 - public function getriding_instructions(){ 888 + public function getriding_instructions()
  889 + {
855 $content = config("site.riding_instructions"); 890 $content = config("site.riding_instructions");
856 - return $this->success("请求成功",$content); 891 + return $this->success("请求成功", $content);
857 } 892 }
858 893
859 /** 894 /**
860 * 通知公告 895 * 通知公告
861 * @return void 896 * @return void
862 */ 897 */
863 - public function getnotice(){ 898 + public function getnotice()
  899 + {
864 $content = config("site.notice"); 900 $content = config("site.notice");
865 - return $this->success("请求成功",$content); 901 + return $this->success("请求成功", $content);
866 } 902 }
867 903
868 904
@@ -870,18 +906,20 @@ class Car extends Base @@ -870,18 +906,20 @@ class Car extends Base
870 * 司机认证 906 * 司机认证
871 * @return void 907 * @return void
872 */ 908 */
873 - public function getdriver_authentication(){ 909 + public function getdriver_authentication()
  910 + {
874 $content = config("site.driver_authentication"); 911 $content = config("site.driver_authentication");
875 - return $this->success("请求成功",$content); 912 + return $this->success("请求成功", $content);
876 } 913 }
877 914
878 /** 915 /**
879 * 关于我们 916 * 关于我们
880 * @return void 917 * @return void
881 */ 918 */
882 - public function getaboutwe(){ 919 + public function getaboutwe()
  920 + {
883 $content = config("site.aboutwe"); 921 $content = config("site.aboutwe");
884 - return $this->success("请求成功",$content); 922 + return $this->success("请求成功", $content);
885 } 923 }
886 924
887 925
@@ -889,7 +927,8 @@ class Car extends Base @@ -889,7 +927,8 @@ class Car extends Base
889 * 创建包车订单 927 * 创建包车订单
890 * @return void 928 * @return void
891 */ 929 */
892 - public function createcharterorder(){ 930 + public function createcharterorder()
  931 + {
893 932
894 $route_id = $this->request->param("route_id");//线路 933 $route_id = $this->request->param("route_id");//线路
895 $number = $this->request->param("number");//乘车人数 934 $number = $this->request->param("number");//乘车人数
@@ -899,31 +938,31 @@ class Car extends Base @@ -899,31 +938,31 @@ class Car extends Base
899 $charter_num = $this->request->param("charter_num");//包车数量 938 $charter_num = $this->request->param("charter_num");//包车数量
900 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 939 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机
901 $remarks = $this->request->param("remarks");//备注 940 $remarks = $this->request->param("remarks");//备注
902 - $carmodel=Db::name("carmodel")->where("id",$carmodel_id)->find(); 941 + $carmodel = Db::name("carmodel")->where("id", $carmodel_id)->find();
903 $specificaddress_id = $this->request->param("specificaddress_id");//区域id 942 $specificaddress_id = $this->request->param("specificaddress_id");//区域id
904 - $chartercar=Db::name("chartercar")  
905 - ->where("specificaddress_id",$specificaddress_id)  
906 - ->where("carmodel_id",$carmodel_id) 943 + $chartercar = Db::name("chartercar")
  944 + ->where("specificaddress_id", $specificaddress_id)
  945 + ->where("carmodel_id", $carmodel_id)
907 ->find(); 946 ->find();
908 - $price=0;  
909 - $price=bcmul($charter_num,$chartercar['price'],2);  
910 -  
911 - $data=[  
912 - "order_no"=>getOrderSn(),  
913 - "price"=>$price,  
914 - "reservation_time"=>$reservation_time,  
915 - "is_pay"=>"2",//未支付  
916 - "route_id"=>$route_id,  
917 - "user_id"=>$this->auth->id,  
918 - "phone"=>$phone,  
919 - "create_time"=>time(),  
920 - "reservation_time"=>time(),  
921 - "type"=>2,  
922 - "number"=>$number,  
923 - "remarks"=>$remarks,  
924 - "intended_driver_id"=>$intended_driver_id, 947 + $price = 0;
  948 + $price = bcmul($charter_num, $chartercar['price'], 2);
  949 +
  950 + $data = [
  951 + "order_no" => getOrderSn(),
  952 + "price" => $price,
  953 + "reservation_time" => $reservation_time,
  954 + "is_pay" => "2",//未支付
  955 + "route_id" => $route_id,
  956 + "user_id" => $this->auth->id,
  957 + "phone" => $phone,
  958 + "create_time" => time(),
  959 + "reservation_time" => time(),
  960 + "type" => 2,
  961 + "number" => $number,
  962 + "remarks" => $remarks,
  963 + "intended_driver_id" => $intended_driver_id,
925 ]; 964 ];
926 - $res=Db::name("order")->insertGetId($data); 965 + $res = Db::name("order")->insertGetId($data);
927 $userinfo = Db::name('user') 966 $userinfo = Db::name('user')
928 ->where(['id' => $this->auth->id]) 967 ->where(['id' => $this->auth->id])
929 ->field('id,wx_xcx_openid') 968 ->field('id,wx_xcx_openid')
@@ -938,7 +977,7 @@ class Car extends Base @@ -938,7 +977,7 @@ class Car extends Base
938 'openid' => $userinfo['wx_xcx_openid'], 977 'openid' => $userinfo['wx_xcx_openid'],
939 ]; 978 ];
940 $f = \addons\epay\library\Service::submitOrder($params); 979 $f = \addons\epay\library\Service::submitOrder($params);
941 - $this->success("请求成功",$f); 980 + $this->success("请求成功", $f);
942 981
943 } 982 }
944 983
@@ -946,7 +985,8 @@ class Car extends Base @@ -946,7 +985,8 @@ class Car extends Base
946 * 创建包车订单 985 * 创建包车订单
947 * @return void 986 * @return void
948 */ 987 */
949 - public function createcharterorderofflinepay(){ 988 + public function createcharterorderofflinepay()
  989 + {
950 $route_id = $this->request->param("route_id");//线路 990 $route_id = $this->request->param("route_id");//线路
951 $number = $this->request->param("number");//乘车人数 991 $number = $this->request->param("number");//乘车人数
952 $reservation_time = $this->request->param("reservation_time");//预约时间 992 $reservation_time = $this->request->param("reservation_time");//预约时间
@@ -955,33 +995,33 @@ class Car extends Base @@ -955,33 +995,33 @@ class Car extends Base
955 $charter_num = $this->request->param("charter_num");//包车数量 995 $charter_num = $this->request->param("charter_num");//包车数量
956 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 996 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机
957 $remarks = $this->request->param("remarks");//备注 997 $remarks = $this->request->param("remarks");//备注
958 - $carmodel=Db::name("carmodel")->where("id",$carmodel_id)->find(); 998 + $carmodel = Db::name("carmodel")->where("id", $carmodel_id)->find();
959 $specificaddress_id = $this->request->param("specificaddress_id");//区域id 999 $specificaddress_id = $this->request->param("specificaddress_id");//区域id
960 - $chartercar=Db::name("chartercar")  
961 - ->where("specificaddress_id",$specificaddress_id)  
962 - ->where("carmodel_id",$carmodel_id) 1000 + $chartercar = Db::name("chartercar")
  1001 + ->where("specificaddress_id", $specificaddress_id)
  1002 + ->where("carmodel_id", $carmodel_id)
963 ->find(); 1003 ->find();
964 - $price=0;  
965 - $price=bcmul($charter_num,$chartercar['price'],2);  
966 - $data=[  
967 - "order_no"=>getOrderSn(),  
968 - "price"=>$price,  
969 - "reservation_time"=>$reservation_time,  
970 - "is_pay"=>1,//未支付  
971 - "route_id"=>$route_id,  
972 - "user_id"=>$this->auth->id,  
973 - "phone"=>$phone,  
974 - "pay_type"=>"offlinepay",  
975 - "create_time"=>time(),  
976 - "reservation_time"=>time(),  
977 - "type"=>2,  
978 - "number"=>$number,  
979 - "remarks"=>$remarks,  
980 - "intended_driver_id"=>$intended_driver_id, 1004 + $price = 0;
  1005 + $price = bcmul($charter_num, $chartercar['price'], 2);
  1006 + $data = [
  1007 + "order_no" => getOrderSn(),
  1008 + "price" => $price,
  1009 + "reservation_time" => $reservation_time,
  1010 + "is_pay" => 1,//未支付
  1011 + "route_id" => $route_id,
  1012 + "user_id" => $this->auth->id,
  1013 + "phone" => $phone,
  1014 + "pay_type" => "offlinepay",
  1015 + "create_time" => time(),
  1016 + "reservation_time" => time(),
  1017 + "type" => 2,
  1018 + "number" => $number,
  1019 + "remarks" => $remarks,
  1020 + "intended_driver_id" => $intended_driver_id,
981 ]; 1021 ];
982 - $res=Db::name("order")->insertGetId($data); 1022 + $res = Db::name("order")->insertGetId($data);
983 1023
984 - $this->success("请求成功",$res); 1024 + $this->success("请求成功", $res);
985 1025
986 } 1026 }
987 1027
@@ -989,7 +1029,8 @@ class Car extends Base @@ -989,7 +1029,8 @@ class Car extends Base
989 * 创建城际订单 1029 * 创建城际订单
990 * @return void 1030 * @return void
991 */ 1031 */
992 - public function createintercityorder(){ 1032 + public function createintercityorder()
  1033 + {
993 $is_qrcode = $this->request->param("is_qrcode");//二维码下单:0=不是,1=是 1034 $is_qrcode = $this->request->param("is_qrcode");//二维码下单:0=不是,1=是
994 $route_id = $this->request->param("route_id");//线路 1035 $route_id = $this->request->param("route_id");//线路
995 $position = $this->request->param("position");//上车地址 1036 $position = $this->request->param("position");//上车地址
@@ -1002,37 +1043,37 @@ class Car extends Base @@ -1002,37 +1043,37 @@ class Car extends Base
1002 $phone = $this->request->param("phone");//联系电话 1043 $phone = $this->request->param("phone");//联系电话
1003 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 1044 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机
1004 $remarks = $this->request->param("remarks");//备注 1045 $remarks = $this->request->param("remarks");//备注
1005 - $driver=Db::name("driver")->where("id",$intended_driver_id)->find();  
1006 - $car=Db::name("car")->where("driver_id",$driver['id'])->find();  
1007 - $carmodel=Db::name("carmodel")->where("id",$car['carmodel_id'])->find();  
1008 - $route=Db::name("route")->where("id",$car['route_id'])->find();  
1009 - $price=0;  
1010 - $specificaddress=Db::name("specificaddress")->where("id",$specificaddress_id)->find();  
1011 - if($specificaddress){  
1012 - $price=bcmul($number,$specificaddress['price'],2);  
1013 - }else{ 1046 + $driver = Db::name("driver")->where("id", $intended_driver_id)->find();
  1047 + $car = Db::name("car")->where("driver_id", $driver['id'])->find();
  1048 + $carmodel = Db::name("carmodel")->where("id", $car['carmodel_id'])->find();
  1049 + $route = Db::name("route")->where("id", $car['route_id'])->find();
  1050 + $price = 0;
  1051 + $specificaddress = Db::name("specificaddress")->where("id", $specificaddress_id)->find();
  1052 + if ($specificaddress) {
  1053 + $price = bcmul($number, $specificaddress['price'], 2);
  1054 + } else {
1014 $this->error("价格计算错误"); 1055 $this->error("价格计算错误");
1015 } 1056 }
1016 - $data=[  
1017 - "order_no"=>getOrderSn(),  
1018 - "price"=>$price,  
1019 - "driver_id"=>$driver['id'],  
1020 - "is_qrcode"=>$is_qrcode,  
1021 - "specificaddress_id"=>$specificaddress_id,  
1022 - "reservation_time"=>$reservation_time,  
1023 - "is_pay"=>"2",//未支付  
1024 - "route_id"=>$route_id,  
1025 - "user_id"=>$this->auth->id,  
1026 - "driver_id"=>$driver['id'],  
1027 - "phone"=>$phone,  
1028 - "create_time"=>time(),  
1029 - "reservation_time"=>time(),  
1030 - "type"=>2,  
1031 - "number"=>$number,  
1032 - "remarks"=>$remarks,  
1033 - "intended_driver_id"=>$intended_driver_id, 1057 + $data = [
  1058 + "order_no" => getOrderSn(),
  1059 + "price" => $price,
  1060 + "driver_id" => $driver['id'],
  1061 + "is_qrcode" => $is_qrcode,
  1062 + "specificaddress_id" => $specificaddress_id,
  1063 + "reservation_time" => $reservation_time,
  1064 + "is_pay" => "2",//未支付
  1065 + "route_id" => $route_id,
  1066 + "user_id" => $this->auth->id,
  1067 + "driver_id" => $driver['id'],
  1068 + "phone" => $phone,
  1069 + "create_time" => time(),
  1070 + "reservation_time" => time(),
  1071 + "type" => 2,
  1072 + "number" => $number,
  1073 + "remarks" => $remarks,
  1074 + "intended_driver_id" => $intended_driver_id,
1034 ]; 1075 ];
1035 - $res=Db::name("order")->insertGetId($data); 1076 + $res = Db::name("order")->insertGetId($data);
1036 $userinfo = Db::name('user') 1077 $userinfo = Db::name('user')
1037 ->where(['id' => $this->auth->id]) 1078 ->where(['id' => $this->auth->id])
1038 ->field('id,wx_xcx_openid') 1079 ->field('id,wx_xcx_openid')
@@ -1047,7 +1088,7 @@ class Car extends Base @@ -1047,7 +1088,7 @@ class Car extends Base
1047 'openid' => $userinfo['wx_xcx_openid'], 1088 'openid' => $userinfo['wx_xcx_openid'],
1048 ]; 1089 ];
1049 $f = \addons\epay\library\Service::submitOrder($params); 1090 $f = \addons\epay\library\Service::submitOrder($params);
1050 - $this->success("请求成功",$f); 1091 + $this->success("请求成功", $f);
1051 1092
1052 } 1093 }
1053 1094
@@ -1056,7 +1097,8 @@ class Car extends Base @@ -1056,7 +1097,8 @@ class Car extends Base
1056 * 创建城际订单线下支付 1097 * 创建城际订单线下支付
1057 * @return void 1098 * @return void
1058 */ 1099 */
1059 - public function createintercityorderofflinepay(){ 1100 + public function createintercityorderofflinepay()
  1101 + {
1060 $is_qrcode = $this->request->param("is_qrcode");//二维码下单:0=不是,1=是 1102 $is_qrcode = $this->request->param("is_qrcode");//二维码下单:0=不是,1=是
1061 $route_id = $this->request->param("route_id");//线路 1103 $route_id = $this->request->param("route_id");//线路
1062 $number = $this->request->param("number");//乘车人数 1104 $number = $this->request->param("number");//乘车人数
@@ -1069,57 +1111,59 @@ class Car extends Base @@ -1069,57 +1111,59 @@ class Car extends Base
1069 $specificaddress_id = $this->request->param("specificaddress_id");//区域id 1111 $specificaddress_id = $this->request->param("specificaddress_id");//区域id
1070 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机 1112 $intended_driver_id = $this->request->param("intended_driver_id");//意向司机
1071 $remarks = $this->request->param("remarks");//备注 1113 $remarks = $this->request->param("remarks");//备注
1072 - $driver=Db::name("driver")->where("id",$intended_driver_id)->find();  
1073 - $car=Db::name("car")->where("driver_id",$driver['id'])->find();  
1074 - $carmodel=Db::name("carmodel")->where("id",$carmodel_id)->find();  
1075 - $route=Db::name("route")->where("id",$car['route_id'])->find();  
1076 - $price=0;  
1077 - $specificaddress=Db::name("specificaddress")->where("id",$specificaddress_id)->find();  
1078 - if($specificaddress){  
1079 - $price=bcmul($number,$specificaddress['price'],2);  
1080 - }else{ 1114 + $driver = Db::name("driver")->where("id", $intended_driver_id)->find();
  1115 + $car = Db::name("car")->where("driver_id", $driver['id'])->find();
  1116 + $carmodel = Db::name("carmodel")->where("id", $carmodel_id)->find();
  1117 + $route = Db::name("route")->where("id", $car['route_id'])->find();
  1118 + $price = 0;
  1119 + $specificaddress = Db::name("specificaddress")->where("id", $specificaddress_id)->find();
  1120 + if ($specificaddress) {
  1121 + $price = bcmul($number, $specificaddress['price'], 2);
  1122 + } else {
1081 $this->error("价格计算错误"); 1123 $this->error("价格计算错误");
1082 } 1124 }
1083 - $data=[  
1084 - "order_no"=>getOrderSn(),  
1085 - "price"=>$price,  
1086 - "is_qrcode"=>$is_qrcode,  
1087 - "specificaddress_id"=>$specificaddress_id,  
1088 - "reservation_time"=>$reservation_time,  
1089 - "is_pay"=>1,//未支付  
1090 - "route_id"=>$route_id,  
1091 - "driver_id"=>$driver['id'],  
1092 - "user_id"=>$this->auth->id,  
1093 - "phone"=>$phone,  
1094 - "pay_type"=>"offlinepay",  
1095 - "create_time"=>time(),  
1096 - "reservation_time"=>time(),  
1097 - "type"=>2,  
1098 - "number"=>$number,  
1099 - "remarks"=>$remarks,  
1100 - "intended_driver_id"=>$intended_driver_id, 1125 + $data = [
  1126 + "order_no" => getOrderSn(),
  1127 + "price" => $price,
  1128 + "is_qrcode" => $is_qrcode,
  1129 + "specificaddress_id" => $specificaddress_id,
  1130 + "reservation_time" => $reservation_time,
  1131 + "is_pay" => 1,//未支付
  1132 + "route_id" => $route_id,
  1133 + "driver_id" => $driver['id'],
  1134 + "user_id" => $this->auth->id,
  1135 + "phone" => $phone,
  1136 + "pay_type" => "offlinepay",
  1137 + "create_time" => time(),
  1138 + "reservation_time" => time(),
  1139 + "type" => 2,
  1140 + "number" => $number,
  1141 + "remarks" => $remarks,
  1142 + "intended_driver_id" => $intended_driver_id,
1101 ]; 1143 ];
1102 - $res=Db::name("order")->insertGetId($data);  
1103 - $this->success("请求成功",$res); 1144 + $res = Db::name("order")->insertGetId($data);
  1145 + $this->success("请求成功", $res);
1104 } 1146 }
1105 1147
1106 /** 1148 /**
1107 * 查询二维码 1149 * 查询二维码
1108 * @return void 1150 * @return void
1109 */ 1151 */
1110 - public function qrcode(){  
1111 - $driver=Db::name("driver")->where('user_id',$this->auth->id)->field("place_image")->find();  
1112 - $driver['place_image']=full_image($driver['place_image']);  
1113 - $this->success("请求成功",$driver); 1152 + public function qrcode()
  1153 + {
  1154 + $driver = Db::name("driver")->where('user_id', $this->auth->id)->field("place_image")->find();
  1155 + $driver['place_image'] = full_image($driver['place_image']);
  1156 + $this->success("请求成功", $driver);
1114 } 1157 }
1115 1158
1116 /** 1159 /**
1117 * 查询二维码 1160 * 查询二维码
1118 * @return void 1161 * @return void
1119 */ 1162 */
1120 - public function carmodel(){  
1121 - $carmodel=Db::name("carmodel")->select();  
1122 - $this->success("请求成功",$carmodel); 1163 + public function carmodel()
  1164 + {
  1165 + $carmodel = Db::name("carmodel")->select();
  1166 + $this->success("请求成功", $carmodel);
1123 } 1167 }
1124 1168
1125 /** 1169 /**
@@ -1130,47 +1174,49 @@ class Car extends Base @@ -1130,47 +1174,49 @@ class Car extends Base
1130 * @throws \think\db\exception\ModelNotFoundException 1174 * @throws \think\db\exception\ModelNotFoundException
1131 * @throws \think\exception\DbException 1175 * @throws \think\exception\DbException
1132 */ 1176 */
1133 - public function selectintercityorder(){  
1134 - $page=$this->request->param("page");  
1135 - $total=$this->request->param("total");  
1136 - $start_time=$this->request->param("start_time");  
1137 - $end_time=$this->request->param("end_time");  
1138 - $driver=Db::name("driver")->where('user_id',7)->find();  
1139 - $res=Db::name("order") 1177 + public function selectintercityorder()
  1178 + {
  1179 + $page = $this->request->param("page");
  1180 + $total = $this->request->param("total");
  1181 + $start_time = $this->request->param("start_time");
  1182 + $end_time = $this->request->param("end_time");
  1183 + $driver = Db::name("driver")->where('user_id', 7)->find();
  1184 + $res = Db::name("order")
1140 ->alias("a") 1185 ->alias("a")
1141 - ->join("route b","a.route_id=b.id") 1186 + ->join("route b", "a.route_id=b.id")
1142 ->field("a.*,b.start_address,b.end_address") 1187 ->field("a.*,b.start_address,b.end_address")
1143 - ->where("a.driver_id",$driver["id"])  
1144 - ->where("is_qrcode",1)  
1145 - ->where("a.create_time",">",$start_time)  
1146 - ->where("a.create_time","<",$end_time)  
1147 - ->page($page,$total) 1188 + ->where("a.driver_id", $driver["id"])
  1189 + ->where("is_qrcode", 1)
  1190 + ->where("a.create_time", ">", $start_time)
  1191 + ->where("a.create_time", "<", $end_time)
  1192 + ->page($page, $total)
1148 ->select(); 1193 ->select();
1149 - $amount=Db::name("order") 1194 + $amount = Db::name("order")
1150 ->alias("a") 1195 ->alias("a")
1151 - ->join("route b","a.route_id=b.id") 1196 + ->join("route b", "a.route_id=b.id")
1152 ->field("a.*,b.start_address,b.end_address") 1197 ->field("a.*,b.start_address,b.end_address")
1153 - ->where("driver_id",$driver["id"])  
1154 - ->where("is_qrcode",1)  
1155 - ->where("a.create_time",">",$start_time)  
1156 - ->where("a.create_time","<",$end_time) 1198 + ->where("driver_id", $driver["id"])
  1199 + ->where("is_qrcode", 1)
  1200 + ->where("a.create_time", ">", $start_time)
  1201 + ->where("a.create_time", "<", $end_time)
1157 ->count(); 1202 ->count();
1158 - $data=["data"=>$res,"amount"=>$amount];  
1159 - return $this->success("请求成功",$data); 1203 + $data = ["data" => $res, "amount" => $amount];
  1204 + return $this->success("请求成功", $data);
1160 } 1205 }
1161 1206
1162 /** 1207 /**
1163 * 从蒙自出发 1208 * 从蒙自出发
1164 * @return void 1209 * @return void
1165 */ 1210 */
1166 - public function set_out(){  
1167 - $where = ["type"=>1]; 1211 + public function set_out()
  1212 + {
  1213 + $where = ["type" => 1];
1168 $indexList = []; 1214 $indexList = [];
1169 $itemArr = []; 1215 $itemArr = [];
1170 $list = Db::name("route")->where($where) 1216 $list = Db::name("route")->where($where)
1171 ->select(); 1217 ->select();
1172 - foreach ($list as $k=>$v){  
1173 - $list[$k]['specificaddress']=Db::name("specificaddress")->where("route_id",$list[$k]['id'])->select(); 1218 + foreach ($list as $k => $v) {
  1219 + $list[$k]['specificaddress'] = Db::name("specificaddress")->where("route_id", $list[$k]['id'])->select();
1174 } 1220 }
1175 $charArray = []; 1221 $charArray = [];
1176 if (!empty($list)) { 1222 if (!empty($list)) {
@@ -1201,14 +1247,15 @@ class Car extends Base @@ -1201,14 +1247,15 @@ class Car extends Base
1201 * 到达蒙自 1247 * 到达蒙自
1202 * @return void 1248 * @return void
1203 */ 1249 */
1204 - public function reach(){  
1205 - $where = ["type"=>2]; 1250 + public function reach()
  1251 + {
  1252 + $where = ["type" => 2];
1206 $indexList = []; 1253 $indexList = [];
1207 $itemArr = []; 1254 $itemArr = [];
1208 $list = Db::name("route")->where($where) 1255 $list = Db::name("route")->where($where)
1209 ->select(); 1256 ->select();
1210 - foreach ($list as $k=>$v){  
1211 - $list[$k]['specificaddress']=Db::name("specificaddress")->where("route_id",$list[$k]['id'])->select(); 1257 + foreach ($list as $k => $v) {
  1258 + $list[$k]['specificaddress'] = Db::name("specificaddress")->where("route_id", $list[$k]['id'])->select();
1212 } 1259 }
1213 $charArray = []; 1260 $charArray = [];
1214 if (!empty($list)) { 1261 if (!empty($list)) {
@@ -1241,21 +1288,22 @@ class Car extends Base @@ -1241,21 +1288,22 @@ class Car extends Base
1241 * @throws \think\exception\DbException 1288 * @throws \think\exception\DbException
1242 * @throws \think\exception\PDOException 1289 * @throws \think\exception\PDOException
1243 */ 1290 */
1244 - public function orderpayagain(){  
1245 - $order_no=$this->request->param("order_no");  
1246 - $order=Db::name("order")->where("order_no",$order_no)->find(); 1291 + public function orderpayagain()
  1292 + {
  1293 + $order_no = $this->request->param("order_no");
  1294 + $order = Db::name("order")->where("order_no", $order_no)->find();
1247 1295
1248 - if(!$order){ 1296 + if (!$order) {
1249 $this->error("无此订单"); 1297 $this->error("无此订单");
1250 } 1298 }
1251 - if($order['is_pay']!=2){ 1299 + if ($order['is_pay'] != 2) {
1252 $this->error("无法支付该订单"); 1300 $this->error("无法支付该订单");
1253 } 1301 }
1254 - $data=[  
1255 - "order_no"=>getOrderSn(), 1302 + $data = [
  1303 + "order_no" => getOrderSn(),
1256 ]; 1304 ];
1257 - $res=Db::name("order")->where("id",$order['id'])->update($data);  
1258 - $order=Db::name("order")->where("id",$order['id'])->find(); 1305 + $res = Db::name("order")->where("id", $order['id'])->update($data);
  1306 + $order = Db::name("order")->where("id", $order['id'])->find();
1259 $userinfo = Db::name('user') 1307 $userinfo = Db::name('user')
1260 ->where(['id' => $this->auth->id]) 1308 ->where(['id' => $this->auth->id])
1261 ->field('id,wx_xcx_openid') 1309 ->field('id,wx_xcx_openid')
@@ -1270,7 +1318,7 @@ class Car extends Base @@ -1270,7 +1318,7 @@ class Car extends Base
1270 'openid' => $userinfo['wx_xcx_openid'], 1318 'openid' => $userinfo['wx_xcx_openid'],
1271 ]; 1319 ];
1272 $f = \addons\epay\library\Service::submitOrder($params); 1320 $f = \addons\epay\library\Service::submitOrder($params);
1273 - $this->success("请求成功",$f); 1321 + $this->success("请求成功", $f);
1274 } 1322 }
1275 1323
1276 /** 1324 /**
@@ -1280,10 +1328,11 @@ class Car extends Base @@ -1280,10 +1328,11 @@ class Car extends Base
1280 * @throws \think\db\exception\ModelNotFoundException 1328 * @throws \think\db\exception\ModelNotFoundException
1281 * @throws \think\exception\DbException 1329 * @throws \think\exception\DbException
1282 */ 1330 */
1283 - public function selectspecificaddress(){  
1284 - $route_id=$this->request->param("route_id");  
1285 - $specificaddress=Db::name("specificaddress")->where("route_id",$route_id)->select();  
1286 - $this->success("请求成功",$specificaddress); 1331 + public function selectspecificaddress()
  1332 + {
  1333 + $route_id = $this->request->param("route_id");
  1334 + $specificaddress = Db::name("specificaddress")->where("route_id", $route_id)->select();
  1335 + $this->success("请求成功", $specificaddress);
1287 } 1336 }
1288 1337
1289 1338
@@ -1291,32 +1340,32 @@ class Car extends Base @@ -1291,32 +1340,32 @@ class Car extends Base
1291 * 查询订单中选中的座位 1340 * 查询订单中选中的座位
1292 * @return void 1341 * @return void
1293 */ 1342 */
1294 - public function findseat(){  
1295 - $order_id=$this->request->param("order_id");  
1296 - $order=Db::name("order")->where("id",$order_id)->find();  
1297 - $car=Db::name("car")->where("id",$order['car_id'])->find();  
1298 - $seat=Db::name("seat")->where("id",$car['seat_id'])->find();  
1299 - $seat_data=json_decode($seat['seat'],true);  
1300 - $seat_no = array_filter($seat_data, function($value) { 1343 + public function findseat()
  1344 + {
  1345 + $order_id = $this->request->param("order_id");
  1346 + $order = Db::name("order")->where("id", $order_id)->find();
  1347 + $car = Db::name("car")->where("id", $order['car_id'])->find();
  1348 + $seat = Db::name("seat")->where("id", $car['seat_id'])->find();
  1349 + $seat_data = json_decode($seat['seat'], true);
  1350 + $seat_no = array_filter($seat_data, function ($value) {
1301 return !empty($value); 1351 return !empty($value);
1302 }); 1352 });
  1353 + print_r($seat_no);return;
1303 $orderseat_no = explode(",", $order["seat_no"]); 1354 $orderseat_no = explode(",", $order["seat_no"]);
1304 - if($seat_data){  
1305 - if($order['seat_no']){  
1306 -  
1307 - foreach ($seat_data as $k=>$v){  
1308 - foreach ($orderseat_no as $ks=>$vs){  
1309 - if($seat_data[$k]["seat_no"]==$orderseat_no[$ks]){  
1310 - $seat_data[$k]["is_select"]=1;  
1311 - }else{  
1312 - $seat_data[$k]["is_select"]=0; 1355 + if ($seat_data) {
  1356 + if ($order['seat_no']) {
  1357 + foreach ($seat_data as $k => $v) {
  1358 + foreach ($orderseat_no as $ks => $vs) {
  1359 + if ($seat_data[$k]["seat_no"] == $orderseat_no[$ks]) {
  1360 + $seat_data[$k]["is_select"] = 1;
  1361 + } else {
  1362 + $seat_data[$k]["is_select"] = 0;
1313 } 1363 }
1314 } 1364 }
1315 } 1365 }
1316 -  
1317 } 1366 }
1318 - $this->success("请求成功",$seat_data);  
1319 - }else{ 1367 + $this->success("请求成功", $seat_data);
  1368 + } else {
1320 $this->error("请求失败"); 1369 $this->error("请求失败");
1321 } 1370 }
1322 } 1371 }