Add checking of flags for JO auto assignment. #607
This commit is contained in:
parent
49fdfa9ea6
commit
f54476a173
5 changed files with 76 additions and 42 deletions
|
|
@ -2816,6 +2816,14 @@ class APIController extends Controller implements LoggedController
|
||||||
// with an available rider
|
// with an available rider
|
||||||
// error_log('found nearest hub ' . $nearest_hub->getID());
|
// error_log('found nearest hub ' . $nearest_hub->getID());
|
||||||
foreach ($nearest_hubs as $nearest_hub)
|
foreach ($nearest_hubs as $nearest_hub)
|
||||||
|
{
|
||||||
|
// check if hub can be auto assigned
|
||||||
|
// if not, move on to the next hub in the list
|
||||||
|
if (($nearest_hub['hub']->isHubAutoAssign()))
|
||||||
|
{
|
||||||
|
// check if hub has riders that can be auto assigned
|
||||||
|
// if not, move on to the next hub
|
||||||
|
if (($nearest_hub['hub']->isRiderAutoAssign()))
|
||||||
{
|
{
|
||||||
$available_riders = $nearest_hub['hub']->getAvailableRiders();
|
$available_riders = $nearest_hub['hub']->getAvailableRiders();
|
||||||
if (count($available_riders) >= 1)
|
if (count($available_riders) >= 1)
|
||||||
|
|
@ -2854,11 +2862,35 @@ class APIController extends Controller implements LoggedController
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// we just create the JO and let admin panel handle the hub assignment
|
||||||
// log hub into hub_filter_log
|
// log hub into hub_filter_log
|
||||||
$hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider', null, $cust->getID());
|
$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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: log hub as cannot be auto rider assigned somewhere
|
||||||
|
// assign hub
|
||||||
|
error_log('Rider cannot be auto assigned ' . $nearest_hub['hub']->getID());
|
||||||
|
$jo->setHub($nearest_hub['hub']);
|
||||||
|
$jo->setStatus(JOStatus::RIDER_ASSIGN);
|
||||||
|
$jo->setStatusAutoAssign(AutoAssignStatus::HUB_ASSIGNED);
|
||||||
|
|
||||||
|
// update redis hub_jo_count for hub
|
||||||
|
$hub_dist->incrementJoCountForHub($nearest_hub['hub']);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: log hub as cannot be auto assigned somewhere
|
||||||
|
// move to next hub
|
||||||
|
error_log('Hub cannot be auto-assigned ' . $nearest_hub['hub']->getID());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -161,8 +161,8 @@ class HubController extends Controller
|
||||||
->setRiderSlots($req->request->get('rider_slots', 0))
|
->setRiderSlots($req->request->get('rider_slots', 0))
|
||||||
->setHubViewFlag($req->request->get('flag_hub_view', false))
|
->setHubViewFlag($req->request->get('flag_hub_view', false))
|
||||||
->setNotifNumber($req->request->get('notif_number'))
|
->setNotifNumber($req->request->get('notif_number'))
|
||||||
->setAutoAssignHub($req->request->get('flag_hub_auto_assign', false))
|
->setHubAutoAssign($req->request->get('flag_hub_auto_assign', false))
|
||||||
->setAutoAssignRider($req->request->get('flag_rider_auto_assign', false))
|
->setRiderAutoAssign($req->request->get('flag_rider_auto_assign', false))
|
||||||
->clearPaymentMethods();
|
->clearPaymentMethods();
|
||||||
|
|
||||||
// set payment methods
|
// set payment methods
|
||||||
|
|
|
||||||
|
|
@ -247,24 +247,24 @@ class Hub
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAutoAssignHub($flag_hub_auto_assign = true)
|
public function setHubAutoAssign($flag_hub_auto_assign = true)
|
||||||
{
|
{
|
||||||
$this->flag_hub_auto_assign = $flag_hub_auto_assign;
|
$this->flag_hub_auto_assign = $flag_hub_auto_assign;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAutoAssignHub()
|
public function isHubAutoAssign()
|
||||||
{
|
{
|
||||||
return $this->flag_hub_auto_assign;
|
return $this->flag_hub_auto_assign;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAutoAssignRider($flag_rider_auto_assign = true)
|
public function setRiderAutoAssign($flag_rider_auto_assign = true)
|
||||||
{
|
{
|
||||||
$this->flag_rider_auto_assign = $flag_rider_auto_assign;
|
$this->flag_rider_auto_assign = $flag_rider_auto_assign;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isAutoAssignRider()
|
public function isRiderAutoAssign()
|
||||||
{
|
{
|
||||||
return $this->flag_rider_auto_assign;
|
return $this->flag_rider_auto_assign;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,11 +154,13 @@ class MapTools
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: only the API calls this
|
// NOTE: only the API(findAdvanceNearestHubAndSlots) calls this
|
||||||
public function getClosestOpenHubs(Point $point, $limit, $time = false)
|
public function getClosestOpenHubs(Point $point, $limit, $time = false)
|
||||||
{
|
{
|
||||||
// get closest hubs based on st_distance function from db
|
// get closest hubs based on st_distance function from db
|
||||||
$query_string = 'SELECT h, st_distance(h.coordinates, point(:lng, :lat)) as dist FROM App\Entity\Hub h WHERE h.status_open = true';
|
$query_string = 'SELECT h, st_distance(h.coordinates, point(:lng, :lat)) as dist FROM App\Entity\Hub h
|
||||||
|
WHERE h.status_open = true
|
||||||
|
AND h.flag_hub_auto_assign = true';
|
||||||
if ($time)
|
if ($time)
|
||||||
$query_string .= ' AND :time BETWEEN h.time_open AND h.time_close';
|
$query_string .= ' AND :time BETWEEN h.time_open AND h.time_close';
|
||||||
$query_string .= ' ORDER BY dist';
|
$query_string .= ' ORDER BY dist';
|
||||||
|
|
|
||||||
|
|
@ -121,14 +121,14 @@
|
||||||
<div class="col-lg-3">
|
<div class="col-lg-3">
|
||||||
<span class="m-switch m-switch--icon block-switch">
|
<span class="m-switch m-switch--icon block-switch">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="flag_hub_auto_assign" id="status-open" value="1"{{ obj.isAutoAssignHub ? ' checked' }}>
|
<input type="checkbox" name="flag_hub_auto_assign" id="status-open" value="1"{{ obj.isHubAutoAssign ? ' checked' }}>
|
||||||
<label class="switch-label">Hub Auto-Assign</label>
|
<label class="switch-label">Hub Auto-Assign</label>
|
||||||
<span></span>
|
<span></span>
|
||||||
</label>
|
</label>
|
||||||
</span>
|
</span>
|
||||||
<span class="m-switch m-switch--icon block-switch">
|
<span class="m-switch m-switch--icon block-switch">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="flag_rider_auto_assign" id="status-open" value="1"{{ obj.isAutoAssignRider ? ' checked' }}>
|
<input type="checkbox" name="flag_rider_auto_assign" id="status-open" value="1"{{ obj.isRiderAutoAssign ? ' checked' }}>
|
||||||
<label class="switch-label">Rider Auto-Assign</label>
|
<label class="switch-label">Rider Auto-Assign</label>
|
||||||
<span></span>
|
<span></span>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue