Add customer distance limit to hub filtering in admin panel. #601

This commit is contained in:
Korina Cordero 2021-07-26 04:11:54 +00:00
parent 8fbfc1ebe7
commit 3a43cc14fb
4 changed files with 19 additions and 5 deletions

View file

@ -70,8 +70,11 @@ INVENTORY_API_AUTH_TOKEN=insert_auth_token_here
# API logging
API_LOGGING=set_to_true_or_false
# customer distance limit in km
CUST_DISTANCE_LIMIT=set_to_number
# customer distance limit in km for mobile
CUST_DISTANCE_LIMIT=5
# customer distance limit in km for admin panel
ADMIN_PANEL_CUST_DISTANCE_LIMIT=5
MAPTILER_API_KEY=map_tiler_api_key

View file

@ -170,6 +170,7 @@ services:
App\Service\JobOrderHandler\ResqJobOrderHandler:
arguments:
$country_code: "%env(COUNTRY_CODE)%"
$cust_distance_limit: "%env(ADMIN_PANEL_CUST_DISTANCE_LIMIT)%"
#job order generator interface
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"

View file

@ -56,6 +56,10 @@ class HubSelector
$results = [];
error_log('payment methods ' . $payment_method);
error_log('distance limit ' . $limit_distance);
error_log('emergency flag ' . $flag_emergency);
// get all the hubs within distance
$filtered_hubs = $this->getClosestHubs($point, $limit_distance, $jo_id, $customer_id);

View file

@ -80,6 +80,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
protected $promo_logger;
protected $hub_dist;
protected $hub_geofence;
protected $cust_distance_limit;
protected $template_hash;
@ -87,7 +88,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
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)
{
$this->em = $em;
$this->ic = $ic;
@ -101,6 +103,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$this->promo_logger = $promo_logger;
$this->hub_dist = $hub_dist;
$this->hub_geofence = $hub_geofence;
$this->cust_distance_limit = $cust_distance_limit;
$this->loadTemplates();
}
@ -1979,6 +1982,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$long = $obj->getCoordinates()->getLongitude();
$lat = $obj->getCoordinates()->getLatitude();
// set result limit and location
$hub_criteria->setPoint($obj->getCoordinates())
->setLimitResults(50);
@ -1986,7 +1990,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
{
// if true, set other values for HubCriteria
error_log('Area is covered by hub filtering');
$hub_criteria->setPaymentMethod($obj->getModeOfPayment())
$hub_criteria->setLimitDistance($this->cust_distance_limit)
->setPaymentMethod($obj->getModeOfPayment())
->setJoType($obj->getServiceType())
->setRoundRobin(true);
}
@ -2292,7 +2297,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
{
// if true, set other values for HubCriteria
// error_log('Area is covered by hub');
$hub_criteria->setPaymentMethod($obj->getModeOfPayment())
$hub_criteria->setLimitDistance($this->cust_distance_limit)
->setPaymentMethod($obj->getModeOfPayment())
->setJoType($obj->getServiceType())
->setRoundRobin(true);
}