* Fixes on bookable rooms api
* added emails * updated model to store client token from gateway * updated model to store amount refund Change-Id: Ibeebab8f1209ee9763186293746fe44f8ffe0466
This commit is contained in:
parent
29d767001c
commit
fe546f4702
@ -13,9 +13,8 @@
|
||||
**/
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use libs\utils\ICacheService;
|
||||
use Mockery\Exception;
|
||||
use Exception;
|
||||
use models\summit\ISummitRepository;
|
||||
use ModelSerializers\SerializerRegistry;
|
||||
use services\model\ISummitService;
|
||||
use utils\PagingResponse;
|
||||
use Illuminate\Console\Command;
|
||||
|
113
app/Console/Commands/SummitRoomReservationRevocationCommand.php
Normal file
113
app/Console/Commands/SummitRoomReservationRevocationCommand.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Models\Foundation\Summit\Repositories\ISummitRoomReservationRepository;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use libs\utils\ITransactionService;
|
||||
use models\summit\SummitRoomReservation;
|
||||
use utils\Filter;
|
||||
use utils\FilterElement;
|
||||
use utils\PagingInfo;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Exception;
|
||||
/**
|
||||
* Class SummitRoomReservationRevocationCommand
|
||||
* @package App\Console\Commands
|
||||
*/
|
||||
final class SummitRoomReservationRevocationCommand extends Command {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'summit:room-reservation-revocation';
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'summit:room-reservation-revocation';
|
||||
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Revokes all reserved bookable room reservations after N minutes';
|
||||
|
||||
|
||||
/**
|
||||
* @var ISummitRoomReservationRepository
|
||||
*/
|
||||
private $reservations_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* SummitRoomReservationRevocationCommand constructor.
|
||||
* @param ISummitRoomReservationRepository $reservations_repository
|
||||
* @param ITransactionService $tx_service
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
ISummitRoomReservationRepository $reservations_repository,
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->reservations_repository = $reservations_repository;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
$this->info("processing summit room reservations");
|
||||
$start = time();
|
||||
|
||||
$this->tx_service->transaction(function(){
|
||||
$filter = new Filter();
|
||||
$filter->addFilterCondition(FilterElement::makeEqual('status', SummitRoomReservation::ReservedStatus));
|
||||
$eol = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||
$lifetime = intval(Config::get("bookable_rooms.reservation_lifetime", 5));
|
||||
$eol->sub(new \DateInterval('PT'.$lifetime.'M'));
|
||||
$filter->addFilterCondition(FilterElement::makeLowerOrEqual('created', $eol->getTimestamp() ));
|
||||
$page = $this->reservations_repository->getAllByPage(new PagingInfo(1, 100), $filter);
|
||||
foreach($page->getItems() as $reservation){
|
||||
$reservation->cancel();
|
||||
}
|
||||
});
|
||||
|
||||
$end = time();
|
||||
$delta = $end - $start;
|
||||
$this->info(sprintf("execution call %s seconds", $delta));
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -32,6 +32,7 @@ class Kernel extends ConsoleKernel
|
||||
\App\Console\Commands\ChatTeamMessagesSender::class,
|
||||
\App\Console\Commands\SummitListJsonGenerator::class,
|
||||
\App\Console\Commands\PromoCodesRedeemProcessor::class,
|
||||
\App\Console\Commands\SummitRoomReservationRevocationCommand::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -79,5 +80,8 @@ class Kernel extends ConsoleKernel
|
||||
|
||||
$schedule->command('summit:promo-codes-redeem-processor', [end($summit_ids)])->daily()->withoutOverlapping();
|
||||
|
||||
// bookable rooms
|
||||
|
||||
$schedule->command('summit:room-reservation-revocation')->everyFiveMinutes()->withoutOverlapping();
|
||||
}
|
||||
}
|
||||
|
22
app/Events/BookableRooms/BookableRoomReservationCanceled.php
Normal file
22
app/Events/BookableRooms/BookableRoomReservationCanceled.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace App\Events;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class BookableRoomReservationCanceled
|
||||
* @package App\Events\BookableRooms
|
||||
*/
|
||||
final class BookableRoomReservationCanceled extends BookableRoomReservationAction
|
||||
{
|
||||
|
||||
}
|
@ -204,7 +204,7 @@ final class OAuth2SummitBookableRoomsAttributeTypeApiController extends OAuth2Pr
|
||||
}
|
||||
|
||||
$attr = $this->summit_service->addBookableRoomAttribute($summit, $payload);
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($attr)->serialize());
|
||||
return $this->created(SerializerRegistry::getInstance()->getSerializer($attr)->serialize(Request::input('expand', '')));
|
||||
}
|
||||
catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
@ -235,7 +235,7 @@ final class OAuth2SummitBookableRoomsAttributeTypeApiController extends OAuth2Pr
|
||||
$attr = $summit->getBookableAttributeTypeById($type_id);
|
||||
if (is_null($attr)) return $this->error404();
|
||||
|
||||
return $this->ok(SerializerRegistry::getInstance()->getSerializer($attr)->serialize());
|
||||
return $this->ok(SerializerRegistry::getInstance()->getSerializer($attr)->serialize(Request::input('expand', '')));
|
||||
}
|
||||
catch (ValidationException $ex1) {
|
||||
Log::warning($ex1);
|
||||
|
42
app/Mail/AbstractBookableRoomReservationEmail.php
Normal file
42
app/Mail/AbstractBookableRoomReservationEmail.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Mail;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use models\summit\SummitRoomReservation;
|
||||
/**
|
||||
* Class AbstractBookableRoomReservationEmailextends
|
||||
* @package App\Mail
|
||||
*/
|
||||
abstract class AbstractBookableRoomReservationEmail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var SummitRoomReservation
|
||||
*/
|
||||
public $reservation;
|
||||
|
||||
/**
|
||||
* AbstractBookableRoomReservationEmailextends constructor.
|
||||
* @param SummitRoomReservation $reservation
|
||||
*/
|
||||
public function __construct(SummitRoomReservation $reservation)
|
||||
{
|
||||
$this->reservation = $reservation;
|
||||
}
|
||||
|
||||
|
||||
}
|
37
app/Mail/BookableRoomReservationCanceledEmail.php
Normal file
37
app/Mail/BookableRoomReservationCanceledEmail.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php namespace App\Mail;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Support\Facades\Config;
|
||||
/**
|
||||
* Class BookableRoomReservationCanceledEmail
|
||||
* @package App\Mail
|
||||
*/
|
||||
final class BookableRoomReservationCanceledEmail extends AbstractBookableRoomReservationEmail
|
||||
{
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$subject = Config::get("mail.bookable_room_reservation_canceled_email_subject");
|
||||
if(empty($subject))
|
||||
$subject = sprintf("[%s] Your Reservation had canceled", Config::get('app.app_name'));
|
||||
|
||||
return $this->from(Config::get("mail.from"))
|
||||
->to($this->reservation->getOwner()->getEmail())
|
||||
->subject($subject)
|
||||
->view('emails.bookable_rooms.reservation_canceled');
|
||||
}
|
||||
}
|
37
app/Mail/BookableRoomReservationCreatedEmail.php
Normal file
37
app/Mail/BookableRoomReservationCreatedEmail.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php namespace App\Mail;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Support\Facades\Config;
|
||||
/**
|
||||
* Class BookableRoomReservationCreatedEmail
|
||||
* @package App\Mail
|
||||
*/
|
||||
final class BookableRoomReservationCreatedEmail extends AbstractBookableRoomReservationEmail
|
||||
{
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$subject = Config::get("mail.bookable_room_reservation_created_email_subject");
|
||||
if(empty($subject))
|
||||
$subject = sprintf("[%s] Room Reservation Created", Config::get('app.app_name'));
|
||||
|
||||
return $this->from(Config::get("mail.from"))
|
||||
->to($this->reservation->getOwner()->getEmail())
|
||||
->subject($subject)
|
||||
->view('emails.bookable_rooms.reservation_created');
|
||||
}
|
||||
}
|
38
app/Mail/BookableRoomReservationPaymentConfirmedEmail.php
Normal file
38
app/Mail/BookableRoomReservationPaymentConfirmedEmail.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php namespace App\Mail;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Support\Facades\Config;
|
||||
/**
|
||||
* Class BookableRoomReservationPaymentConfirmedEmail
|
||||
* @package App\Mail
|
||||
*/
|
||||
final class BookableRoomReservationPaymentConfirmedEmail extends AbstractBookableRoomReservationEmail
|
||||
{
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$subject = Config::get("mail.bookable_room_reservation_payment_confirmed_email_subject");
|
||||
if(empty($subject))
|
||||
$subject = sprintf("[%s] Your Room Reservation is confirmed!", Config::get('app.app_name'));
|
||||
|
||||
return $this->from(Config::get("mail.from"))
|
||||
->to($this->reservation->getOwner()->getEmail())
|
||||
->subject($subject)
|
||||
->view('emails.bookable_rooms.reservation_payment_confirmed');
|
||||
}
|
||||
}
|
38
app/Mail/BookableRoomReservationRefundAcceptedEmail.php
Normal file
38
app/Mail/BookableRoomReservationRefundAcceptedEmail.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php namespace App\Mail;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Support\Facades\Config;
|
||||
/**
|
||||
* Class BookableRoomReservationRefundAcceptedEmail
|
||||
* @package App\Mail
|
||||
*/
|
||||
final class BookableRoomReservationRefundAcceptedEmail extends AbstractBookableRoomReservationEmail
|
||||
{
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$subject = Config::get("mail.bookable_room_reservation_refund_accepted_email_subject");
|
||||
if(empty($subject))
|
||||
$subject = sprintf("[%s] Your Room Reservation Refund is Accepted!", Config::get('app.app_name'));
|
||||
|
||||
return $this->from(Config::get("mail.from"))
|
||||
->to($this->reservation->getOwner()->getEmail())
|
||||
->subject($subject)
|
||||
->view('emails.bookable_rooms.reservation_refund_accepted');
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php namespace App\Mail;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Support\Facades\Config;
|
||||
/**
|
||||
* Class BookableRoomReservationRefundRequestedAdminEmail
|
||||
* @package App\Mail
|
||||
*/
|
||||
final class BookableRoomReservationRefundRequestedAdminEmail extends AbstractBookableRoomReservationEmail
|
||||
{
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$subject = Config::get("mail.bookable_room_reservation_refund_requeted_admin_email_subject");
|
||||
if(empty($subject))
|
||||
$subject = sprintf("[%s] There is a new reservation refund request available!", Config::get('app.app_name'));
|
||||
|
||||
return $this->from(Config::get("mail.from"))
|
||||
->to(Config::get("bookable_rooms.admin_email"))
|
||||
->subject($subject)
|
||||
->view('emails.bookable_rooms.reservation_refund_requested_admin');
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php namespace App\Mail;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Illuminate\Support\Facades\Config;
|
||||
/**
|
||||
* Class BookableRoomReservationRefundRequestedOwnerEmail
|
||||
* @package App\Mail
|
||||
*/
|
||||
final class BookableRoomReservationRefundRequestedOwnerEmail extends AbstractBookableRoomReservationEmail
|
||||
{
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->view('view.name');
|
||||
}
|
||||
}
|
@ -11,9 +11,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use App\Events\BookableRoomReservationCanceled;
|
||||
use App\Events\BookableRoomReservationRefundAccepted;
|
||||
use App\Events\PaymentBookableRoomReservationConfirmed;
|
||||
use App\Events\RequestedBookableRoomReservationRefund;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use models\main\Member;
|
||||
use models\utils\SilverstripeBaseModel;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitRoomReservationRepository")
|
||||
* @ORM\Table(name="SummitRoomReservation")
|
||||
@ -60,6 +65,7 @@ class SummitRoomReservation extends SilverstripeBaseModel
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(name="PaymentGatewayClientToken", type="string")
|
||||
*/
|
||||
private $payment_gateway_client_token;
|
||||
|
||||
@ -75,6 +81,12 @@ class SummitRoomReservation extends SilverstripeBaseModel
|
||||
*/
|
||||
private $amount;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
* @ORM\Column(name="RefundedAmount", type="float")
|
||||
*/
|
||||
private $refunded_amount;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="models\main\Member", inversedBy="reservations")
|
||||
* @ORM\JoinColumn(name="OwnerID", referencedColumnName="ID")
|
||||
@ -94,6 +106,7 @@ class SummitRoomReservation extends SilverstripeBaseModel
|
||||
const PayedStatus = "Payed";
|
||||
const RequestedRefundStatus = "RequestedRefund";
|
||||
const RefundedStatus = "Refunded";
|
||||
const Canceled = "Canceled";
|
||||
|
||||
public static $valid_status = [
|
||||
self::ReservedStatus,
|
||||
@ -101,6 +114,7 @@ class SummitRoomReservation extends SilverstripeBaseModel
|
||||
self::RequestedRefundStatus,
|
||||
self::RefundedStatus,
|
||||
self::ErrorStatus,
|
||||
self::Canceled
|
||||
];
|
||||
|
||||
/**
|
||||
@ -111,6 +125,15 @@ class SummitRoomReservation extends SilverstripeBaseModel
|
||||
return $this->start_datetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $amount
|
||||
*/
|
||||
public function refund(float $amount){
|
||||
$this->status = self::RefundedStatus;
|
||||
$this->refunded_amount = $amount;
|
||||
Event::fire(new BookableRoomReservationRefundAccepted($this->getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
@ -290,10 +313,17 @@ class SummitRoomReservation extends SilverstripeBaseModel
|
||||
$this->status = self::PayedStatus;
|
||||
$now = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||
$this->approved_payment_date = $now;
|
||||
Event::fire(new PaymentBookableRoomReservationConfirmed($this->getId()));
|
||||
}
|
||||
|
||||
public function cancel():void{
|
||||
$this->status = self::Canceled;
|
||||
Event::fire(new BookableRoomReservationCanceled($this->id));
|
||||
}
|
||||
|
||||
public function requestRefund():void{
|
||||
$this->status = self::RequestedRefundStatus;
|
||||
Event::fire(new RequestedBookableRoomReservationRefund($this->getId()));
|
||||
}
|
||||
|
||||
public function setPaymentError(string $error):void{
|
||||
@ -325,4 +355,20 @@ class SummitRoomReservation extends SilverstripeBaseModel
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getRefundedAmount(): float
|
||||
{
|
||||
return $this->refunded_amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $refunded_amount
|
||||
*/
|
||||
public function setRefundedAmount(float $refunded_amount): void
|
||||
{
|
||||
$this->refunded_amount = $refunded_amount;
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="SummitVenueRoom")
|
||||
* Class SummitVenueRoom
|
||||
* Class SummitVenueRoomgetLocalEndDatetime
|
||||
* @package models\summit
|
||||
*/
|
||||
class SummitVenueRoom extends SummitAbstractLocation implements IOrderable
|
||||
@ -72,6 +72,16 @@ class SummitVenueRoom extends SummitAbstractLocation implements IOrderable
|
||||
return $this->venue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCompleteName():string{
|
||||
$name = $this->venue->getSummit()->getName();
|
||||
$name .= ' '.$this->venue->getName();
|
||||
$name .= ' '.$this->getName();
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
@ -38,9 +38,16 @@ use App\Factories\EntityEvents\SummitEventUpdatedEntityEventFactory;
|
||||
use App\Factories\EntityEvents\SummitTicketTypeActionEntityEventFactory;
|
||||
use App\Factories\EntityEvents\TrackActionEntityEventFactory;
|
||||
use App\Factories\EntityEvents\TrackGroupActionActionEntityEventFactory;
|
||||
use App\Mail\BookableRoomReservationCanceledEmail;
|
||||
use App\Mail\BookableRoomReservationCreatedEmail;
|
||||
use App\Mail\BookableRoomReservationPaymentConfirmedEmail;
|
||||
use App\Mail\BookableRoomReservationRefundAcceptedEmail;
|
||||
use App\Mail\BookableRoomReservationRefundRequestedAdminEmail;
|
||||
use App\Mail\BookableRoomReservationRefundRequestedOwnerEmail;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use LaravelDoctrine\ORM\Facades\EntityManager;
|
||||
use models\summit\SummitRoomReservation;
|
||||
|
||||
@ -326,21 +333,48 @@ final class EventServiceProvider extends ServiceProvider
|
||||
Event::listen(\App\Events\BookableRoomReservationRefundAccepted::class, function($event)
|
||||
{
|
||||
$repository = EntityManager::getRepository(SummitRoomReservation::class);
|
||||
$reservation = $repository->find($event->getReservationId());
|
||||
if(is_null($reservation) || ! $reservation instanceof SummitRoomReservation) return;
|
||||
|
||||
Mail::send(new BookableRoomReservationRefundAcceptedEmail($reservation));
|
||||
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\CreatedBookableRoomReservation::class, function($event)
|
||||
{
|
||||
$repository = EntityManager::getRepository(SummitRoomReservation::class);
|
||||
$reservation = $repository->find($event->getReservationId());
|
||||
if(is_null($reservation) || ! $reservation instanceof SummitRoomReservation) return;
|
||||
|
||||
Mail::send(new BookableRoomReservationCreatedEmail($reservation));
|
||||
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\PaymentBookableRoomReservationConfirmed::class, function($event)
|
||||
{
|
||||
$repository = EntityManager::getRepository(SummitRoomReservation::class);
|
||||
$reservation = $repository->find($event->getReservationId());
|
||||
if(is_null($reservation) || ! $reservation instanceof SummitRoomReservation) return;
|
||||
|
||||
Mail::send(new BookableRoomReservationPaymentConfirmedEmail($reservation));
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\RequestedBookableRoomReservationRefund::class, function($event)
|
||||
{
|
||||
$repository = EntityManager::getRepository(SummitRoomReservation::class);
|
||||
$reservation = $repository->find($event->getReservationId());
|
||||
if(is_null($reservation) || ! $reservation instanceof SummitRoomReservation) return;
|
||||
|
||||
Mail::send(new BookableRoomReservationRefundRequestedAdminEmail($reservation));
|
||||
Mail::send(new BookableRoomReservationRefundRequestedOwnerEmail($reservation));
|
||||
});
|
||||
|
||||
Event::listen(\App\Events\BookableRoomReservationCanceled::class, function($event)
|
||||
{
|
||||
$repository = EntityManager::getRepository(SummitRoomReservation::class);
|
||||
$reservation = $repository->find($event->getReservationId());
|
||||
if(is_null($reservation) || ! $reservation instanceof SummitRoomReservation) return;
|
||||
Mail::send(new BookableRoomReservationCanceledEmail($reservation));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ class DoctrineSummitRoomReservationRepository
|
||||
'status' => 'e.status:json_string',
|
||||
'start_datetime' => 'e.start_datetime:datetime_epoch',
|
||||
'end_datetime' => 'e.end_datetime:datetime_epoch',
|
||||
'created' => 'e.created:datetime_epoch',
|
||||
'room_id' => new DoctrineJoinFilterMapping
|
||||
(
|
||||
'e.room',
|
||||
|
@ -11,7 +11,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Events\CreatedBookableRoomReservation;
|
||||
use App\Events\FloorDeleted;
|
||||
use App\Events\FloorInserted;
|
||||
@ -22,8 +21,6 @@ use App\Events\LocationImageInserted;
|
||||
use App\Events\LocationImageUpdated;
|
||||
use App\Events\LocationInserted;
|
||||
use App\Events\LocationUpdated;
|
||||
use App\Events\PaymentBookableRoomReservationConfirmed;
|
||||
use App\Events\RequestedBookableRoomReservationRefund;
|
||||
use App\Events\SummitVenueRoomDeleted;
|
||||
use App\Events\SummitVenueRoomInserted;
|
||||
use App\Events\SummitVenueRoomUpdated;
|
||||
@ -57,7 +54,6 @@ use models\summit\SummitRoomReservation;
|
||||
use models\summit\SummitVenue;
|
||||
use models\summit\SummitVenueFloor;
|
||||
use models\summit\SummitVenueRoom;
|
||||
|
||||
/**
|
||||
* Class SummitLocationService
|
||||
* @package App\Services\Model
|
||||
@ -1755,7 +1751,6 @@ final class SummitLocationService
|
||||
|
||||
if ($this->payment_gateway->isSuccessFullPayment($payload)) {
|
||||
$reservation->setPayed();
|
||||
Event::fire(new PaymentBookableRoomReservationConfirmed($reservation->getId()));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1795,8 +1790,6 @@ final class SummitLocationService
|
||||
|
||||
$reservation->requestRefund();
|
||||
|
||||
Event::fire(new RequestedBookableRoomReservationRefund($reservation->getId()));
|
||||
|
||||
return $reservation;
|
||||
});
|
||||
}
|
||||
@ -1828,9 +1821,7 @@ final class SummitLocationService
|
||||
|
||||
$this->payment_gateway->refundPayment($reservation->getPaymentGatewayCartId(), $amount);
|
||||
|
||||
$reservation->setStatus(SummitRoomReservation::RefundedStatus);
|
||||
|
||||
Event::fire(new CreatedBookableRoomReservation($reservation->getId()));
|
||||
$reservation->refund($amount);
|
||||
|
||||
return $reservation;
|
||||
});
|
||||
|
@ -209,4 +209,7 @@ return [
|
||||
'Encryption' => services\utils\Facades\Encryption::class,
|
||||
],
|
||||
|
||||
'app_name' => env('APP_NAME', 'Open Infrastructure Summit'),
|
||||
'tenant_name' => env('TENANT_NAME', 'OpenStack'),
|
||||
|
||||
];
|
||||
|
17
config/bookable_rooms.php
Normal file
17
config/bookable_rooms.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
return [
|
||||
'reservation_lifetime' => env('BOOKABLE_ROOMS_RESERVATION_LIFETIME', 5),
|
||||
'admin_email' => env('BOOKABLE_ROOMS_ADMIN_EMAIL'),
|
||||
];
|
@ -55,7 +55,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => ['address' => null, 'name' => null],
|
||||
'from' => ['address' => env('MAIL_FROM_EMAIL'), 'name' => env('MAIL_FROM_NAME')],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
46
database/migrations/model/Version20190626125814.php
Normal file
46
database/migrations/model/Version20190626125814.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php namespace Database\Migrations\Model;
|
||||
/**
|
||||
* Copyright 2019 OpenStack Foundation
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema as Schema;
|
||||
use LaravelDoctrine\Migrations\Schema\Table;
|
||||
use LaravelDoctrine\Migrations\Schema\Builder;
|
||||
|
||||
/**
|
||||
* Class Version20190626125814
|
||||
* @package Database\Migrations\Model
|
||||
*/
|
||||
final class Version20190626125814 extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function up(Schema $schema)
|
||||
{
|
||||
$builder = new Builder($schema);
|
||||
if($schema->hasTable("SummitRoomReservation")) {
|
||||
$builder->table('SummitRoomReservation', function (Table $table) {
|
||||
$table->text("PaymentGatewayClientToken");
|
||||
$table->decimal("RefundedAmount", 9, 2)->setDefault('0.00');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
*/
|
||||
public function down(Schema $schema)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Dear {!! $reservation->getOwner()->getFullName() !!},
|
||||
</p>
|
||||
<p>
|
||||
Your Reservation for room {!! $reservation->getRoom()->getCompleteName() !!} got canceled because you did not take any action to pay it.
|
||||
</p>
|
||||
<p>
|
||||
Id {!! $reservation->getId()!!}
|
||||
Owner {!! $reservation->getOwner()->getFullName()!!}
|
||||
Email {!! $reservation->getOwner()->getEmail()!!}
|
||||
From {!! $reservation->getLocalStartDatetime()->format("Y-m-d H:i:s") !!}
|
||||
To {!! $reservation->getLocalEndDatetime()->format("Y-m-d H:i:s") !!}
|
||||
Created {!! $reservation->getCreated()->format("Y-m-d H:i:s") !!}
|
||||
Amount {!! $reservation->getAmount() !!}
|
||||
Currency {!! $reservation->getCurrency() !!}
|
||||
</p>
|
||||
<p>Cheers,<br/>{!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Dear {!! $reservation->getOwner()->getFullName() !!},
|
||||
</p>
|
||||
<p>
|
||||
Your Reservation for room {!! $reservation->getRoom()->getCompleteName() !!} has been created successfully.
|
||||
</p>
|
||||
<p>Cheers,<br/>{!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Dear {!! $reservation->getOwner()->getFullName() !!},
|
||||
</p>
|
||||
<p>
|
||||
Your Reservation for room {!! $reservation->getRoom()->getCompleteName() !!} has been confirmed.
|
||||
</p>
|
||||
<p>
|
||||
Please take note of the reservation info bellow:
|
||||
</p>
|
||||
<p>
|
||||
From {!! $reservation->getLocalStartDatetime()->format("Y-m-d H:i:s") !!}
|
||||
To {!! $reservation->getLocalEndDatetime()->format("Y-m-d H:i:s") !!}
|
||||
Room Capacity {!! $reservation->getRoom()->getCapacity() !!}
|
||||
Amount {!! $reservation->getAmount() !!}
|
||||
Currency {!! $reservation->getCurrency() !!}
|
||||
</p>
|
||||
<p>Cheers,<br/>{!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Dear {!! $reservation->getOwner()->getFullName() !!},
|
||||
</p>
|
||||
<p>
|
||||
Your Refund Request Reservation for room {!! $reservation->getRoom()->getCompleteName() !!} has been confirmed.
|
||||
</p>
|
||||
<p>
|
||||
Please take note of the reservation info bellow:
|
||||
</p>
|
||||
<p>
|
||||
From {!! $reservation->getLocalStartDatetime()->format("Y-m-d H:i:s") !!}
|
||||
To {!! $reservation->getLocalEndDatetime()->format("Y-m-d H:i:s") !!}
|
||||
Room Capacity {!! $reservation->getRoom()->getCapacity() !!}
|
||||
Amount {!! $reservation->getRefundedAmount() !!}
|
||||
Currency {!! $reservation->getCurrency() !!}
|
||||
</p>
|
||||
<p>Cheers,<br/>{!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
There is a new reservation refund request available to process
|
||||
</p>
|
||||
<p>
|
||||
Please take note of the reservation info bellow:
|
||||
</p>
|
||||
<p>
|
||||
Id {!! $reservation->getId()!!}
|
||||
Owner {!! $reservation->getOwner()->getFullName()!!}
|
||||
Email {!! $reservation->getOwner()->getEmail()!!}
|
||||
From {!! $reservation->getLocalStartDatetime()->format("Y-m-d H:i:s") !!}
|
||||
To {!! $reservation->getLocalEndDatetime()->format("Y-m-d H:i:s") !!}
|
||||
Created {!! $reservation->getCreated()->format("Y-m-d H:i:s") !!}
|
||||
Amount {!! $reservation->getAmount() !!}
|
||||
Currency {!! $reservation->getCurrency() !!}
|
||||
</p>
|
||||
<p>Cheers,<br/>{!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Dear {!! $reservation->getOwner()->getFullName() !!},
|
||||
</p>
|
||||
<p>
|
||||
You had requested a refund for your reservation.
|
||||
</p>
|
||||
<p>
|
||||
Please take note of the reservation info bellow:
|
||||
</p>
|
||||
<p>
|
||||
Id {!! $reservation->getId()!!}
|
||||
Owner {!! $reservation->getOwner()->getFullName()!!}
|
||||
Email {!! $reservation->getOwner()->getEmail()!!}
|
||||
From {!! $reservation->getLocalStartDatetime()->format("Y-m-d H:i:s") !!}
|
||||
To {!! $reservation->getLocalEndDatetime()->format("Y-m-d H:i:s") !!}
|
||||
Created {!! $reservation->getCreated()->format("Y-m-d H:i:s") !!}
|
||||
Amount {!! $reservation->getAmount() !!}
|
||||
Currency {!! $reservation->getCurrency() !!}
|
||||
</p>
|
||||
<p>Cheers,<br/>{!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
@ -1,7 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Dear {{ $request->getRequestedBy()->getFullName() }},
|
||||
User {{ $request->getSpeaker()->getFullName() }} has approved your request to edit his/her Speaker Profile.
|
||||
</p>
|
||||
<p>
|
||||
The OpenStack Team.
|
||||
</p>
|
||||
User {{ $request->getSpeaker()->getFullName() }} has approved your request to edit his/her Speaker Profile.
|
||||
</p>
|
||||
<p>Cheers,<br/>{!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
@ -1,7 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Dear {{ $request->getRequestedBy()->getFullName() }},
|
||||
User {{ $request->getSpeaker()->getFullName() }} has rejected your request to edit his/her Speaker Profile.
|
||||
</p>
|
||||
<p>
|
||||
The OpenStack Team.
|
||||
</p>
|
||||
User {{ $request->getSpeaker()->getFullName() }} has rejected your request to edit his/her Speaker Profile.
|
||||
</p>
|
||||
<p>Cheers,<br/>{!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
@ -1,8 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Dear {{ $request->getSpeaker()->getFullName() }},
|
||||
User {{ $request->getRequestedBy()->getFullName() }} has requested to be able to edit your Speaker Profile.
|
||||
To Allow that please click on the following link <a href="{{$request->getConfirmationLink($request->getSpeaker()->getId(), $token)}}">Allow</a>.
|
||||
</p>
|
||||
<p>
|
||||
The OpenStack Team.
|
||||
</p>
|
||||
User {{ $request->getRequestedBy()->getFullName() }} has requested to be able to edit your Speaker Profile.
|
||||
</p>
|
||||
<p>
|
||||
To Allow that please click on the following link <a href="{{$request->getConfirmationLink($request->getSpeaker()->getId(), $token)}}">Allow</a>.
|
||||
</p>
|
||||
<p>Cheers,<br/>{!! Config::get('app.tenant_name') !!} Support Team</p>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user