Add index for status for job order. Add command to update the status and rider for unaccepted job orders. #630
This commit is contained in:
parent
94f2cc75a7
commit
0065bc94ef
3 changed files with 62 additions and 1 deletions
58
src/Command/UpdateUnacceptedJobOrdersCommand.php
Normal file
58
src/Command/UpdateUnacceptedJobOrdersCommand.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\JobOrder;
|
||||
|
||||
class UpdateUnacceptedJobOrdersCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('joborder:reassignunaccepted')
|
||||
->setDescription('Requeue for rider assignment assigned but unaccepted job orders that have been assigned for more than 3 mins.')
|
||||
->setHelp('Requeue for rider assignment assigned but unaccepted job orders that have been assigned for more than 3 mins.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
// TODO: get the timeout limit from .env
|
||||
$timeout = 3;
|
||||
|
||||
// pdo connection
|
||||
$db = $em->getConnection();
|
||||
|
||||
// update the assigned job orders and have been unaccepted for at least 3 minutes
|
||||
// change the jo status from assigned to rider_assign and rider id to null
|
||||
$sql = 'UPDATE job_order SET status=:jo_status, rider_id=null WHERE status=\'assigned\' and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout';
|
||||
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute([
|
||||
'jo_status' => 'rider_assign',
|
||||
'timeout' => $timeout,
|
||||
]);
|
||||
|
||||
// send notifications to rider app, telling rider that jo has been requeued
|
||||
|
||||
// send notification to mobile app for customer, telling customer that jo has been requeued
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -2957,6 +2957,8 @@ class APIController extends Controller implements LoggedController
|
|||
$jo->setStatusAutoAssign(AutoAssignStatus::HUB_AND_RIDER_ASSIGNED);
|
||||
$jo->setDeliveryStatus(DeliveryStatus::RIDER_ASSIGN);
|
||||
|
||||
// TODO: set date_assigned for job order
|
||||
|
||||
$assigned_rider->setAvailable(false);
|
||||
|
||||
// set rider's current job order
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ use App\Ramcar\WillingToWaitContent;
|
|||
* @ORM\Index(name="plate_number_idx", columns={"plate_number"}),
|
||||
* @ORM\Index(name="first_name_idx", columns={"first_name"}),
|
||||
* @ORM\Index(name="last_name_idx", columns={"last_name"}),
|
||||
* @ORM\Index(name="phone_mobile_idx", columns={"phone_mobile"})
|
||||
* @ORM\Index(name="phone_mobile_idx", columns={"phone_mobile"}),
|
||||
* @ORM\Index(name="status_idx", columns={"status"}),
|
||||
* })
|
||||
*/
|
||||
class JobOrder
|
||||
|
|
|
|||
Loading…
Reference in a new issue