Merge branch '162-phase-2-changes' into 'master'
Resolve "Phase 2 changes" Closes #162 See merge request jankstudio/resq!171
This commit is contained in:
commit
e638e63e81
2 changed files with 73 additions and 5 deletions
|
|
@ -1089,17 +1089,68 @@ class APIController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if we have an ongoing job order
|
// check if we have an ongoing job order
|
||||||
|
/*
|
||||||
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
||||||
'customer' => $cust,
|
'customer' => $cust,
|
||||||
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::IN_TRANSIT, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::IN_TRANSIT, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
||||||
]);
|
]);
|
||||||
|
*/
|
||||||
|
$ongoing_jos = $this->getOngoingJobOrders($cust);
|
||||||
|
|
||||||
// $res->setData(['here' => count($ongoing_jos)]);
|
// $res->setData(['here' => count($ongoing_jos)]);
|
||||||
// return $res->getReturnResponse();
|
// return $res->getReturnResponse();
|
||||||
if (count($ongoing_jos) <= 0)
|
if (count($ongoing_jos) <= 0)
|
||||||
{
|
{
|
||||||
// TODO: check if the latest jo they have needs rider rating
|
// check if the latest fulfilled jo they have needs rider rating
|
||||||
// $query = $em->createQuery('select
|
$query = $em->createQuery('select jo from App\Entity\JobOrder jo where jo.customer = :cust and jo.status = :status order by jo.date_fulfill desc');
|
||||||
|
$fulfill_jo = $query->setParameters([
|
||||||
|
'cust' => $cust,
|
||||||
|
'status' => JOStatus::FULFILLED,
|
||||||
|
])
|
||||||
|
->setMaxResults(1)
|
||||||
|
->getSingleResult();
|
||||||
|
|
||||||
|
// we got a recently fulfilled job order
|
||||||
|
if ($fulfill_jo)
|
||||||
|
{
|
||||||
|
// check if the rider has been rated
|
||||||
|
if (!$fulfill_jo->hasRiderRating())
|
||||||
|
{
|
||||||
|
$dest = $fulfill_jo->getCoordinates();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'jo_id' => $fulfill_jo->getID(),
|
||||||
|
'service_type' => $fulfill_jo->getServiceType(),
|
||||||
|
'destination' => [
|
||||||
|
'long' => $dest->getLongitude(),
|
||||||
|
'lat' => $dest->getLatitude(),
|
||||||
|
],
|
||||||
|
'delivery_address' => $fulfill_jo->getDeliveryAddress(),
|
||||||
|
'delivery_instructions' => $fulfill_jo->getDeliveryInstructions(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$rider = $fulfill_jo->getRider();
|
||||||
|
|
||||||
|
// default image url
|
||||||
|
$url_prefix = $req->getSchemeAndHttpHost();
|
||||||
|
$image_url = $url_prefix . '/assets/images/user.gif';
|
||||||
|
if ($rider->getImageFile() != null)
|
||||||
|
$image_url = $url_prefix . '/uploads/' . $rider->getImageFile();
|
||||||
|
|
||||||
|
$data['status'] = APIRiderStatus::RIDER_RATING;
|
||||||
|
// default rider location to hub
|
||||||
|
$data['rider'] = [
|
||||||
|
'id' => $rider->getID(),
|
||||||
|
'name' => $rider->getFullName(),
|
||||||
|
'plate_num' => $rider->getPlateNumber(),
|
||||||
|
'contact_num' => $rider->getContactNumber(),
|
||||||
|
'image_url' => $image_url,
|
||||||
|
];
|
||||||
|
$res->setData($data);
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// no pending
|
// no pending
|
||||||
$res->setData([
|
$res->setData([
|
||||||
|
|
@ -1171,6 +1222,17 @@ class APIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getOngoingJobOrders($cust)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
||||||
|
'customer' => $cust,
|
||||||
|
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::IN_TRANSIT, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $ongoing_jos;
|
||||||
|
}
|
||||||
|
|
||||||
public function getOngoing(Request $req)
|
public function getOngoing(Request $req)
|
||||||
{
|
{
|
||||||
$required_params = [];
|
$required_params = [];
|
||||||
|
|
@ -1188,11 +1250,14 @@ class APIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// check if we have an ongoing job order
|
// check if we have an ongoing job order
|
||||||
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
$ongoing_jos = $em->getRepository(JobOrder::class)->findBy([
|
||||||
'customer' => $cust,
|
'customer' => $cust,
|
||||||
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::IN_TRANSIT, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
||||||
]);
|
]);
|
||||||
|
*/
|
||||||
|
$ongoing_jos = $this->getOngoingJobOrders($cust);
|
||||||
|
|
||||||
// initialize data
|
// initialize data
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
@ -1279,6 +1344,9 @@ class APIController extends Controller
|
||||||
if (!empty($comment))
|
if (!empty($comment))
|
||||||
$rating->setComment($comment);
|
$rating->setComment($comment);
|
||||||
|
|
||||||
|
// mark jo as rider rated already
|
||||||
|
$jo->setHasRiderRating();
|
||||||
|
|
||||||
$em->persist($rating);
|
$em->persist($rating);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
|
|
@ -1458,7 +1526,7 @@ class APIController extends Controller
|
||||||
'reason' => $cancel_reason,
|
'reason' => $cancel_reason,
|
||||||
'jo_id' => $jo->getID(),
|
'jo_id' => $jo->getID(),
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
// $mclient->sendEvent($jo, $payload);
|
||||||
$mclient->sendRiderEvent($jo, $payload);
|
$mclient->sendRiderEvent($jo, $payload);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -700,7 +700,7 @@ class JobOrder
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function HasRiderRating()
|
public function hasRiderRating()
|
||||||
{
|
{
|
||||||
if ($this->flag_rider_rating == null)
|
if ($this->flag_rider_rating == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue