Add jo perform rider api call for CMB #424
This commit is contained in:
parent
131bc9c3f6
commit
943c01e5d9
5 changed files with 72 additions and 7 deletions
|
|
@ -35,6 +35,11 @@ cmb_rapi_arrive:
|
||||||
controller: App\Controller\CMBRAPIController::arrive
|
controller: App\Controller\CMBRAPIController::arrive
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
|
cmb_rapi_performed:
|
||||||
|
path: /cmbrapi/joperform
|
||||||
|
controller: App\Controller\CMBRAPIController::performJobOrder
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
cmb_rapi_payment:
|
cmb_rapi_payment:
|
||||||
path: /cmbrapi/jopayment
|
path: /cmbrapi/jopayment
|
||||||
controller: App\Controller\CMBRAPIController::payment
|
controller: App\Controller\CMBRAPIController::payment
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,26 @@ class CMBRAPIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function generateResultFromHandler($data)
|
||||||
|
{
|
||||||
|
$res = new NewAPIResult();
|
||||||
|
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
$title = $data['title'];
|
||||||
|
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorTitle($title)
|
||||||
|
->setErrorMessage($message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
public function cancelJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
public function cancelJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
{
|
{
|
||||||
$res = new NewAPIResult();
|
$res = new NewAPIResult();
|
||||||
|
|
@ -183,6 +203,15 @@ class CMBRAPIController extends Controller
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function performJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
|
{
|
||||||
|
$data = $rapi_handler->performJobOrder($req);
|
||||||
|
|
||||||
|
$res = $this->generateResultFromHandler($data);
|
||||||
|
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
public function hubArrive(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
public function hubArrive(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
{
|
{
|
||||||
$res = new NewAPIResult();
|
$res = new NewAPIResult();
|
||||||
|
|
|
||||||
|
|
@ -802,6 +802,11 @@ class JobOrder
|
||||||
$this->makeRiderAvailable();
|
$this->makeRiderAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function perform()
|
||||||
|
{
|
||||||
|
$this->setStatus(JOStatus::PERFORM)
|
||||||
|
}
|
||||||
|
|
||||||
public function fulfill()
|
public function fulfill()
|
||||||
{
|
{
|
||||||
$this->setStatus(JOStatus::FULFILLED)
|
$this->setStatus(JOStatus::FULFILLED)
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,15 @@ namespace App\Ramcar;
|
||||||
|
|
||||||
class JOStatus extends NameValue
|
class JOStatus extends NameValue
|
||||||
{
|
{
|
||||||
const PENDING = 'pending'; // NOTE: JO has no hub assigned
|
const PENDING = 'pending'; // JO has no hub assigned
|
||||||
const RIDER_ASSIGN = 'rider_assign'; // NOTE: JO has hub assigned but no rider assigned
|
const RIDER_ASSIGN = 'rider_assign'; // JO has hub assigned but no rider assigned
|
||||||
const ASSIGNED = 'assigned'; // NOTE: JO has hub and rider assigned
|
const ASSIGNED = 'assigned'; // JO has hub and rider assigned
|
||||||
const IN_TRANSIT = 'in_transit'; // NOTE: JO's rider is on his way
|
const IN_TRANSIT = 'in_transit'; // JO's rider is on his way
|
||||||
const IN_PROGRESS = 'in_progress'; // NOTE: JO fulfillment in progress
|
const IN_PROGRESS = 'in_progress'; // JO fulfillment in progress
|
||||||
const CANCELLED = 'cancelled'; // NOTE: JO is cancelled
|
const PERFORMED = 'performed'; // Rider has finished performing JO task / service
|
||||||
const FULFILLED = 'fulfilled'; // NOTE: JO is fulfilled
|
const PAID = 'paid'; // Rider has finished collecting payment for JO
|
||||||
|
const CANCELLED = 'cancelled'; // JO is cancelled
|
||||||
|
const FULFILLED = 'fulfilled'; // JO is fulfilled
|
||||||
|
|
||||||
const COLLECTION = [
|
const COLLECTION = [
|
||||||
'pending' => 'For Dispatch',
|
'pending' => 'For Dispatch',
|
||||||
|
|
@ -18,6 +20,8 @@ class JOStatus extends NameValue
|
||||||
'assigned' => 'Assigned',
|
'assigned' => 'Assigned',
|
||||||
'in_transit' => 'In Transit',
|
'in_transit' => 'In Transit',
|
||||||
'in_progress' => 'In Progress',
|
'in_progress' => 'In Progress',
|
||||||
|
'performed' => 'Service Performed',
|
||||||
|
'paid' => 'Customer Paid',
|
||||||
'cancelled' => 'Cancelled',
|
'cancelled' => 'Cancelled',
|
||||||
'fulfilled' => 'Completed',
|
'fulfilled' => 'Completed',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -801,6 +801,28 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function performJobOrder(Request $req)
|
||||||
|
{
|
||||||
|
$required_params = [
|
||||||
|
'jo_id',
|
||||||
|
];
|
||||||
|
|
||||||
|
$data = $this->checkJO($req, $required_params, $jo);
|
||||||
|
if (isset($data['error']))
|
||||||
|
{
|
||||||
|
$data['title'] = 'Failed Job Order Perform';
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
$jo->perform()
|
||||||
|
|
||||||
|
// TODO: make event for this?
|
||||||
|
|
||||||
|
$this->em->flush();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
public function rejectJobOrder(Request $req)
|
public function rejectJobOrder(Request $req)
|
||||||
{
|
{
|
||||||
$required_params = [
|
$required_params = [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue