Add logging when one time discount has been availed for mobile. Add removal of promo from customer when one time discount has been availed for mobile. #558
This commit is contained in:
parent
df05316612
commit
03360a2ae9
2 changed files with 69 additions and 3 deletions
|
|
@ -44,6 +44,7 @@ use App\Service\HubSelector;
|
||||||
use App\Service\HubDistributor;
|
use App\Service\HubDistributor;
|
||||||
use App\Service\HubFilterLogger;
|
use App\Service\HubFilterLogger;
|
||||||
use App\Service\WarrantyAPILogger;
|
use App\Service\WarrantyAPILogger;
|
||||||
|
use App\Service\PromoLogger;
|
||||||
|
|
||||||
use App\Entity\MobileSession;
|
use App\Entity\MobileSession;
|
||||||
use App\Entity\Customer;
|
use App\Entity\Customer;
|
||||||
|
|
@ -852,7 +853,8 @@ class APIController extends Controller implements LoggedController
|
||||||
public function requestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo,
|
public function requestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo,
|
||||||
MapTools $map_tools, InventoryManager $im, MQTTClient $mclient,
|
MapTools $map_tools, InventoryManager $im, MQTTClient $mclient,
|
||||||
RiderAssignmentHandlerInterface $rah, HubSelector $hub_select,
|
RiderAssignmentHandlerInterface $rah, HubSelector $hub_select,
|
||||||
HubDistributor $hub_dist, HubFilterLogger $hub_filter_logger)
|
HubDistributor $hub_dist, HubFilterLogger $hub_filter_logger,
|
||||||
|
PromoLogger $promo_logger)
|
||||||
{
|
{
|
||||||
// check required parameters and api key
|
// check required parameters and api key
|
||||||
$required_params = [
|
$required_params = [
|
||||||
|
|
@ -1160,6 +1162,37 @@ class APIController extends Controller implements LoggedController
|
||||||
'invoice' => $invoice_data
|
'invoice' => $invoice_data
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// check service type
|
||||||
|
if ($jo->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW)
|
||||||
|
{
|
||||||
|
$customer = $cv->getCustomer();
|
||||||
|
$customer_tags = $customer->getCustomerTagObjects();
|
||||||
|
if (!empty($customer_tags))
|
||||||
|
{
|
||||||
|
foreach ($customer_tags as $customer_tag)
|
||||||
|
{
|
||||||
|
// TODO: not too comfy with this being hardcoded
|
||||||
|
if ($customer_tag->getID() == 'CAR_CLUB_PROMO')
|
||||||
|
{
|
||||||
|
// remove associated entity
|
||||||
|
$customer->removeCustomerTag($customer_tag);
|
||||||
|
|
||||||
|
// log the availment of promo from customer
|
||||||
|
$created_by = $req->query->get('api_key');;
|
||||||
|
$cust_id = $jo->getCustomer()->getID();
|
||||||
|
$cust_fname = $jo->getCustomer()->getFirstName();
|
||||||
|
$cust_lname = $jo->getCustomer()->getLastName();
|
||||||
|
$jo_id = $jo->getID();
|
||||||
|
$invoice_id = $jo->getInvoice()->getID();
|
||||||
|
// TODO: check if we store total price of invoice or just the discounted amount
|
||||||
|
$amount = $jo->getInvoice()->getTotalPrice();
|
||||||
|
$this->promo_logger->logPromoInfo($created_by, $cust_id, $cust_fname, $cust_lname, $jo_id,
|
||||||
|
$invoice_id, $amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set data
|
// set data
|
||||||
$res->setData($data);
|
$res->setData($data);
|
||||||
|
|
||||||
|
|
@ -2371,7 +2404,8 @@ class APIController extends Controller implements LoggedController
|
||||||
public function newRequestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo,
|
public function newRequestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo,
|
||||||
MapTools $map_tools, InventoryManager $im, MQTTClient $mclient,
|
MapTools $map_tools, InventoryManager $im, MQTTClient $mclient,
|
||||||
RiderAssignmentHandlerInterface $rah, HubSelector $hub_select,
|
RiderAssignmentHandlerInterface $rah, HubSelector $hub_select,
|
||||||
HubDistributor $hub_dist, HubFilterLogger $hub_filter_logger)
|
HubDistributor $hub_dist, HubFilterLogger $hub_filter_logger,
|
||||||
|
PromoLogger $promo_logger)
|
||||||
{
|
{
|
||||||
// check required parameters and api key
|
// check required parameters and api key
|
||||||
$required_params = [
|
$required_params = [
|
||||||
|
|
@ -2740,6 +2774,38 @@ class APIController extends Controller implements LoggedController
|
||||||
'invoice' => $invoice_data
|
'invoice' => $invoice_data
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// need to check for customer tag/promo
|
||||||
|
// check service type
|
||||||
|
if ($jo->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW)
|
||||||
|
{
|
||||||
|
$customer = $cv->getCustomer();
|
||||||
|
$customer_tags = $customer->getCustomerTagObjects();
|
||||||
|
if (!empty($customer_tags))
|
||||||
|
{
|
||||||
|
foreach ($customer_tags as $customer_tag)
|
||||||
|
{
|
||||||
|
// TODO: not too comfy with this being hardcoded
|
||||||
|
if ($customer_tag->getID() == 'CAR_CLUB_PROMO')
|
||||||
|
{
|
||||||
|
// remove associated entity
|
||||||
|
$customer->removeCustomerTag($customer_tag);
|
||||||
|
|
||||||
|
// log the availment of promo from customer
|
||||||
|
$created_by = $req->query->get('api_key');;
|
||||||
|
$cust_id = $jo->getCustomer()->getID();
|
||||||
|
$cust_fname = $jo->getCustomer()->getFirstName();
|
||||||
|
$cust_lname = $jo->getCustomer()->getLastName();
|
||||||
|
$jo_id = $jo->getID();
|
||||||
|
$invoice_id = $jo->getInvoice()->getID();
|
||||||
|
// TODO: check if we store total price of invoice or just the discounted amount
|
||||||
|
$amount = $jo->getInvoice()->getTotalPrice();
|
||||||
|
$promo_logger->logPromoInfo($created_by, $cust_id, $cust_fname, $cust_lname, $jo_id,
|
||||||
|
$invoice_id, $amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set data
|
// set data
|
||||||
$res->setData($data);
|
$res->setData($data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
||||||
{
|
{
|
||||||
// new job order
|
// new job order
|
||||||
$jo = new JobOrder();
|
$jo = new JobOrder();
|
||||||
$flag_new_jo = true;
|
$flag_new_jo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find customer
|
// find customer
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue