Add calls to send job order id and status to DriveHub when a third party JO changes JO status. #722
This commit is contained in:
parent
ae8b7be04b
commit
b2bc22a54f
7 changed files with 265 additions and 27 deletions
|
|
@ -16,15 +16,19 @@ use App\Entity\User;
|
||||||
use App\Ramcar\JOStatus;
|
use App\Ramcar\JOStatus;
|
||||||
use App\Ramcar\JOEventType;
|
use App\Ramcar\JOEventType;
|
||||||
|
|
||||||
|
use App\Service\DriveHubManager;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
class FulfillOldJobOrderCommand extends Command
|
class FulfillOldJobOrderCommand extends Command
|
||||||
{
|
{
|
||||||
protected $em;
|
protected $em;
|
||||||
|
protected $dh_manager;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em)
|
public function __construct(EntityManagerInterface $em, DriveHubManager $dh_manager)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
|
$this->dh_manager = $dh_manager;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
@ -67,12 +71,23 @@ class FulfillOldJobOrderCommand extends Command
|
||||||
$jo->fulfill();
|
$jo->fulfill();
|
||||||
|
|
||||||
// add event
|
// add event
|
||||||
$event = new JOEvent();
|
$event = new JOEvent();
|
||||||
$event->setDateHappen(new DateTime())
|
$event->setDateHappen(new DateTime())
|
||||||
->setTypeID(JOEventType::FULFILL)
|
->setTypeID(JOEventType::FULFILL)
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setJobOrder($jo);
|
->setJobOrder($jo);
|
||||||
$em->persist($event);
|
$em->persist($event);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($jo->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $jo->getID(),
|
||||||
|
'status_name' => $jo->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ use App\Ramcar\WarrantyClass;
|
||||||
use App\Ramcar\ServiceType;
|
use App\Ramcar\ServiceType;
|
||||||
use App\Ramcar\WarrantySource;
|
use App\Ramcar\WarrantySource;
|
||||||
use App\Ramcar\WarrantyStatus;
|
use App\Ramcar\WarrantyStatus;
|
||||||
|
use App\Ramcar\TransactionOrigin;
|
||||||
|
|
||||||
|
use App\Service\DriveHubManager;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
|
|
@ -34,10 +37,12 @@ class FulfillOpenJobOrderCommand extends Command
|
||||||
protected $em;
|
protected $em;
|
||||||
protected $batt_hash;
|
protected $batt_hash;
|
||||||
protected $sap_batt_hash;
|
protected $sap_batt_hash;
|
||||||
|
protected $dh_manager;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em)
|
public function __construct(EntityManagerInterface $em, DriveHubManager $dh_manager)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
|
$this->dh_manager = $dh_manager;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +81,7 @@ class FulfillOpenJobOrderCommand extends Command
|
||||||
$conn = $this->em->getConnection();
|
$conn = $this->em->getConnection();
|
||||||
|
|
||||||
$jo_sql = 'SELECT jo.id AS jo_id, c.id AS c_id, cv.id AS cv_id,
|
$jo_sql = 'SELECT jo.id AS jo_id, c.id AS c_id, cv.id AS cv_id,
|
||||||
jo.service_type, jo.warranty_class, jo.rider_id, jo.date_schedule
|
jo.service_type, jo.warranty_class, jo.rider_id, jo.date_schedule, jo.source
|
||||||
FROM job_order jo, customer c, customer_vehicle cv
|
FROM job_order jo, customer c, customer_vehicle cv
|
||||||
WHERE jo.customer_id = c.id AND jo.cvehicle_id = cv.id
|
WHERE jo.customer_id = c.id AND jo.cvehicle_id = cv.id
|
||||||
AND jo.status IN (\'pending\', \'rider_assign\', \'assigned\', \'in_transit\', \'in_progress\')
|
AND jo.status IN (\'pending\', \'rider_assign\', \'assigned\', \'in_transit\', \'in_progress\')
|
||||||
|
|
@ -107,6 +112,7 @@ class FulfillOpenJobOrderCommand extends Command
|
||||||
$warranty_class = $jo_row['warranty_class'];
|
$warranty_class = $jo_row['warranty_class'];
|
||||||
$rider_id = $jo_row['rider_id'];
|
$rider_id = $jo_row['rider_id'];
|
||||||
$str_date_schedule = $jo_row['date_schedule'];
|
$str_date_schedule = $jo_row['date_schedule'];
|
||||||
|
$source = $jo_row['source'];
|
||||||
|
|
||||||
$jo_ctr++;
|
$jo_ctr++;
|
||||||
|
|
||||||
|
|
@ -116,6 +122,9 @@ class FulfillOpenJobOrderCommand extends Command
|
||||||
// create JO event
|
// create JO event
|
||||||
$jo_evt_data[] = $this->createJOEvent($conn, $jo_id, $str_current_date, $rider_id);
|
$jo_evt_data[] = $this->createJOEvent($conn, $jo_id, $str_current_date, $rider_id);
|
||||||
|
|
||||||
|
// send to drivehub if JO is third party
|
||||||
|
$this->sendJOStatus($jo_id, $source);
|
||||||
|
|
||||||
// error_log($jo_ctr . ' Processing JO ' . $jo_id);
|
// error_log($jo_ctr . ' Processing JO ' . $jo_id);
|
||||||
|
|
||||||
// check service type
|
// check service type
|
||||||
|
|
@ -378,6 +387,20 @@ class FulfillOpenJobOrderCommand extends Command
|
||||||
// TODO: delete file?
|
// TODO: delete file?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function sendJOStatus($jo_id, $source)
|
||||||
|
{
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($source == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $jo_id,
|
||||||
|
'status_name' => JOStatus::FULFILLED,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function getCustomerInfo($conn, $id)
|
protected function getCustomerInfo($conn, $id)
|
||||||
{
|
{
|
||||||
$cust_info = [];
|
$cust_info = [];
|
||||||
|
|
|
||||||
|
|
@ -16,15 +16,19 @@ use App\Entity\User;
|
||||||
use App\Ramcar\JOStatus;
|
use App\Ramcar\JOStatus;
|
||||||
use App\Ramcar\JOEventType;
|
use App\Ramcar\JOEventType;
|
||||||
|
|
||||||
|
use App\Service\DriveHubManager;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
class FulfillPendingJobOrderCommand extends Command
|
class FulfillPendingJobOrderCommand extends Command
|
||||||
{
|
{
|
||||||
protected $em;
|
protected $em;
|
||||||
|
protected $dh_manager;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em)
|
public function __construct(EntityManagerInterface $em, DriveHubManager $dh_manager)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
|
$this->dh_manager = $dh_manager;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
@ -70,12 +74,23 @@ class FulfillPendingJobOrderCommand extends Command
|
||||||
$jo->fulfill();
|
$jo->fulfill();
|
||||||
|
|
||||||
// add event
|
// add event
|
||||||
$event = new JOEvent();
|
$event = new JOEvent();
|
||||||
$event->setDateHappen(new DateTime())
|
$event->setDateHappen(new DateTime())
|
||||||
->setTypeID(JOEventType::FULFILL)
|
->setTypeID(JOEventType::FULFILL)
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setJobOrder($jo);
|
->setJobOrder($jo);
|
||||||
$em->persist($event);
|
$em->persist($event);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($jo->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $jo->getID(),
|
||||||
|
'status_name' => $jo->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
use App\Service\MQTTClient;
|
use App\Service\MQTTClient;
|
||||||
|
use App\Service\DriveHubManager;
|
||||||
|
|
||||||
|
use App\Ramcar\TransactionOrigin;
|
||||||
|
|
||||||
use App\Entity\JobOrder;
|
use App\Entity\JobOrder;
|
||||||
use App\Entity\Rider;
|
use App\Entity\Rider;
|
||||||
|
|
@ -20,11 +23,13 @@ class UpdateUnacceptedJobOrdersCommand extends Command
|
||||||
{
|
{
|
||||||
protected $em;
|
protected $em;
|
||||||
protected $mclient;
|
protected $mclient;
|
||||||
|
protected $dh_manager;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, MQTTClient $mclient)
|
public function __construct(EntityManagerInterface $em, MQTTClient $mclient, DriveHubManager $dh_manager)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->mclient = $mclient;
|
$this->mclient = $mclient;
|
||||||
|
$this->dh_manager = $dh_manager;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
@ -49,10 +54,11 @@ class UpdateUnacceptedJobOrdersCommand extends Command
|
||||||
// pdo connection
|
// pdo connection
|
||||||
$db = $em->getConnection();
|
$db = $em->getConnection();
|
||||||
|
|
||||||
// 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
|
||||||
// that will be updated
|
// (1) need to get the ids of the job orders that will be updated
|
||||||
// need rider id to set rider to available since rider becomes unavailable
|
// (2) need rider id to set rider to available since rider becomes unavailable
|
||||||
// the minute JO is assigned to rider
|
// the minute JO is assigned to rider
|
||||||
|
// (3) need to get the source of the JO to check if it's a third party JO
|
||||||
$query_sql = 'SELECT 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);
|
||||||
|
|
@ -109,6 +115,18 @@ class UpdateUnacceptedJobOrdersCommand extends Command
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
// use new_status since the jo that we have doesn't have the updated status
|
||||||
|
if ($jo->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $jo->getID(),
|
||||||
|
'status_name' => $new_status,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
|
||||||
$rider = $jo->getRider();
|
$rider = $jo->getRider();
|
||||||
if ($rider != null)
|
if ($rider != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ use App\Service\JobOrderHandlerInterface;
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
use App\Service\RisingTideGateway;
|
use App\Service\RisingTideGateway;
|
||||||
use App\Service\RiderTracker;
|
use App\Service\RiderTracker;
|
||||||
|
use App\Service\DriveHubManager;
|
||||||
|
|
||||||
use App\Ramcar\ServiceType;
|
use App\Ramcar\ServiceType;
|
||||||
use App\Ramcar\TradeInType;
|
use App\Ramcar\TradeInType;
|
||||||
|
|
@ -42,6 +43,7 @@ use App\Ramcar\ModeOfPayment;
|
||||||
use App\Ramcar\InvoiceCriteria;
|
use App\Ramcar\InvoiceCriteria;
|
||||||
use App\Ramcar\WarrantySource;
|
use App\Ramcar\WarrantySource;
|
||||||
use App\Ramcar\DeliveryStatus;
|
use App\Ramcar\DeliveryStatus;
|
||||||
|
use App\Ramcar\TransactionOrigin;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
|
|
@ -388,7 +390,7 @@ class RiderAppController extends APIController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function acceptJobOrder(Request $req, EntityManagerInterface $em)
|
public function acceptJobOrder(Request $req, EntityManagerInterface $em, DriveHubManager $dh_manager)
|
||||||
{
|
{
|
||||||
$required_params = ['jo_id'];
|
$required_params = ['jo_id'];
|
||||||
|
|
||||||
|
|
@ -432,12 +434,23 @@ class RiderAppController extends APIController
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($jo->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $jo->getID(),
|
||||||
|
'status_name' => $jo->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
return new APIResponse(true, 'Job order accepted.', $data);
|
return new APIResponse(true, 'Job order accepted.', $data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancelJobOrder(Request $req, EntityManagerInterface $em, MQTTClient $mclient)
|
public function cancelJobOrder(Request $req, EntityManagerInterface $em, MQTTClient $mclient, DriveHubManager $dh_manager)
|
||||||
{
|
{
|
||||||
$required_params = ['jo_id'];
|
$required_params = ['jo_id'];
|
||||||
|
|
||||||
|
|
@ -483,6 +496,17 @@ class RiderAppController extends APIController
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($jo->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $jo->getID(),
|
||||||
|
'status_name' => $jo->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
return new APIResponse(true, 'Job order requeued.', $data);
|
return new APIResponse(true, 'Job order requeued.', $data);
|
||||||
}
|
}
|
||||||
|
|
@ -648,7 +672,7 @@ class RiderAppController extends APIController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function arrive(Request $req, EntityManagerInterface $em, MQTTClient $mclient)
|
public function arrive(Request $req, EntityManagerInterface $em, MQTTClient $mclient, DriveHubManager $dh_manager)
|
||||||
{
|
{
|
||||||
$required_params = ['jo_id'];
|
$required_params = ['jo_id'];
|
||||||
|
|
||||||
|
|
@ -698,6 +722,17 @@ class RiderAppController extends APIController
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($jo->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $jo->getID(),
|
||||||
|
'status_name' => $jo->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
return new APIResponse(true, 'Rider arrived at customer location.', $data);
|
return new APIResponse(true, 'Rider arrived at customer location.', $data);
|
||||||
}
|
}
|
||||||
|
|
@ -749,7 +784,8 @@ class RiderAppController extends APIController
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payment(Request $req, EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler,
|
public function payment(Request $req, EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler,
|
||||||
RisingTideGateway $rt, WarrantyHandler $wh, MQTTClient $mclient, TranslatorInterface $translator)
|
RisingTideGateway $rt, WarrantyHandler $wh, MQTTClient $mclient, TranslatorInterface $translator,
|
||||||
|
DriveHubManager $dh_manager)
|
||||||
{
|
{
|
||||||
$required_params = ['jo_id'];
|
$required_params = ['jo_id'];
|
||||||
|
|
||||||
|
|
@ -871,6 +907,17 @@ class RiderAppController extends APIController
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($jo->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $jo->getID(),
|
||||||
|
'status_name' => $jo->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
return new APIResponse(true, 'Job order paid and fulfilled.', $data);
|
return new APIResponse(true, 'Job order paid and fulfilled.', $data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,36 @@ class DriveHubManager
|
||||||
$this->callback_url = $callback_url;
|
$this->callback_url = $callback_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendJOStatusChange()
|
public function sendJOStatusChange($jo_data)
|
||||||
{
|
{
|
||||||
|
// jo_info = [
|
||||||
|
// 'id' => jo_id,
|
||||||
|
// 'status_id' => jo status id, --> for resq2
|
||||||
|
// 'status_name' => jo status name,
|
||||||
|
// ]
|
||||||
|
|
||||||
|
$body = json_encode($jo_data);
|
||||||
|
|
||||||
// send status back to callback url as POST in json format
|
// send status back to callback url as POST in json format
|
||||||
|
|
||||||
|
$curl = curl_init();
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
CURLOPT_URL => $this->callback_url,
|
||||||
|
CURLOPT_POST => true,
|
||||||
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
|
CURLOPT_POSTFIELDS => $body,
|
||||||
|
CURLOPT_HTTPHEADER => [
|
||||||
|
'Content-Type: application/json',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
curl_setopt_array($curl, $options);
|
||||||
|
$res = curl_exec($curl);
|
||||||
|
|
||||||
|
curl_close($curl);
|
||||||
|
|
||||||
|
// check result
|
||||||
|
// error_log('Result ' . $res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ use App\Service\PromoLogger;
|
||||||
use App\Service\HubSelector;
|
use App\Service\HubSelector;
|
||||||
use App\Service\HubDistributor;
|
use App\Service\HubDistributor;
|
||||||
use App\Service\HubFilteringGeoChecker;
|
use App\Service\HubFilteringGeoChecker;
|
||||||
|
use App\Service\DriveHubManager;
|
||||||
|
|
||||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||||
|
|
||||||
|
|
@ -90,6 +91,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
protected $hub_geofence;
|
protected $hub_geofence;
|
||||||
protected $cust_distance_limit;
|
protected $cust_distance_limit;
|
||||||
protected $hub_filter_enable;
|
protected $hub_filter_enable;
|
||||||
|
protected $dh_manager;
|
||||||
|
|
||||||
protected $template_hash;
|
protected $template_hash;
|
||||||
|
|
||||||
|
|
@ -98,7 +100,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
|
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
|
||||||
string $country_code, WarrantyHandler $wh, RisingTideGateway $rt,
|
string $country_code, WarrantyHandler $wh, RisingTideGateway $rt,
|
||||||
PromoLogger $promo_logger, HubDistributor $hub_dist, HubFilteringGeoChecker $hub_geofence,
|
PromoLogger $promo_logger, HubDistributor $hub_dist, HubFilteringGeoChecker $hub_geofence,
|
||||||
string $cust_distance_limit, string $hub_filter_enabled)
|
string $cust_distance_limit, string $hub_filter_enabled, DriveHubManager $dh_manager)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->ic = $ic;
|
$this->ic = $ic;
|
||||||
|
|
@ -114,6 +116,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$this->hub_geofence = $hub_geofence;
|
$this->hub_geofence = $hub_geofence;
|
||||||
$this->cust_distance_limit = $cust_distance_limit;
|
$this->cust_distance_limit = $cust_distance_limit;
|
||||||
$this->hub_filter_enabled = $hub_filter_enabled;
|
$this->hub_filter_enabled = $hub_filter_enabled;
|
||||||
|
$this->dh_manager = $dh_manager;
|
||||||
|
|
||||||
$this->loadTemplates();
|
$this->loadTemplates();
|
||||||
}
|
}
|
||||||
|
|
@ -984,6 +987,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
|
|
||||||
// update redis hub jo count
|
// update redis hub jo count
|
||||||
$this->hub_dist->incrementJoCountForHub($hub);
|
$this->hub_dist->incrementJoCountForHub($hub);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($obj->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $obj->getID(),
|
||||||
|
'status_name' => $obj->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error_array;
|
return $error_array;
|
||||||
|
|
@ -1140,6 +1154,18 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
|
|
||||||
// call rider assignment handler's assignJobOrder
|
// call rider assignment handler's assignJobOrder
|
||||||
$this->rah->assignJobOrder($obj, $rider);
|
$this->rah->assignJobOrder($obj, $rider);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($obj->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $obj->getID(),
|
||||||
|
'status_name' => $obj->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error_array;
|
return $error_array;
|
||||||
|
|
@ -1331,6 +1357,18 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$phone_number = $this->country_code . $obj->getCustomer()->getPhoneMobile();
|
$phone_number = $this->country_code . $obj->getCustomer()->getPhoneMobile();
|
||||||
if (!empty($phone_number))
|
if (!empty($phone_number))
|
||||||
$this->sendSMSToCustomer($phone_number);
|
$this->sendSMSToCustomer($phone_number);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($obj->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $obj->getID(),
|
||||||
|
'status_name' => $obj->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error_array;
|
return $error_array;
|
||||||
|
|
@ -1382,6 +1420,18 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
$mclient->sendRiderEvent($obj, $payload);
|
$mclient->sendRiderEvent($obj, $payload);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($obj->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $obj->getID(),
|
||||||
|
'status_name' => $obj->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set hub for job order
|
// set hub for job order
|
||||||
|
|
@ -1465,8 +1515,13 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
// get previously assigned rider, if any
|
// get previously assigned rider, if any
|
||||||
$old_rider = $obj->getRider();
|
$old_rider = $obj->getRider();
|
||||||
|
|
||||||
|
// get previous JO status, if any
|
||||||
|
// this will be used for third party JOs. If new JO status is same as old JO status,
|
||||||
|
// we don't tell drive hub.
|
||||||
|
$old_jo_status = $obj->getStatus();
|
||||||
|
|
||||||
if (empty($error_array))
|
if (empty($error_array))
|
||||||
{
|
{
|
||||||
// rider mqtt event
|
// rider mqtt event
|
||||||
// NOTE: need to send this before saving because rider will be cleared
|
// NOTE: need to send this before saving because rider will be cleared
|
||||||
$rider_payload = [
|
$rider_payload = [
|
||||||
|
|
@ -1566,6 +1621,22 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$this->hub_dist->decrementJoCountForHub($old_hub);
|
$this->hub_dist->decrementJoCountForHub($old_hub);
|
||||||
if ($hub != null)
|
if ($hub != null)
|
||||||
$this->hub_dist->incrementJoCountForHub($hub);
|
$this->hub_dist->incrementJoCountForHub($hub);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($obj->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
// check if the new status is the same as the old status
|
||||||
|
// if yes, we don't tell drive hub, otherwise, we send
|
||||||
|
if ($old_jo_status != $obj->getStatus())
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $obj->getID(),
|
||||||
|
'status_name' => $obj->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error_array;
|
return $error_array;
|
||||||
|
|
@ -1739,6 +1810,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$ownertype_id = $req->request->get('ownership_type', 0);
|
$ownertype_id = $req->request->get('ownership_type', 0);
|
||||||
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
|
$owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id);
|
||||||
|
|
||||||
|
// get previous JO status, if any
|
||||||
|
// this will be used for third party JOs. If new JO status is same as old JO status,
|
||||||
|
// we don't tell drive hub.
|
||||||
|
$old_jo_status = $obj->getStatus();
|
||||||
|
|
||||||
if (empty($error_array)) {
|
if (empty($error_array)) {
|
||||||
// rider mqtt event
|
// rider mqtt event
|
||||||
// NOTE: need to send this before saving because rider will be cleared
|
// NOTE: need to send this before saving because rider will be cleared
|
||||||
|
|
@ -1840,6 +1916,22 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($obj, $payload);
|
$mclient->sendEvent($obj, $payload);
|
||||||
$mclient->sendRiderEvent($obj, $payload);
|
$mclient->sendRiderEvent($obj, $payload);
|
||||||
|
|
||||||
|
// check if JO source is third party
|
||||||
|
if ($obj->getSource() == TransactionOrigin::THIRD_PARTY)
|
||||||
|
{
|
||||||
|
// check if the new status is the same as the old status
|
||||||
|
// if yes, we don't tell drive hub, otherwise, we send
|
||||||
|
if ($old_jo_status != $obj->getStatus())
|
||||||
|
{
|
||||||
|
$jo_status_data = [
|
||||||
|
'id' => $obj->getID(),
|
||||||
|
'status_name' => $obj->getStatus(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->dh_manager->sendJOStatusChange($jo_status_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $error_array;
|
return $error_array;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue