|
@@ -58,15 +58,63 @@ class Car extends Api |
|
@@ -58,15 +58,63 @@ class Car extends Api |
58
|
* @return void
|
58
|
* @return void
|
59
|
*/
|
59
|
*/
|
60
|
public function createorder(){
|
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");
|
61
|
+ $number=$this->request->param("number");//乘车人数
|
|
|
62
|
+ $phone = $this->request->param("phone");//联系手机号码
|
|
|
63
|
+ $user_name = $this->request->param("user_name");//联系人
|
|
|
64
|
+ $position = $this->request->param("position");//上车地址
|
|
|
65
|
+ $lat = $this->request->param("lat");//经度
|
|
|
66
|
+ $lng = $this->request->param("lng");//维度
|
|
|
67
|
+ $remarks = $this->request->param("remarks");//备注
|
|
|
68
|
+ $intended_driver_id = $this->request->param("intended_driver_id");//意向司机
|
|
|
69
|
+ $route_id = $this->request->param("route_id");//线路
|
|
|
70
|
+ $car_id = $this->request->param("car_id");//车辆
|
|
|
71
|
+ if($number<=0){
|
|
|
72
|
+ $this->error("人数错误");
|
|
|
73
|
+ }
|
|
|
74
|
+ //查询线路
|
|
|
75
|
+ $route=Db::name("route")->where("id",$route_id)->find();
|
|
|
76
|
+ //查询车辆
|
|
|
77
|
+ $car=Db::name("car")->where("id",$car_id)->find();
|
|
|
78
|
+ //查询司机
|
|
|
79
|
+ $driver=Db::name("driver")->where("id",$car['driver_id'])->find();
|
|
|
80
|
+ $data=[
|
|
|
81
|
+ "order_no"=>getOrderSn(),
|
|
|
82
|
+ "price"=>bcmul($route['price'],$number,2),
|
|
|
83
|
+ "is_pay"=>"2",//未支付
|
|
|
84
|
+ "car_id"=>$car_id,
|
|
|
85
|
+ "user_id"=>$this->auth->id,
|
|
|
86
|
+ "phone"=>$phone,
|
|
|
87
|
+ "user_name"=>$user_name,
|
|
|
88
|
+ "driver_id"=>$driver['id'],
|
|
|
89
|
+ "driver_name"=>$driver['name'],
|
|
|
90
|
+ "create_time"=>time(),
|
|
|
91
|
+ "reservation_time"=>getOrderSn(),
|
|
|
92
|
+ "position"=>$position,
|
|
|
93
|
+ "lat"=>$lat,
|
|
|
94
|
+ "lng"=>$lng,
|
|
|
95
|
+ "number"=>$number,
|
|
|
96
|
+ "remarks"=>$remarks,
|
|
|
97
|
+ "intended_driver_id"=>$intended_driver_id,
|
|
|
98
|
+ ];
|
|
|
99
|
+ $res=Db::name("order")->insertGetId($data);
|
|
|
100
|
+ $userinfo = Db::name('user')
|
|
|
101
|
+ ->where(['id' => $this->auth->id])
|
|
|
102
|
+ ->field('id,wx_xcx_openid')
|
|
|
103
|
+ ->find();
|
|
|
104
|
+ $notifyURI = 'https://wyc.tenyes.cn/addons/epay/api/notifyx/type/wechat';
|
|
|
105
|
+ $params = [
|
|
|
106
|
+ 'amount' => $data['price'],
|
|
|
107
|
+ 'orderid' => $data['order_no'],
|
|
|
108
|
+ 'type' => 'wechat',
|
|
|
109
|
+ 'notifyurl' => $notifyURI,
|
|
|
110
|
+ 'method' => 'miniapp',
|
|
|
111
|
+ 'openid' => $userinfo['wx_xcx_openid'],
|
|
|
112
|
+ ];
|
|
|
113
|
+
|
|
|
114
|
+ $f = \addons\epay\library\Service::submitOrder($params);
|
|
|
115
|
+ print_r($f);return;
|
|
|
116
|
+
|
|
|
117
|
+ $this->success("请求成功",$res);
|
70
|
|
118
|
|
71
|
|
119
|
|
72
|
}
|
120
|
}
|