...
|
...
|
@@ -40,6 +40,30 @@ class Car extends Base |
|
|
->group("start_time")
|
|
|
->select();
|
|
|
|
|
|
// 查询临时线路车次
|
|
|
|
|
|
$statr_time=strtotime(date("Y-m-d",time()));
|
|
|
$end_time=$statr_time+86400;
|
|
|
$temporary_route=Db::name("temporary_route")
|
|
|
->where("create_time",">",$statr_time)
|
|
|
->where("create_time","<",$end_time)
|
|
|
->where("route_id",$route_id)
|
|
|
->select();
|
|
|
|
|
|
$data=[];
|
|
|
foreach ($temporary_route as $k=>$v){
|
|
|
$data[]=Db::name("car")
|
|
|
->alias("a")
|
|
|
->join("route b","a.route_id=b.id")
|
|
|
->join("driver c","a.driver_id=c.id")
|
|
|
->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")
|
|
|
->where("route_id",$route_id)
|
|
|
->where("a.id",$temporary_route[$k]['car_id'])
|
|
|
->group("start_time")
|
|
|
->find();
|
|
|
}
|
|
|
$res=array_merge($data,$res);
|
|
|
|
|
|
$start_time=strtotime(date("Y-m-d",$time));
|
|
|
$end_time=$start_time+86400;
|
|
|
$newtime=time();
|
...
|
...
|
@@ -52,7 +76,7 @@ class Car extends Base |
|
|
->count();
|
|
|
|
|
|
}
|
|
|
return $this->success($res);
|
|
|
return $this->success("请求成功",$res);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -312,5 +336,37 @@ class Car extends Base |
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加临时车辆路线
|
|
|
* @return void
|
|
|
*/
|
|
|
public function addtemporaryroute(){
|
|
|
$user_id=$this->auth->id;
|
|
|
$driver=Db::name("driver")->where("user_id",$user_id)->find();
|
|
|
$car=Db::name("car")->where("driver_id",$driver['id'])->find();
|
|
|
$data=[
|
|
|
'user_id'=>$user_id,
|
|
|
'car_id'=>$car['id'],
|
|
|
'route_id'=>$car['route_id'],
|
|
|
'driver_id'=>$driver['id'],
|
|
|
'create_time'=>time(),
|
|
|
];
|
|
|
//判断是否重复
|
|
|
//开始时间
|
|
|
$statr_time=strtotime(date("Y-m-d",time()));
|
|
|
$end_time=$statr_time+86400;
|
|
|
$is_repeat=Db::name("temporary_route")
|
|
|
->where("user_id",$user_id)
|
|
|
->where("car_id",$car['id'])
|
|
|
->where("create_time",">",$statr_time)
|
|
|
->where("create_time","<",$end_time)
|
|
|
->where("driver_id",$driver['id'])
|
|
|
->find();
|
|
|
if($is_repeat){
|
|
|
return $this->error("添加失败");
|
|
|
}
|
|
|
$res=Db::name("temporary_route")->insert($data);
|
|
|
return $this->success("添加成功",$res);
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|