Add getJobOrder. #617
This commit is contained in:
parent
604f3aa200
commit
fc7151be88
1 changed files with 142 additions and 19 deletions
|
|
@ -243,67 +243,190 @@ class RiderController extends APIController
|
||||||
return new APIResponse(true, 'Rider logged out', $data);
|
return new APIResponse(true, 'Rider logged out', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJobOrder(Request $req)
|
public function getJobOrder(Request $req, EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
// get the job order of the rider assigned to this session
|
||||||
|
$required_params = [];
|
||||||
|
$missing = $this->checkMissingParameters($req, $required_params);
|
||||||
|
if (count($missing) > 0)
|
||||||
|
{
|
||||||
|
$params = implode(', ', $missing);
|
||||||
|
return new APIResponse(false, 'Missing parameter(s): ' . $params);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get capi user to link to rider api user
|
||||||
|
$capi_user_id = $this->getUser()->getID();
|
||||||
|
|
||||||
|
// check if capi user already has a rider api user
|
||||||
|
$rapi_session = $em->getRepository(RiderAPISession::class)->findOneBy(['capi_user_id' => $capi_user_id]);
|
||||||
|
|
||||||
|
// are we logged in?
|
||||||
|
if (!$rapi_session->hasRider())
|
||||||
|
return new APIResponse(false, 'No logged in rider.');
|
||||||
|
|
||||||
|
$rider = $rapi_session->getRider();
|
||||||
|
|
||||||
|
// do we have a job order?
|
||||||
|
$jo = $rider->getActiveJobOrder();
|
||||||
|
if ($jo == null)
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'job_order' => null
|
||||||
|
];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$coord = $jo->getCoordinates();
|
||||||
|
$cust = $jo->getCustomer();
|
||||||
|
$cv = $jo->getCustomerVehicle();
|
||||||
|
$v = $cv->getVehicle();
|
||||||
|
$inv = $jo->getInvoice();
|
||||||
|
$promo = $inv->getPromo();
|
||||||
|
|
||||||
|
// invoice items
|
||||||
|
$inv_items = [];
|
||||||
|
foreach ($inv->getItems() as $item)
|
||||||
|
{
|
||||||
|
$item_batt = $item->getBattery();
|
||||||
|
if ($item_batt == null)
|
||||||
|
$batt_id = null;
|
||||||
|
else
|
||||||
|
$batt_id = $item_batt->getID();
|
||||||
|
|
||||||
|
$inv_items[] = [
|
||||||
|
'id' => $item->getID(),
|
||||||
|
'title' => $item->getTitle(),
|
||||||
|
'qty' => $item->getQuantity(),
|
||||||
|
'price' => $item->getPrice(),
|
||||||
|
'batt_id' => $batt_id,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// promo
|
||||||
|
if ($promo != null)
|
||||||
|
{
|
||||||
|
$promo_data = [
|
||||||
|
'id' => $promo->getID(),
|
||||||
|
'name' => $promo->getName(),
|
||||||
|
'code' => $promo->getCode(),
|
||||||
|
'discount_rate' => $promo->getDiscountRate(),
|
||||||
|
'discount_apply' => $promo->getDiscountApply(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$promo_data = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$trade_in_type = $jo->getTradeInType();
|
||||||
|
if (empty($trade_in_type))
|
||||||
|
$trade_in_type = 'none';
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'job_order' => [
|
||||||
|
'id' => $jo->getID(),
|
||||||
|
'service_type' => $jo->getServiceType(),
|
||||||
|
'date_schedule' => $jo->getDateSchedule()->format('Ymd H:i:s'),
|
||||||
|
'longitude' => $coord->getLongitude(),
|
||||||
|
'latitude' => $coord->getLatitude(),
|
||||||
|
'status' => $jo->getStatus(),
|
||||||
|
'customer' => [
|
||||||
|
'title' => $cust->getTitle(),
|
||||||
|
'first_name' => $cust->getFirstName(),
|
||||||
|
'last_name' => $cust->getLastName(),
|
||||||
|
'phone_mobile' => $this->getParameter('country_code') . $cust->getPhoneMobile(),
|
||||||
|
],
|
||||||
|
'vehicle' => [
|
||||||
|
'manufacturer' => $v->getManufacturer()->getName(),
|
||||||
|
'make' => $v->getMake(),
|
||||||
|
'model' => $cv->getModelYear(),
|
||||||
|
'plate_number' => $cv->getPlateNumber(),
|
||||||
|
'color' => $cv->getColor(),
|
||||||
|
],
|
||||||
|
'or_num' => $jo->getORNum(),
|
||||||
|
'or_name' => $jo->getORName(),
|
||||||
|
'delivery_instructions' => $jo->getDeliveryInstructions(),
|
||||||
|
'delivery_address' => $jo->getDeliveryAddress(),
|
||||||
|
'landmark' => $jo->getLandmark(),
|
||||||
|
'invoice' => [
|
||||||
|
'discount' => $inv->getDiscount(),
|
||||||
|
'trade_in' => $inv->getTradeIn(),
|
||||||
|
'total_price' => $inv->getTotalPrice(),
|
||||||
|
'vat' => $inv->getVat(),
|
||||||
|
'items' => $inv_items,
|
||||||
|
],
|
||||||
|
'mode_of_payment' => $jo->getModeOfPayment(),
|
||||||
|
'trade_in_type' => $trade_in_type,
|
||||||
|
'promo' => $promo_data,
|
||||||
|
// TODO: load the actual
|
||||||
|
'has_warranty_doc' => false,
|
||||||
|
'flag_coolant' => $jo->hasCoolant(),
|
||||||
|
'has_motolite' => $cv->hasMotoliteBattery(),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return new APIResponse(true, 'Job order found.', $data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function acceptJobOrder(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function acceptJobOrder(Request $req)
|
public function cancelJobOrder(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cancelJobOrder(Request $req)
|
public function arrive(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function arrive(Request $req)
|
public function hubArrive(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hubArrive(Request $req)
|
public function payment(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function payment(Request $req)
|
public function available(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function available(Request $req)
|
public function getPromos(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPromos(Request $req)
|
public function getBatteries(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBatteries(Request $req)
|
public function changeService(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeService(Request $req)
|
public function hubDepart(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hubDepart(Request $req)
|
public function preHubArrive(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preHubArrive(Request $req)
|
public function preHubDepart(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preHubDepart(Request $req)
|
public function startJobOrder(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function startJobOrder(Request $req)
|
public function postHubArrive(Request $req, EntityManagerInterface $em)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postHubArrive(Request $req)
|
public function postHubDepart(Request $req, EntityManagerInterface $em)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function postHubDepart(Request $req)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue