Resolve "Set distance limit in admin panel" #1530
6 changed files with 44 additions and 10 deletions
|
|
@ -70,8 +70,11 @@ INVENTORY_API_AUTH_TOKEN=insert_auth_token_here
|
||||||
# API logging
|
# API logging
|
||||||
API_LOGGING=set_to_true_or_false
|
API_LOGGING=set_to_true_or_false
|
||||||
|
|
||||||
# customer distance limit in km
|
# customer distance limit in km for mobile
|
||||||
CUST_DISTANCE_LIMIT=set_to_number
|
CUST_DISTANCE_LIMIT=5
|
||||||
|
|
||||||
|
# customer distance limit in km for admin panel
|
||||||
|
CUST_DISTANCE_LIMIT_ADMIN_PANEL=5
|
||||||
|
|
||||||
MAPTILER_API_KEY=map_tiler_api_key
|
MAPTILER_API_KEY=map_tiler_api_key
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,7 @@ services:
|
||||||
App\Service\JobOrderHandler\ResqJobOrderHandler:
|
App\Service\JobOrderHandler\ResqJobOrderHandler:
|
||||||
arguments:
|
arguments:
|
||||||
$country_code: "%env(COUNTRY_CODE)%"
|
$country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
$cust_distance_limit: "%env(CUST_DISTANCE_LIMIT_ADMIN_PANEL)%"
|
||||||
|
|
||||||
#job order generator interface
|
#job order generator interface
|
||||||
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
|
App\Service\JobOrderHandlerInterface: "@App\\Service\\JobOrderHandler\\ResqJobOrderHandler"
|
||||||
|
|
|
||||||
|
|
@ -1027,12 +1027,20 @@ class APIController extends Controller implements LoggedController
|
||||||
$hub_criteria = new HubCriteria();
|
$hub_criteria = new HubCriteria();
|
||||||
$hub_criteria->setPoint($jo->getCoordinates());
|
$hub_criteria->setPoint($jo->getCoordinates());
|
||||||
|
|
||||||
|
// get distance limit for mobile from env
|
||||||
|
$dotenv = new Dotenv();
|
||||||
|
$dotenv->loadEnv(__DIR__.'/../../.env');
|
||||||
|
$limit_distance = $_ENV['CUST_DISTANCE_LIMIT'];
|
||||||
|
|
||||||
|
// set distance limit
|
||||||
|
$hub_criteria->setLimitDistance($limit_distance);
|
||||||
|
|
||||||
if ($hub_geofence->isCovered($long, $lat))
|
if ($hub_geofence->isCovered($long, $lat))
|
||||||
{
|
{
|
||||||
// TODO: set this properly, since the other flags
|
// TODO: set this properly, since the other flags
|
||||||
// are on default values.
|
// are on default values.
|
||||||
// if true, set other values for HubCriteria
|
// if true, set other values for HubCriteria
|
||||||
// error_log('Area is covered by hub filtering');
|
error_log('Area is covered by hub filtering');
|
||||||
$hub_criteria->setJoType($jo->getServiceType())
|
$hub_criteria->setJoType($jo->getServiceType())
|
||||||
->setPaymentMethod($jo->getModeOfPayment())
|
->setPaymentMethod($jo->getModeOfPayment())
|
||||||
->setRoundRobin(true);
|
->setRoundRobin(true);
|
||||||
|
|
@ -1096,7 +1104,7 @@ class APIController extends Controller implements LoggedController
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// log hub into hub_filter_log
|
// log hub into hub_filter_log
|
||||||
$hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider');
|
$hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider', null, $cust->getID());
|
||||||
// continue to go through list to find hub with an available rider
|
// continue to go through list to find hub with an available rider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2758,12 +2766,20 @@ class APIController extends Controller implements LoggedController
|
||||||
$hub_criteria = new HubCriteria();
|
$hub_criteria = new HubCriteria();
|
||||||
$hub_criteria->setPoint($jo->getCoordinates());
|
$hub_criteria->setPoint($jo->getCoordinates());
|
||||||
|
|
||||||
|
// get distance limit for mobile from env
|
||||||
|
$dotenv = new Dotenv();
|
||||||
|
$dotenv->loadEnv(__DIR__.'/../../.env');
|
||||||
|
$limit_distance = $_ENV['CUST_DISTANCE_LIMIT'];
|
||||||
|
|
||||||
|
// set distance limit
|
||||||
|
$hub_criteria->setLimitDistance($limit_distance);
|
||||||
|
|
||||||
if ($hub_geofence->isCovered($long, $lat))
|
if ($hub_geofence->isCovered($long, $lat))
|
||||||
{
|
{
|
||||||
// if true, set other values for HubCriteria
|
// if true, set other values for HubCriteria
|
||||||
// TODO: set this properly, since the other flags
|
// TODO: set this properly, since the other flags
|
||||||
// are on default values
|
// are on default values
|
||||||
// error_log('Area is covered by hub filtering');
|
error_log('Area is covered by hub filtering');
|
||||||
$hub_criteria->setJoType($jo->getServiceType())
|
$hub_criteria->setJoType($jo->getServiceType())
|
||||||
->setPaymentMethod($jo->getModeOfPayment())
|
->setPaymentMethod($jo->getModeOfPayment())
|
||||||
->setRoundRobin(true);
|
->setRoundRobin(true);
|
||||||
|
|
@ -2827,7 +2843,7 @@ class APIController extends Controller implements LoggedController
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// log hub into hub_filter_log
|
// log hub into hub_filter_log
|
||||||
$hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider');
|
$hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider', null, $cust->getID());
|
||||||
// continue to go through list to find hub with an available rider
|
// continue to go through list to find hub with an available rider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ class HubDistributor
|
||||||
return 1;
|
return 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
error_log('arranged hubs ' . json_encode($arranged_hubs));
|
// error_log('arranged hubs ' . json_encode($arranged_hubs));
|
||||||
|
|
||||||
return $arranged_hubs;
|
return $arranged_hubs;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,10 @@ class HubSelector
|
||||||
|
|
||||||
$results = [];
|
$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
|
// get all the hubs within distance
|
||||||
$filtered_hubs = $this->getClosestHubs($point, $limit_distance, $jo_id, $customer_id);
|
$filtered_hubs = $this->getClosestHubs($point, $limit_distance, $jo_id, $customer_id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
protected $promo_logger;
|
protected $promo_logger;
|
||||||
protected $hub_dist;
|
protected $hub_dist;
|
||||||
protected $hub_geofence;
|
protected $hub_geofence;
|
||||||
|
protected $cust_distance_limit;
|
||||||
|
|
||||||
protected $template_hash;
|
protected $template_hash;
|
||||||
|
|
||||||
|
|
@ -87,7 +88,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
|
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
|
||||||
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)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->ic = $ic;
|
$this->ic = $ic;
|
||||||
|
|
@ -101,6 +103,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$this->promo_logger = $promo_logger;
|
$this->promo_logger = $promo_logger;
|
||||||
$this->hub_dist = $hub_dist;
|
$this->hub_dist = $hub_dist;
|
||||||
$this->hub_geofence = $hub_geofence;
|
$this->hub_geofence = $hub_geofence;
|
||||||
|
$this->cust_distance_limit = $cust_distance_limit;
|
||||||
|
|
||||||
$this->loadTemplates();
|
$this->loadTemplates();
|
||||||
}
|
}
|
||||||
|
|
@ -1979,6 +1982,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
$long = $obj->getCoordinates()->getLongitude();
|
$long = $obj->getCoordinates()->getLongitude();
|
||||||
$lat = $obj->getCoordinates()->getLatitude();
|
$lat = $obj->getCoordinates()->getLatitude();
|
||||||
|
|
||||||
|
// set result limit and location
|
||||||
$hub_criteria->setPoint($obj->getCoordinates())
|
$hub_criteria->setPoint($obj->getCoordinates())
|
||||||
->setLimitResults(50);
|
->setLimitResults(50);
|
||||||
|
|
||||||
|
|
@ -1986,7 +1990,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
{
|
{
|
||||||
// if true, set other values for HubCriteria
|
// if true, set other values for HubCriteria
|
||||||
error_log('Area is covered by hub filtering');
|
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())
|
->setJoType($obj->getServiceType())
|
||||||
->setRoundRobin(true);
|
->setRoundRobin(true);
|
||||||
}
|
}
|
||||||
|
|
@ -1994,7 +1999,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
// check if emergency or not
|
// check if emergency or not
|
||||||
$willing_to_wait = $obj->getWillWait();
|
$willing_to_wait = $obj->getWillWait();
|
||||||
if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT)
|
if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT)
|
||||||
|
{
|
||||||
|
// reset distance limit if emergency
|
||||||
|
$hub_criteria->setLimitDistance(500);
|
||||||
$hub_criteria->setEmergency(true);
|
$hub_criteria->setEmergency(true);
|
||||||
|
}
|
||||||
|
|
||||||
// get JO and customer id for logging purposes
|
// get JO and customer id for logging purposes
|
||||||
$jo_id = $obj->getID();
|
$jo_id = $obj->getID();
|
||||||
|
|
@ -2292,7 +2301,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
{
|
{
|
||||||
// if true, set other values for HubCriteria
|
// if true, set other values for HubCriteria
|
||||||
// error_log('Area is covered by hub');
|
// 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())
|
->setJoType($obj->getServiceType())
|
||||||
->setRoundRobin(true);
|
->setRoundRobin(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue