Add filtering for JOs with VIP transaction origin #800

This commit is contained in:
Ramon Gutierrez 2024-07-04 12:57:27 +08:00
parent 23d814d1e9
commit a10f58e425
6 changed files with 23 additions and 2 deletions

View file

@ -733,6 +733,7 @@ class JobOrderController extends ApiController
// set job order info // set job order info
$hub_criteria->setJobOrderId($jo->getID()) $hub_criteria->setJobOrderId($jo->getID())
->setJoType($jo->getServiceType()) ->setJoType($jo->getServiceType())
->setJoOrigin($jo->getSource())
->setCustomerClass($cust->getCustomerClassification()) ->setCustomerClass($cust->getCustomerClassification())
->setOrderDate($jo->getDateCreate()) ->setOrderDate($jo->getDateCreate())
->setServiceType($jo->getServiceType()); ->setServiceType($jo->getServiceType());

View file

@ -761,7 +761,7 @@ class JobOrderController extends Controller
$lat = $req->request->get('coord_lat', 0); $lat = $req->request->get('coord_lat', 0);
$price_tier = 0; $price_tier = 0;
if (($lng != 0) && ($lat != 0)) if (!empty($lng) && !empty($lat))
{ {
$coordinates = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat')); $coordinates = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
$price_tier = $pt_manager->getPriceTier($coordinates); $price_tier = $pt_manager->getPriceTier($coordinates);

View file

@ -24,6 +24,7 @@ class HubCriteria
protected $customer_class; // customer class protected $customer_class; // customer class
protected $order_date; // date JO was created protected $order_date; // date JO was created
protected $service_type; // service type of JO protected $service_type; // service type of JO
protected $jo_origin; // origin of JO
public function __construct() public function __construct()
{ {
@ -43,6 +44,7 @@ class HubCriteria
$this->customer_class = null; $this->customer_class = null;
$this->order_date = new DateTime(); $this->order_date = new DateTime();
$this->service_type = null; $this->service_type = null;
$this->jo_origin = null;
} }
public function setPoint(Point $point) public function setPoint(Point $point)
@ -222,5 +224,16 @@ class HubCriteria
{ {
return $this->service_type; return $this->service_type;
} }
public function setJoOrigin($jo_origin)
{
$this->jo_origin = $jo_origin;
return $this;
}
public function getJoOrigin()
{
return $this->jo_origin;
}
} }

View file

@ -15,6 +15,7 @@ use App\Service\InventoryManager;
use App\Service\HubFilterLogger; use App\Service\HubFilterLogger;
use App\Service\RisingTideGateway; use App\Service\RisingTideGateway;
use App\Entity\Battery; use App\Entity\Battery;
use App\Ramcar\TransactionOrigin;
class InventoryHubFilter extends BaseHubFilter implements HubFilterInterface class InventoryHubFilter extends BaseHubFilter implements HubFilterInterface
{ {
@ -33,6 +34,7 @@ class InventoryHubFilter extends BaseHubFilter implements HubFilterInterface
'flag_inventory_check', 'flag_inventory_check',
'customer_class', 'customer_class',
'jo_type', 'jo_type',
'jo_origin',
'order_date', 'order_date',
'service_type', 'service_type',
'items', 'items',
@ -48,7 +50,8 @@ class InventoryHubFilter extends BaseHubFilter implements HubFilterInterface
} }
// check customer class // check customer class
if (!empty($params['customer_class']) && $params['customer_class'] == CustomerClassification::VIP) { if ((!empty($params['customer_class']) && $params['customer_class'] == CustomerClassification::VIP) ||
$params['jo_origin'] === TransactionOrigin::VIP) {
error_log("INVENTORY CHECK " . $this->getJOID() . ": VIP CLASS"); error_log("INVENTORY CHECK " . $this->getJOID() . ": VIP CLASS");
return $hubs; return $hubs;
} }

View file

@ -67,6 +67,7 @@ class HubSelector
$flag_emergency = $criteria->isEmergency(); $flag_emergency = $criteria->isEmergency();
$flag_round_robin = $criteria->isRoundRobin(); $flag_round_robin = $criteria->isRoundRobin();
$jo_id = $criteria->getJobOrderId(); $jo_id = $criteria->getJobOrderId();
$jo_origin = $criteria->getJoOrigin();
$customer_id = $criteria->getCustomerId(); $customer_id = $criteria->getCustomerId();
$customer_class = $criteria->getCustomerClass(); $customer_class = $criteria->getCustomerClass();
@ -87,6 +88,7 @@ class HubSelector
'flag_inventory_check' => $flag_inventory_check, 'flag_inventory_check' => $flag_inventory_check,
'customer_class' => $customer_class, 'customer_class' => $customer_class,
'jo_type' => $jo_type, 'jo_type' => $jo_type,
'jo_origin' => $jo_origin,
'order_date' => $order_date, 'order_date' => $order_date,
'service_type' => $service_type, 'service_type' => $service_type,
'items' => $items, 'items' => $items,

View file

@ -2594,6 +2594,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$customer_id = $obj->getCustomer()->getID(); $customer_id = $obj->getCustomer()->getID();
$hub_criteria->setJobOrderId($jo_id) $hub_criteria->setJobOrderId($jo_id)
->setJoOrigin($obj->getSource())
->setCustomerId($customer_id); ->setCustomerId($customer_id);
$hubs = $hub_selector->find($hub_criteria); $hubs = $hub_selector->find($hub_criteria);
@ -2941,6 +2942,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
$customer_id = $cust->getID(); $customer_id = $cust->getID();
$hub_criteria->setJobOrderId($jo_id) $hub_criteria->setJobOrderId($jo_id)
->setJoOrigin($obj->getSource())
->setCustomerId($customer_id); ->setCustomerId($customer_id);
$hubs = $hub_selector->find($hub_criteria); $hubs = $hub_selector->find($hub_criteria);