Add checking for customer pre-registered hub. #609
This commit is contained in:
parent
6f5c88dbdb
commit
b56754363e
1 changed files with 62 additions and 3 deletions
|
|
@ -2555,7 +2555,33 @@ class APIController extends Controller implements LoggedController
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
|
|
||||||
$coordinates = new Point($req->query->get('longitude'), $req->query->get('latitude'));
|
$coordinates = new Point($req->query->get('longitude'), $req->query->get('latitude'));
|
||||||
$nearest_hub_slots = $this->findAdvanceNearestHubAndSlots($coordinates, $em, $map_tools);
|
|
||||||
|
// add checking if customer has a pre-registered hub
|
||||||
|
$cust = $this->session->getCustomer();
|
||||||
|
if ($cust == null)
|
||||||
|
{
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage('No customer information found');
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if customer has customer tag promo
|
||||||
|
if (($cust->getCustomerTag('TAG_CAR_CLUB_OFFICER_PROMO')) ||
|
||||||
|
($cust->getCustomerTag('TAG_CAR_CLUB_MEMBER_PROMO')))
|
||||||
|
{
|
||||||
|
// if has customer tag, customer has not availed of promo, get the hub where customer is pre-registered
|
||||||
|
$car_club_cust_hub = $cust->getCarClubCustomerHub();
|
||||||
|
if ($car_club_cust_hub != null)
|
||||||
|
{
|
||||||
|
// need to get the rider slots for the pre-registered hub
|
||||||
|
$hub = $car_club_cust_hub->getHub();
|
||||||
|
$nearest_hub_slots = $this->findAdvanceNearestHubAndSlots($coordinates, $em, $map_tools, $hub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$nearest_hub_slots = $this->findAdvanceNearestHubAndSlots($coordinates, $em, $map_tools);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($nearest_hub_slots['hub']))
|
if (empty($nearest_hub_slots['hub']))
|
||||||
{
|
{
|
||||||
|
|
@ -3111,6 +3137,26 @@ class APIController extends Controller implements LoggedController
|
||||||
if (($hour < 8) || ($hour > 16))
|
if (($hour < 8) || ($hour > 16))
|
||||||
$schedule_choice = false;
|
$schedule_choice = false;
|
||||||
|
|
||||||
|
// add checking if customer has a pre-registered hub
|
||||||
|
$cust = $this->session->getCustomer();
|
||||||
|
if ($cust == null)
|
||||||
|
{
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage('No customer information found');
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
// check if customer has customer tag promo
|
||||||
|
if (($cust->getCustomerTag('TAG_CAR_CLUB_OFFICER_PROMO')) ||
|
||||||
|
($cust->getCustomerTag('TAG_CAR_CLUB_MEMBER_PROMO')))
|
||||||
|
{
|
||||||
|
// if has customer tag, customer has not availed of promo, get the hub where customer is pre-registered
|
||||||
|
$car_club_hub = $cust->getCarClubCustomerHub();
|
||||||
|
if ($car_club_hub != null)
|
||||||
|
{
|
||||||
|
$schedule_choice = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'display_schedule_choice' => $schedule_choice,
|
'display_schedule_choice' => $schedule_choice,
|
||||||
];
|
];
|
||||||
|
|
@ -3764,10 +3810,23 @@ class APIController extends Controller implements LoggedController
|
||||||
return $selected_rider;
|
return $selected_rider;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function findAdvanceNearestHubAndSlots(Point $coordinates, EntityManagerInterface $em, MapTools $map_tools)
|
protected function findAdvanceNearestHubAndSlots(Point $coordinates, EntityManagerInterface $em, MapTools $map_tools, $hub=null)
|
||||||
{
|
{
|
||||||
// get the nearest 10 hubs
|
|
||||||
$hub_data = [];
|
$hub_data = [];
|
||||||
|
|
||||||
|
if ($hub != null)
|
||||||
|
{
|
||||||
|
// get the slots of hub
|
||||||
|
$hub_slots = $this->getHubRiderSlots($hub, $em);
|
||||||
|
|
||||||
|
$hub_data = [
|
||||||
|
'hub' => $hub,
|
||||||
|
'slots' => $hub_slots,
|
||||||
|
];
|
||||||
|
return $hub_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the nearest 10 hubs
|
||||||
$nearest_hubs_with_distance = [];
|
$nearest_hubs_with_distance = [];
|
||||||
$hubs = $map_tools->getClosestOpenHubs($coordinates, 10);
|
$hubs = $map_tools->getClosestOpenHubs($coordinates, 10);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue