Add emergency filter. #554
This commit is contained in:
parent
63b989034d
commit
140ea8c738
4 changed files with 73 additions and 24 deletions
|
|
@ -29,6 +29,7 @@ use App\Ramcar\JOEventType;
|
||||||
use App\Ramcar\AdvanceOrderSlot;
|
use App\Ramcar\AdvanceOrderSlot;
|
||||||
use App\Ramcar\AutoAssignStatus;
|
use App\Ramcar\AutoAssignStatus;
|
||||||
use App\Ramcar\HubCriteria;
|
use App\Ramcar\HubCriteria;
|
||||||
|
use App\Ramcar\WillingToWaitContent;
|
||||||
|
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
use App\Service\RisingTideGateway;
|
use App\Service\RisingTideGateway;
|
||||||
|
|
@ -922,6 +923,14 @@ class APIController extends Controller implements LoggedController
|
||||||
}
|
}
|
||||||
$jo->setServiceType($stype);
|
$jo->setServiceType($stype);
|
||||||
|
|
||||||
|
// check if willing to wait is true or not
|
||||||
|
$will_wait = $req->request->get('willing_to_wait');
|
||||||
|
// check for 'false' text
|
||||||
|
if ($will_wait === false || $will_wait === 0 || $will_wait === '0' || $will_wait == 'false')
|
||||||
|
$jo->setWillWait(WillingToWaitContent::NOT_WILLING_TO_WAIT);
|
||||||
|
else
|
||||||
|
$jo->setWillWait(WillingToWaitContent::WILLING_TO_WAIT);
|
||||||
|
|
||||||
// validate warranty
|
// validate warranty
|
||||||
$warr = $req->request->get('warranty');
|
$warr = $req->request->get('warranty');
|
||||||
if (!WarrantyClass::validate($warr))
|
if (!WarrantyClass::validate($warr))
|
||||||
|
|
@ -1030,6 +1039,12 @@ class APIController extends Controller implements LoggedController
|
||||||
if (!empty($jo->getModeOfPayment()))
|
if (!empty($jo->getModeOfPayment()))
|
||||||
$hub_criteria->setPaymentMethod($jo->getModeOfPayment());
|
$hub_criteria->setPaymentMethod($jo->getModeOfPayment());
|
||||||
|
|
||||||
|
// check if willing to wait is true or not
|
||||||
|
if ($jo->getWillWait() == WillingToWaitContent::NOT_WILLING_TO_WAIT)
|
||||||
|
{
|
||||||
|
$hub_criteria->setEmergency(true);
|
||||||
|
}
|
||||||
|
|
||||||
// find nearest hubs
|
// find nearest hubs
|
||||||
$nearest_hubs = $hub_select->find($hub_criteria);
|
$nearest_hubs = $hub_select->find($hub_criteria);
|
||||||
|
|
||||||
|
|
@ -2449,6 +2464,14 @@ class APIController extends Controller implements LoggedController
|
||||||
}
|
}
|
||||||
$jo->setServiceType($stype);
|
$jo->setServiceType($stype);
|
||||||
|
|
||||||
|
// check if willing to wait is true or not
|
||||||
|
$will_wait = $req->request->get('willing_to_wait');
|
||||||
|
// check for 'false' text
|
||||||
|
if ($will_wait === false || $will_wait === 0 || $will_wait === '0' || $will_wait == 'false')
|
||||||
|
$jo->setWillWait(WillingToWaitContent::NOT_WILLING_TO_WAIT);
|
||||||
|
else
|
||||||
|
$jo->setWillWait(WillingToWaitContent::WILLING_TO_WAIT);
|
||||||
|
|
||||||
// validate warranty
|
// validate warranty
|
||||||
$warr = $req->request->get('warranty');
|
$warr = $req->request->get('warranty');
|
||||||
if (!WarrantyClass::validate($warr))
|
if (!WarrantyClass::validate($warr))
|
||||||
|
|
@ -2560,6 +2583,12 @@ class APIController extends Controller implements LoggedController
|
||||||
if (!empty($jo->getModeOfPayment()))
|
if (!empty($jo->getModeOfPayment()))
|
||||||
$hub_criteria->setPaymentMethod($jo->getModeOfPayment());
|
$hub_criteria->setPaymentMethod($jo->getModeOfPayment());
|
||||||
|
|
||||||
|
// check if willing to wait is true or not
|
||||||
|
if ($jo->getWillWait() == WillingToWaitContent::NOT_WILLING_TO_WAIT)
|
||||||
|
{
|
||||||
|
$hub_criteria->setEmergency(true);
|
||||||
|
}
|
||||||
|
|
||||||
// find nearest hubs
|
// find nearest hubs
|
||||||
$nearest_hubs = $hub_select->find($hub_criteria);
|
$nearest_hubs = $hub_select->find($hub_criteria);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class HubCriteria
|
||||||
protected $date_time; // date and time to check if hub is open or not
|
protected $date_time; // date and time to check if hub is open or not
|
||||||
protected $items; // array of items: items[sku] = quantity to check for
|
protected $items; // array of items: items[sku] = quantity to check for
|
||||||
protected $payment_method; // payment method of JO
|
protected $payment_method; // payment method of JO
|
||||||
|
protected $flag_emergency; // flag if emergency or not
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
@ -27,6 +28,7 @@ class HubCriteria
|
||||||
$this->flag_inventory_check = false;
|
$this->flag_inventory_check = false;
|
||||||
$this->items = [];
|
$this->items = [];
|
||||||
$this->payment_method = '';
|
$this->payment_method = '';
|
||||||
|
$flag_emergency = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPoint(Point $point)
|
public function setPoint(Point $point)
|
||||||
|
|
@ -124,4 +126,15 @@ class HubCriteria
|
||||||
{
|
{
|
||||||
return $this->payment_method;
|
return $this->payment_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setEmergency($flag_emergency = true)
|
||||||
|
{
|
||||||
|
$this->flag_emergency = $flag_emergency;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isEmergency()
|
||||||
|
{
|
||||||
|
return $this->flag_emergency;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ class HubSelector
|
||||||
$items = $criteria->getItems();
|
$items = $criteria->getItems();
|
||||||
$date_time = $criteria->getDateTime();
|
$date_time = $criteria->getDateTime();
|
||||||
$payment_method = $criteria->getPaymentMethod();
|
$payment_method = $criteria->getPaymentMethod();
|
||||||
|
$flag_emergency = $criteria->isEmergency();
|
||||||
|
|
||||||
$results = [];
|
$results = [];
|
||||||
|
|
||||||
|
|
@ -57,6 +58,8 @@ class HubSelector
|
||||||
|
|
||||||
//error_log('closest hubs ' . json_encode($filtered_hubs));
|
//error_log('closest hubs ' . json_encode($filtered_hubs));
|
||||||
|
|
||||||
|
if (!$flag_emergency)
|
||||||
|
{
|
||||||
// filter the first hub results for date and opening times
|
// filter the first hub results for date and opening times
|
||||||
$hubs_date_time = $this->filterHubsByDateAndTime($filtered_hubs, $date_time);
|
$hubs_date_time = $this->filterHubsByDateAndTime($filtered_hubs, $date_time);
|
||||||
$filtered_hubs = $hubs_date_time;
|
$filtered_hubs = $hubs_date_time;
|
||||||
|
|
@ -85,6 +88,7 @@ class HubSelector
|
||||||
// max results filter
|
// max results filter
|
||||||
$hubs_max_result = $this->filterHubsByMaxResults($filtered_hubs, $limit_results);
|
$hubs_max_result = $this->filterHubsByMaxResults($filtered_hubs, $limit_results);
|
||||||
$filtered_hubs = $hubs_max_result;
|
$filtered_hubs = $hubs_max_result;
|
||||||
|
}
|
||||||
|
|
||||||
$results = $filtered_hubs;
|
$results = $filtered_hubs;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1898,9 +1898,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
// get rejection reasons
|
// get rejection reasons
|
||||||
$params['rejection_reasons'] = JORejectionReason::getCollection();
|
$params['rejection_reasons'] = JORejectionReason::getCollection();
|
||||||
|
|
||||||
// set hub criteria
|
|
||||||
$hub_criteria = new HubCriteria();
|
|
||||||
|
|
||||||
// get battery (if any)
|
// get battery (if any)
|
||||||
$skus = [];
|
$skus = [];
|
||||||
$items = [];
|
$items = [];
|
||||||
|
|
@ -1931,6 +1928,12 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
->setLimitResults(50)
|
->setLimitResults(50)
|
||||||
->setPaymentMethod($obj->getModeOfPayment())
|
->setPaymentMethod($obj->getModeOfPayment())
|
||||||
->setJoType($obj->getServiceType());
|
->setJoType($obj->getServiceType());
|
||||||
|
|
||||||
|
// check if emergency or not
|
||||||
|
$willing_to_wait = $obj->getWillWait();
|
||||||
|
if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT)
|
||||||
|
$hub_criteria->setEmergency(true);
|
||||||
|
|
||||||
$hubs = $hub_selector->find($hub_criteria);
|
$hubs = $hub_selector->find($hub_criteria);
|
||||||
//$hubs = $map_tools->getClosestHubs($obj->getCoordinates(), 50, date("H:i:s"));
|
//$hubs = $map_tools->getClosestHubs($obj->getCoordinates(), 50, date("H:i:s"));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue