Add getHeaderCoordinates to rider api. #424
This commit is contained in:
parent
232ebfe3fc
commit
eadcd4604a
1 changed files with 105 additions and 3 deletions
|
|
@ -98,6 +98,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// retry until we get a unique id
|
// retry until we get a unique id
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
|
@ -191,6 +195,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// assign rider to session
|
// assign rider to session
|
||||||
$this->session->setRider($rider);
|
$this->session->setRider($rider);
|
||||||
|
|
||||||
|
|
@ -248,6 +256,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// make rider unavailable
|
// make rider unavailable
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
|
|
||||||
|
|
@ -288,6 +300,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// set rider to available to take on JOs
|
// set rider to available to take on JOs
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
|
|
||||||
|
|
@ -322,6 +338,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// set rider to unavailable to take on JOs
|
// set rider to unavailable to take on JOs
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
|
|
||||||
|
|
@ -371,6 +391,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
|
|
||||||
// get JOs assigned to rider for the month given
|
// get JOs assigned to rider for the month given
|
||||||
|
|
@ -577,6 +601,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
|
|
||||||
$qb = $this->em->getRepository(JobOrder::class)->createQueryBuilder('j');
|
$qb = $this->em->getRepository(JobOrder::class)->createQueryBuilder('j');
|
||||||
|
|
@ -906,6 +934,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$jo_data = $this->formatJobOrderData($req, $jo);
|
$jo_data = $this->formatJobOrderData($req, $jo);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
|
@ -927,6 +959,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// TODO: put JO in job queue
|
// TODO: put JO in job queue
|
||||||
|
|
||||||
// TODO: refactor this into a jo handler class, so we don't have to repeat for control center
|
// TODO: refactor this into a jo handler class, so we don't have to repeat for control center
|
||||||
|
|
@ -955,12 +991,13 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// set jo status to in transit
|
// set jo status to in transit
|
||||||
$jo->setStatus(JOStatus::IN_TRANSIT);
|
$jo->setStatus(JOStatus::IN_TRANSIT);
|
||||||
|
|
||||||
// set rider's active JO
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: send mqtt event (?)
|
// TODO: send mqtt event (?)
|
||||||
|
|
||||||
// add event log
|
// add event log
|
||||||
|
|
@ -991,6 +1028,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$cancel_reason = $req->request->get('cancel_reason');
|
$cancel_reason = $req->request->get('cancel_reason');
|
||||||
|
|
||||||
$jo->cancel($cancel_reason);
|
$jo->cancel($cancel_reason);
|
||||||
|
|
@ -1022,6 +1063,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$jo->perform();
|
$jo->perform();
|
||||||
|
|
||||||
// add event log
|
// add event log
|
||||||
|
|
@ -1050,6 +1095,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$jo->requeue();
|
$jo->requeue();
|
||||||
|
|
||||||
// set rider to null
|
// set rider to null
|
||||||
|
|
@ -1096,6 +1145,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// TODO: refactor this into a jo handler class, so we don't have to repeat for control center
|
// TODO: refactor this into a jo handler class, so we don't have to repeat for control center
|
||||||
|
|
||||||
// set jo status to in progress
|
// set jo status to in progress
|
||||||
|
|
@ -1168,6 +1221,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// add mode of payment
|
// add mode of payment
|
||||||
$mode = $req->request->get('mode_of_payment');
|
$mode = $req->request->get('mode_of_payment');
|
||||||
$jo->setModeOfPayment($mode);
|
$jo->setModeOfPayment($mode);
|
||||||
|
|
@ -1441,6 +1498,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$inv = $jo->getInvoice();
|
$inv = $jo->getInvoice();
|
||||||
$promo = $inv->getPromo();
|
$promo = $inv->getPromo();
|
||||||
|
|
||||||
|
|
@ -1514,6 +1575,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// set jo status to in progress
|
// set jo status to in progress
|
||||||
$jo->setStatus(JOStatus::IN_PROGRESS);
|
$jo->setStatus(JOStatus::IN_PROGRESS);
|
||||||
|
|
||||||
|
|
@ -1541,6 +1606,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
// set customer signature
|
// set customer signature
|
||||||
$jo_extra = $jo->getJOExtra();
|
$jo_extra = $jo->getJOExtra();
|
||||||
$sig_file = $this->handleFileUpload($req, 'signature');
|
$sig_file = $this->handleFileUpload($req, 'signature');
|
||||||
|
|
@ -1650,6 +1719,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
$rider->setActiveJobOrder($jo);
|
$rider->setActiveJobOrder($jo);
|
||||||
|
|
||||||
|
|
@ -1672,6 +1745,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$odometer_reading = $req->request->get('odometer');
|
$odometer_reading = $req->request->get('odometer');
|
||||||
|
|
||||||
if ($odometer_reading > 999999)
|
if ($odometer_reading > 999999)
|
||||||
|
|
@ -1728,6 +1805,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$dest = $this->upload_dir;
|
$dest = $this->upload_dir;
|
||||||
|
|
||||||
$img_1_file = $req->files->get('img_1');
|
$img_1_file = $req->files->get('img_1');
|
||||||
|
|
@ -1908,6 +1989,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
|
|
||||||
$rider_status = $rider->isAvailable();
|
$rider_status = $rider->isAvailable();
|
||||||
|
|
@ -1945,6 +2030,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
|
|
||||||
// check if we have an active JO
|
// check if we have an active JO
|
||||||
|
|
@ -2026,6 +2115,10 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get longitude and latitude
|
||||||
|
// TODO: right now, we're just checking if we get the coordinates
|
||||||
|
$this->getHeaderCoordinates($req);
|
||||||
|
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
// check if rider is assigned to JO
|
// check if rider is assigned to JO
|
||||||
if ($jo->getRider() != null)
|
if ($jo->getRider() != null)
|
||||||
|
|
@ -2308,4 +2401,13 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
|
|
||||||
return $req->getScheme() . '://' . $req->getHttpHost() . $req->getBasePath() . '/uploads/jo_extra/' . $filename;
|
return $req->getScheme() . '://' . $req->getHttpHost() . $req->getBasePath() . '/uploads/jo_extra/' . $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getHeaderCoordinates(Request $req)
|
||||||
|
{
|
||||||
|
$x_lng = $req->headers->get('x-longitude');
|
||||||
|
$x_lat = $req->headers->get('x-latitude');
|
||||||
|
|
||||||
|
error_log('rider_longitude ' . $x_lng);
|
||||||
|
error_log('rider_latitude ' . $x_lat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue