fix refunded bookings

This commit is contained in:
edmondlang
2023-08-19 17:04:43 +08:00
parent 00c2672d16
commit 85682905e4
+14 -3
View File
@@ -5,6 +5,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use Carbon\Carbon;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Booking;
class DeleteOrderCommand extends Command
@@ -40,7 +41,8 @@ class DeleteOrderCommand extends Command
*/
public function handle()
{
$bookings_reference = $this->argument('bookings_reference');
// $bookings_reference = $this->argument('bookings_reference');
$bookings_reference = '28546,38599,44487,71086,70133,58580,42831,96028,41188,33894,95877,86732,31894,50962,44215,92894,40968,30303,89762,74693,45271,27169';
$bookings_reference = explode(',', $bookings_reference);
$start = new Carbon();
@@ -52,9 +54,18 @@ class DeleteOrderCommand extends Command
if (!$booking) {
$this->logOutput('Booking not found: ' . $reference);
} else {
$booking->status = ApprovalStatus::EXPIRED;
$booking->status = ApprovalStatus::APPROVED;
$booking->save();
$this->logOutput('Booking deleted: ' . $reference);
// $this->logOutput('Booking deleted: ' . $reference);
$payment = $booking->transactions()
->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])
->first();
$payment->status = ApprovalStatus::EXPIRED;
$payment->save();
$this->logOutput('Booking ' . $reference . ' Payment deleted: ' . $payment->id);
}
}