Add changes to CMB's rider API handler. #420
This commit is contained in:
parent
ce2b838ff7
commit
2ea5bfe193
1 changed files with 30 additions and 29 deletions
|
|
@ -6,8 +6,8 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||
|
||||
use App\Ramcar\CMBServiceType;
|
||||
use App\Ramcar\CMBTradeInType;
|
||||
use App\Ramcar\ServiceType;
|
||||
use App\Ramcar\TradeInType;
|
||||
use App\Ramcar\JOStatus;
|
||||
use App\Ramcar\JOEventType;
|
||||
use App\Ramcar\InvoiceStatus;
|
||||
|
|
@ -30,7 +30,6 @@ use App\Entity\Promo;
|
|||
use App\Entity\Battery;
|
||||
use App\Entity\BatteryModel;
|
||||
use App\Entity\BatterySize;
|
||||
use App\Entity\Warranty;
|
||||
|
||||
use DateTime;
|
||||
|
||||
|
|
@ -484,7 +483,9 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
return $data;
|
||||
}
|
||||
|
||||
// TODO: tag rider as available
|
||||
// tag rider as available
|
||||
$rider = $this->session->getRider();
|
||||
$rider->setAvailable(true);
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
|
|
@ -516,7 +517,8 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
->setRider($rider);
|
||||
$this->em->persist($event);
|
||||
|
||||
// TODO: tag rider as unavailable
|
||||
// tag rider as unavailable
|
||||
$rider->setAvailable(false);
|
||||
|
||||
// save to customer vehicle battery record
|
||||
$this->jo_handler->updateVehicleBattery($jo);
|
||||
|
|
@ -526,41 +528,40 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
// create warranty
|
||||
if($this->jo_handler->checkIfNewBattery($jo))
|
||||
{
|
||||
$serial = $jo->getCustomerVehicle()->getWarrantyCode();
|
||||
$serial = null;
|
||||
$warranty_class = $jo->getWarrantyClass();
|
||||
$first_name = $jo->getCustomer()->getFirstName();
|
||||
$last_name = $jo->getCustomer()->getLastName();
|
||||
$mobile_number = $jo->getCustomer()->getPhoneMobile();
|
||||
|
||||
// check if date fulfilled is null
|
||||
if ($jo->getDateFulfill() == null)
|
||||
$date_purchase = $jo->getDateCreate();
|
||||
else
|
||||
$date_purchase = $jo->getDateFulfill();
|
||||
//if ($jo->getDateFulfill() == null)
|
||||
// $date_purchase = $jo->getDateCreate();
|
||||
//else
|
||||
// $date_purchase = $jo->getDateFulfill();
|
||||
|
||||
// validate plate number
|
||||
// $plate_number = $this->wh->cleanPlateNumber($jo->getCustomerVehicle()->getPlateNumber());
|
||||
$plate_number = Warranty::cleanPlateNumber($jo->getCustomerVehicle()->getPlateNumber());
|
||||
if ($plate_number != false)
|
||||
// use date_schedule for warranty expiration computation
|
||||
$date_purchase = $jo->getDateSchedule();
|
||||
|
||||
$plate_number = $this->wh->cleanPlateNumber($jo->getCustomerVehicle()->getPlateNumber());
|
||||
|
||||
$batt_list = array();
|
||||
$invoice = $jo->getInvoice();
|
||||
if (!empty($invoice))
|
||||
{
|
||||
$batt_list = array();
|
||||
$invoice = $jo->getInvoice();
|
||||
if (!empty($invoice))
|
||||
// get battery
|
||||
$invoice_items = $invoice->getItems();
|
||||
foreach ($invoice_items as $item)
|
||||
{
|
||||
// get battery
|
||||
$invoice_items = $invoice->getItems();
|
||||
foreach ($invoice_items as $item)
|
||||
$battery = $item->getBattery();
|
||||
if ($battery != null)
|
||||
{
|
||||
$battery = $item->getBattery();
|
||||
if ($battery != null)
|
||||
{
|
||||
$batt_list[] = $item->getBattery();
|
||||
}
|
||||
$batt_list[] = $item->getBattery();
|
||||
}
|
||||
}
|
||||
|
||||
$this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||
}
|
||||
|
||||
$this->wh->createWarranty($serial, $plate_number, $first_name, $last_name, $mobile_number, $batt_list, $date_purchase, $warranty_class);
|
||||
}
|
||||
|
||||
// send mqtt event (fulfilled)
|
||||
|
|
@ -685,7 +686,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
|
||||
// check service type
|
||||
$stype_id = $req->request->get('stype_id');
|
||||
if (!CMBServiceType::validate($stype_id))
|
||||
if (!ServiceType::validate($stype_id))
|
||||
{
|
||||
$data = [
|
||||
'error' => 'Invalid service type - ' . $stype_id
|
||||
|
|
@ -750,7 +751,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
|
||||
// check trade in
|
||||
$trade_in = $req->request->get('trade_in');
|
||||
if (!CMBTradeInType::validate($trade_in))
|
||||
if (!TradeInType::validate($trade_in))
|
||||
$trade_in = null;
|
||||
|
||||
// check mode of payment
|
||||
|
|
|
|||
Loading…
Reference in a new issue