diff --git a/src/Command/UpdateUnacceptedJobOrdersCommand.php b/src/Command/UpdateUnacceptedJobOrdersCommand.php index b4bed2f3..0a863334 100644 --- a/src/Command/UpdateUnacceptedJobOrdersCommand.php +++ b/src/Command/UpdateUnacceptedJobOrdersCommand.php @@ -50,7 +50,7 @@ class UpdateUnacceptedJobOrdersCommand extends Command // since we need the actual job orders for mqtt events, we need to get the ids of the job orders // that will be updated - $query_sql = 'SELECT id, rider_id FROM job_order WHERE status = :current_status and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; + $query_sql = 'SELECT id FROM job_order WHERE status = :current_status and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout'; $query_stmt = $db->prepare($query_sql); $query_stmt->execute([ @@ -63,11 +63,9 @@ class UpdateUnacceptedJobOrdersCommand extends Command while ($row = $query_stmt->fetch(PDO::FETCH_NUM)) { // $row[0] is the jo id - // $row[1] is the rider id - // store the ids for now, until the jos have been updated + // store the ids for now for the event sending after update of JOs $requeued_jos[] = [ 'jo_id' => $row[0], - 'rider_id' => $row[1], ]; } @@ -90,15 +88,23 @@ class UpdateUnacceptedJobOrdersCommand extends Command $jo = $em->getRepository(JobOrder::class)->find($jo_id); if ($jo != null) { - $output->writeln($jo->getID()); + $output->writeln('Requeuing for rider assignmen ' . $jo->getID()); + $id = $jo->getID(); + // send notifications to rider app, telling rider that jo has been requeued - + $rider_payload = [ + 'event' => 'cancelled', + 'reason' => 'Reassigned', + 'jo_id' => $id, + ]; + $mclient->sendRiderEvent($jo, $rider_payload); - // send notification to mobile app for customer, telling customer that jo has been requeued - //$mobile_payload = [ - //]; - - //$mclient->sendEvent(); + // send outlet assign since order should go back to hub and await reassignment to another rider + $payload = [ + 'event' => 'outlet_assign', + 'jo_id' => $id, + ]; + $mclient->sendEvent($jo, $payload); } } diff --git a/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php b/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php index 0b101a17..ddaf985e 100644 --- a/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php +++ b/src/Service/RiderAssignmentHandler/ResqRiderAssignmentHandler.php @@ -50,6 +50,8 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface // send push notification $this->aclient->sendPush($obj, "A RESQ rider is on his way to you."); + + $this->em->flush(); } }