Add sending of mqtt events. #630
This commit is contained in:
parent
c2066b86c9
commit
d366106381
2 changed files with 19 additions and 11 deletions
|
|
@ -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
|
// since we need the actual job orders for mqtt events, we need to get the ids of the job orders
|
||||||
// that will be updated
|
// 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 = $db->prepare($query_sql);
|
||||||
$query_stmt->execute([
|
$query_stmt->execute([
|
||||||
|
|
@ -63,11 +63,9 @@ class UpdateUnacceptedJobOrdersCommand extends Command
|
||||||
while ($row = $query_stmt->fetch(PDO::FETCH_NUM))
|
while ($row = $query_stmt->fetch(PDO::FETCH_NUM))
|
||||||
{
|
{
|
||||||
// $row[0] is the jo id
|
// $row[0] is the jo id
|
||||||
// $row[1] is the rider id
|
// store the ids for now for the event sending after update of JOs
|
||||||
// store the ids for now, until the jos have been updated
|
|
||||||
$requeued_jos[] = [
|
$requeued_jos[] = [
|
||||||
'jo_id' => $row[0],
|
'jo_id' => $row[0],
|
||||||
'rider_id' => $row[1],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,15 +88,23 @@ class UpdateUnacceptedJobOrdersCommand extends Command
|
||||||
$jo = $em->getRepository(JobOrder::class)->find($jo_id);
|
$jo = $em->getRepository(JobOrder::class)->find($jo_id);
|
||||||
if ($jo != null)
|
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
|
// 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
|
// send outlet assign since order should go back to hub and await reassignment to another rider
|
||||||
//$mobile_payload = [
|
$payload = [
|
||||||
//];
|
'event' => 'outlet_assign',
|
||||||
|
'jo_id' => $id,
|
||||||
//$mclient->sendEvent();
|
];
|
||||||
|
$mclient->sendEvent($jo, $payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,8 @@ class ResqRiderAssignmentHandler implements RiderAssignmentHandlerInterface
|
||||||
|
|
||||||
// send push notification
|
// send push notification
|
||||||
$this->aclient->sendPush($obj, "A RESQ rider is on his way to you.");
|
$this->aclient->sendPush($obj, "A RESQ rider is on his way to you.");
|
||||||
|
|
||||||
|
$this->em->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue