Add rating and rider rating to JO history response. Fix associations between rider rating and customer, job order, and rider. #632

This commit is contained in:
Korina Cordero 2021-10-28 06:31:27 +00:00
parent 16c944899f
commit 158d05d822
4 changed files with 39 additions and 2 deletions

View file

@ -2056,14 +2056,23 @@ class APIController extends Controller implements LoggedController
// rider // rider
$rider = $jo->getRider(); $rider = $jo->getRider();
// check if jo has rider rating set to true
$has_rider_rating = $jo->hasRiderRating();
$rating = 0;
if ($rider != null) if ($rider != null)
{ {
$jo_data['rider'] = $rider->getFullName(); $jo_data['rider'] = $rider->getFullName();
// find the rider rating if any
if ($has_rider_rating)
$rating = $jo->getRating()->getRating();
} }
// rider rating for jo // rider rating for jo
$jo_data['rider_rating'] = $jo->hasRiderRating(); $jo_data['has_rider_rating'] = $has_rider_rating;
$jo_data['rider_rating'] = $rating;
// invoice items // invoice items
$items = []; $items = [];
$jo_items = $jo->getInvoice()->getItems(); $jo_items = $jo->getInvoice()->getItems();
@ -3173,6 +3182,9 @@ class APIController extends Controller implements LoggedController
$api_version = $this->getParameter('api_version'); $api_version = $this->getParameter('api_version');
$app_version = $req->query->get('version'); $app_version = $req->query->get('version');
// putting this in for the future, in case we have diverging versions
$os = $req->query->get('os');
$platform = $req->query->get('platform');
$api_v = explode('.', $api_version); $api_v = explode('.', $api_version);
$app_v = explode('.', $app_version); $app_v = explode('.', $app_version);

View file

@ -222,6 +222,12 @@ class Customer
*/ */
protected $car_club_customer_hub; protected $car_club_customer_hub;
// ratings made by customer
/**
* @ORM\OneToMany(targetEntity="RiderRating", mappedBy="customer")
*/
protected $ratings;
public function __construct() public function __construct()
{ {
$this->numbers = new ArrayCollection(); $this->numbers = new ArrayCollection();
@ -259,6 +265,8 @@ class Customer
$this->date_create = new DateTime(); $this->date_create = new DateTime();
$this->create_source = 'unknown'; $this->create_source = 'unknown';
$this->ratings = new ArrayCollection();
} }
public function getID() public function getID()

View file

@ -365,6 +365,12 @@ class JobOrder
*/ */
protected $delivery_status; protected $delivery_status;
// rider rating
/**
* @ORM\OneToOne(targetEntity="RiderRating", mappedBy="job_order")
*/
protected $rating;
public function __construct() public function __construct()
{ {
$this->date_create = new DateTime(); $this->date_create = new DateTime();
@ -1050,4 +1056,8 @@ class JobOrder
return $this->delivery_status; return $this->delivery_status;
} }
public function getRating()
{
return $this->rating;
}
} }

View file

@ -136,6 +136,11 @@ class Rider
*/ */
protected $api_user; protected $api_user;
/**
* @ORM\OneToMany(targetEntity="RiderRating", mappedBy="rider")
*/
protected $ratings;
public function __construct() public function __construct()
{ {
$this->job_orders = new ArrayCollection(); $this->job_orders = new ArrayCollection();
@ -150,6 +155,8 @@ class Rider
$this->active_job_order = null; $this->active_job_order = null;
$this->current_job_order = null; $this->current_job_order = null;
$this->api_user = null; $this->api_user = null;
$this->ratings = new ArrayCollection();
} }
public function getID() public function getID()