diff --git a/.env.dist b/.env.dist index a0693430..1eaf2c17 100644 --- a/.env.dist +++ b/.env.dist @@ -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 diff --git a/config/services.yaml b/config/services.yaml index c4da052b..fe949b8f 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -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" diff --git a/src/Service/HubSelector.php b/src/Service/HubSelector.php index b414e59c..ac84b82d 100644 --- a/src/Service/HubSelector.php +++ b/src/Service/HubSelector.php @@ -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); diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index be3a4564..e7ebf594 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -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); }