Merge branch '464-resq-sms-message-to-customer-upon-jo-completion' into '465-resq-august-13-release'
Resolve "Resq - sms message to customer upon JO completion" See merge request jankstudio/resq!543
This commit is contained in:
commit
61098b551f
2 changed files with 30 additions and 15 deletions
|
|
@ -47,6 +47,7 @@ use App\Service\WarrantyHandler;
|
|||
use App\Service\MQTTClient;
|
||||
use App\Service\APNSClient;
|
||||
use App\Service\MapTools;
|
||||
use App\Service\RisingTideGateway;
|
||||
|
||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||
|
||||
|
|
@ -67,13 +68,14 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
protected $rah;
|
||||
protected $country_code;
|
||||
protected $wh;
|
||||
protected $rt;
|
||||
|
||||
protected $template_hash;
|
||||
|
||||
public function __construct(Security $security, EntityManagerInterface $em,
|
||||
InvoiceGeneratorInterface $ic, ValidatorInterface $validator,
|
||||
TranslatorInterface $translator, RiderAssignmentHandlerInterface $rah,
|
||||
string $country_code, WarrantyHandler $wh)
|
||||
string $country_code, WarrantyHandler $wh, RisingTideGateway $rt)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->ic = $ic;
|
||||
|
|
@ -83,6 +85,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$this->rah = $rah;
|
||||
$this->country_code = $country_code;
|
||||
$this->wh = $wh;
|
||||
$this->rt = $rt;
|
||||
|
||||
$this->loadTemplates();
|
||||
}
|
||||
|
|
@ -862,17 +865,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
else
|
||||
$reason = $req->request->get('no_wait_reason');
|
||||
|
||||
// check if trade in
|
||||
$is_trade_in = $req->request->get('invoice_trade_in_type');
|
||||
$no_trade_in_reason = '';
|
||||
if (empty($is_trade_in))
|
||||
{
|
||||
$no_trade_in_reason = $req->request->get('no_trade_in_reason');
|
||||
|
||||
if (empty($no_trade_in_reason))
|
||||
$error_array['no_trade_in_reason'] = 'No trade in reason required.';
|
||||
}
|
||||
|
||||
if (empty($error_array)) {
|
||||
// coordinates
|
||||
$point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat'));
|
||||
|
|
@ -890,8 +882,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
->setDeliveryAddress($req->request->get('delivery_address'))
|
||||
->setLandmark($req->request->get('landmark'))
|
||||
->setWillingToWait($req->request->get('flag_will_wait', false))
|
||||
->setReasonsNotWait($reason)
|
||||
->setNoTradeInReason($no_trade_in_reason);
|
||||
->setReasonsNotWait($reason);
|
||||
|
||||
// validate
|
||||
$errors = $this->validator->validate($obj);
|
||||
|
|
@ -982,6 +973,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
else
|
||||
error_log('Invalid plate number for warranty. Plate number = ' . $obj->getCustomerVehicle()->getPlateNumber());
|
||||
}
|
||||
|
||||
// send SMS to customer
|
||||
$phone_number = $obj->getCustomer()->getPhoneMobile();
|
||||
if (!empty($phone_number))
|
||||
$this->sendSMSToCustomer($phone_number);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3161,4 +3157,11 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface
|
|||
$em->flush();
|
||||
}
|
||||
|
||||
public function sendSMSToCustomer($phone_number)
|
||||
{
|
||||
// TODO: put this in config file or somewhere
|
||||
$message = "Your Resq job order has been completed.";
|
||||
$this->rt->sendSMS($phone_number, 'MOTOLITE', $message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use App\Service\MQTTClient;
|
|||
use App\Service\WarrantyHandler;
|
||||
use App\Service\JobOrderHandlerInterface;
|
||||
use App\Service\InvoiceGeneratorInterface;
|
||||
use App\Service\RisingTideGateway;
|
||||
|
||||
use App\Entity\RiderSession;
|
||||
use App\Entity\Rider;
|
||||
|
|
@ -45,12 +46,13 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
protected $jo_handler;
|
||||
protected $ic;
|
||||
protected $session;
|
||||
protected $rt;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, RedisClientProvider $redis,
|
||||
EncoderFactoryInterface $ef, RiderCache $rcache,
|
||||
string $country_code, MQTTClient $mclient,
|
||||
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler,
|
||||
InvoiceGeneratorInterface $ic)
|
||||
InvoiceGeneratorInterface $ic, RisingTideGateway $rt)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->redis = $redis;
|
||||
|
|
@ -61,6 +63,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
$this->wh = $wh;
|
||||
$this->jo_handler = $jo_handler;
|
||||
$this->ic = $ic;
|
||||
$this->rt = $rt;
|
||||
|
||||
// one device = one session, since we have control over the devices
|
||||
// when a rider logs in, we just change the rider assigned to the device
|
||||
|
|
@ -523,6 +526,15 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
// save to customer vehicle battery record
|
||||
$this->jo_handler->updateVehicleBattery($jo);
|
||||
|
||||
// send SMS to customer
|
||||
$phone_number = $jo->getCustomer()->getPhoneMobile();
|
||||
if (!empty($phone_number))
|
||||
{
|
||||
// TODO: put this in config file or somewhere
|
||||
$message = "Your Resq job order has been completed.";
|
||||
$this->rt->sendSMS($phone_number, 'MOTOLITE', $message);
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
// create warranty
|
||||
|
|
|
|||
Loading…
Reference in a new issue