Add rider rating flag to JO and modify jo get invoice api call #162

This commit is contained in:
Kendrick Chan 2018-08-10 22:06:52 +08:00
parent 6c63036eea
commit 7237441ec3
3 changed files with 65 additions and 2 deletions

View file

@ -1055,7 +1055,7 @@ class APIController extends Controller
$item_batt = $item->getBattery();
if ($item_batt != null)
{
$my_data['image_url'] = $this->getBatteryImageURL($req, $batt);
$my_data['image_url'] = $this->getBatteryImageURL($req, $item_batt);
}
$items_data[] = $my_data;
@ -1095,6 +1095,10 @@ class APIController extends Controller
]);
if (count($ongoing_jos) <= 0)
{
// TODO: check if the latest jo they have needs rider rating
// $query = $em->createQuery('select
// no pending
$res->setData([
'status' => APIRiderStatus::NO_PENDING_JO
]);
@ -1140,6 +1144,7 @@ class APIController extends Controller
$data['status'] = APIRiderStatus::RIDER_PICK_UP;
// TODO: fix this to actual location of rider
// default rider location to hub
$data['rider'] = [
'id' => $rider->getID(),
'name' => $rider->getFullName(),
@ -1318,8 +1323,42 @@ class APIController extends Controller
return $res->getReturnResponse();
}
$inv = $jo->getInvoice();
$invoice = $jo->getInvoice();
// make invoice json data
$data = [
'total_price' => $invoice->getTotalPrice(),
'vat_ex_price' => $invoice->getVATExclusivePrice(),
'vat' => $invoice->getVAT(),
'discount' => $invoice->getDiscount(),
'trade_in' => $invoice->getTradeIn(),
];
$items = $invoice->getItems();
$items_data = [];
foreach ($items as $item)
{
$my_data = [
'title' => $item->getTitle(),
'qty' => $item->getQuantity() + 0,
'price' => $item->getPrice() + 0.0,
];
$item_batt = $item->getBattery();
if ($item_batt != null)
{
$my_data['image_url'] = $this->getBatteryImageURL($req, $item_batt);
}
$items_data[] = $my_data;
}
$data['items'] = $items_data;
// set data
$res->setData($data);
/*
// invoice items
$inv_items = [];
foreach ($inv->getItems() as $item)
@ -1351,6 +1390,7 @@ class APIController extends Controller
$res->setData($data);
*/
return $res->getReturnResponse();
}

View file

@ -237,6 +237,12 @@ class JobOrder
*/
protected $trade_in_type;
// if the user has left a rating for the rider
/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $flag_rider_rating;
public function __construct()
{
$this->date_create = new DateTime();
@ -252,6 +258,7 @@ class JobOrder
$this->events = new ArrayCollection();
$this->trade_in_type = null;
$this->flag_rider_rating = false;
}
public function getID()
@ -686,4 +693,18 @@ class JobOrder
$this->makeRiderAvailable();
}
public function setHasRiderRating($flag = true)
{
$this->flag_rider_rating = $flag;
return $this;
}
public function HasRiderRating()
{
if ($this->flag_rider_rating == null)
return false;
return $this->flag_rider_rating;
}
}

View file

@ -10,6 +10,7 @@ class APIRiderStatus extends NameValue
const RIDER_PICK_UP = 'rider_pick_up';
const RIDER_OTW = 'rider_otw';
const RIDER_UNAVAIL = 'rider_unavail';
const RIDER_RATING = 'rider_rating';
const COLLECTION = [
'no_pending_jo' => 'No pending job order',
@ -18,5 +19,6 @@ class APIRiderStatus extends NameValue
'rider_pick_up' => 'Rider is picking up item from outlet',
'rider_otw' => 'Rider is on the way to customer',
'rider_unavail' => 'No available rider for delivery',
'rider_rating' => 'Rider waiting for rating from customer',
];
}