Bug fixes for RAPIController. #309
This commit is contained in:
parent
8e613a43b1
commit
c9185e6139
1 changed files with 23 additions and 22 deletions
|
|
@ -17,10 +17,12 @@ use App\Ramcar\APIResult;
|
||||||
use App\Ramcar\JOStatus;
|
use App\Ramcar\JOStatus;
|
||||||
use App\Ramcar\InvoiceCriteria;
|
use App\Ramcar\InvoiceCriteria;
|
||||||
use App\Ramcar\CMBServiceType;
|
use App\Ramcar\CMBServiceType;
|
||||||
|
use App\Ramcar\ServiceType;
|
||||||
use App\Ramcar\WarrantyClass;
|
use App\Ramcar\WarrantyClass;
|
||||||
use App\Ramcar\APIRiderStatus;
|
use App\Ramcar\APIRiderStatus;
|
||||||
use App\Ramcar\TransactionOrigin;
|
use App\Ramcar\TransactionOrigin;
|
||||||
use App\Ramcar\CMBTradeInType;
|
use App\Ramcar\CMBTradeInType;
|
||||||
|
use App\Ramcar\TradeInType;
|
||||||
use App\Ramcar\InvoiceStatus;
|
use App\Ramcar\InvoiceStatus;
|
||||||
use App\Ramcar\ModeOfPayment;
|
use App\Ramcar\ModeOfPayment;
|
||||||
use App\Ramcar\JOEventType;
|
use App\Ramcar\JOEventType;
|
||||||
|
|
@ -50,6 +52,7 @@ use DateTime;
|
||||||
use DateInterval;
|
use DateInterval;
|
||||||
|
|
||||||
// Rider API controller
|
// Rider API controller
|
||||||
|
// TODO: Need to refactor this into a service
|
||||||
class RAPIController extends Controller
|
class RAPIController extends Controller
|
||||||
{
|
{
|
||||||
protected $session;
|
protected $session;
|
||||||
|
|
@ -637,27 +640,30 @@ class RAPIController extends Controller
|
||||||
|
|
||||||
// save to customer vehicle battery record
|
// save to customer vehicle battery record
|
||||||
// TODO: this has to move to JOHandler
|
// TODO: this has to move to JOHandler
|
||||||
$this->updateVehicleBattery($obj);
|
$this->updateVehicleBattery($jo);
|
||||||
|
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
// create warranty
|
// create warranty
|
||||||
if ($obj->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW)
|
if (($jo->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW) ||
|
||||||
|
($jo->getServiceType() == CMBServiceType::BATTERY_REPLACEMENT_NEW))
|
||||||
{
|
{
|
||||||
$serial = null;
|
$serial = null;
|
||||||
$warranty_class = $obj->getWarrantyClass();
|
$warranty_class = $jo->getWarrantyClass();
|
||||||
$first_name = $obj->getCustomer()->getFirstName();
|
$first_name = $jo->getCustomer()->getFirstName();
|
||||||
$last_name = $obj->getCustomer()->getLastName();
|
$last_name = $jo->getCustomer()->getLastName();
|
||||||
$mobile_number = $obj->getCustomer()->getPhoneMobile();
|
$mobile_number = $jo->getCustomer()->getPhoneMobile();
|
||||||
|
|
||||||
// check if date fulfilled is null
|
// check if date fulfilled is null
|
||||||
if ($obj->getDateFulfill() == null)
|
if ($jo->getDateFulfill() == null)
|
||||||
$date_purchase = $obj->getDateCreate();
|
$date_purchase = $jo->getDateCreate();
|
||||||
else
|
else
|
||||||
$date_purchase = $obj->getDateFulfill();
|
$date_purchase = $jo->getDateFulfill();
|
||||||
|
|
||||||
$plate_number = $wh->cleanPlateNumber($obj->getCustomerVehicle()->getPlateNumber());
|
$plate_number = $wh->cleanPlateNumber($jo->getCustomerVehicle()->getPlateNumber());
|
||||||
|
|
||||||
$batt_list = array();
|
$batt_list = array();
|
||||||
$invoice = $obj->getInvoice();
|
$invoice = $jo->getInvoice();
|
||||||
if (!empty($invoice))
|
if (!empty($invoice))
|
||||||
{
|
{
|
||||||
// get battery
|
// get battery
|
||||||
|
|
@ -675,8 +681,6 @@ class RAPIController extends Controller
|
||||||
$wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
$wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
// send mqtt event (fulfilled)
|
// send mqtt event (fulfilled)
|
||||||
$rider = $this->session->getRider();
|
$rider = $this->session->getRider();
|
||||||
$image_url = $req->getScheme() . '://' . $req->getHttpHost() . $req->getBasePath() . '/assets/images/user.gif';
|
$image_url = $req->getScheme() . '://' . $req->getHttpHost() . $req->getBasePath() . '/assets/images/user.gif';
|
||||||
|
|
@ -691,12 +695,6 @@ class RAPIController extends Controller
|
||||||
];
|
];
|
||||||
$mclient->sendEvent($jo, $payload);
|
$mclient->sendEvent($jo, $payload);
|
||||||
|
|
||||||
// create the warranty if new battery only
|
|
||||||
if ($jo->getServiceType () == CMBServiceType::BATTERY_REPLACEMENT_NEW)
|
|
||||||
{
|
|
||||||
$this->createWarranty($jo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -815,7 +813,8 @@ class RAPIController extends Controller
|
||||||
|
|
||||||
// check service type
|
// check service type
|
||||||
$stype_id = $req->request->get('stype_id');
|
$stype_id = $req->request->get('stype_id');
|
||||||
if (!CMBServiceType::validate($stype_id))
|
if ((!CMBServiceType::validate($stype_id)) ||
|
||||||
|
(!ServiceType::validate($stype_id)))
|
||||||
{
|
{
|
||||||
$res->setError(true)
|
$res->setError(true)
|
||||||
->setErrorMessage('Invalid service type - ' . $stype_id);
|
->setErrorMessage('Invalid service type - ' . $stype_id);
|
||||||
|
|
@ -877,7 +876,8 @@ class RAPIController extends Controller
|
||||||
|
|
||||||
// check trade in
|
// check trade in
|
||||||
$trade_in = $req->request->get('trade_in');
|
$trade_in = $req->request->get('trade_in');
|
||||||
if (!CMBTradeInType::validate($trade_in))
|
if ((!CMBTradeInType::validate($trade_in)) ||
|
||||||
|
(!TradeInType::validate($trade_in)))
|
||||||
$trade_in = null;
|
$trade_in = null;
|
||||||
|
|
||||||
// check mode of payment
|
// check mode of payment
|
||||||
|
|
@ -966,6 +966,7 @@ class RAPIController extends Controller
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// warranty expiration
|
// warranty expiration
|
||||||
|
$warr_months = 0;
|
||||||
$warr = $jo->getWarrantyClass();
|
$warr = $jo->getWarrantyClass();
|
||||||
if ($warr == WarrantyClass::WTY_PRIVATE)
|
if ($warr == WarrantyClass::WTY_PRIVATE)
|
||||||
$warr_months = $battery->getWarrantyPrivate();
|
$warr_months = $battery->getWarrantyPrivate();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue