Files
2026-02-16 09:29:37 +00:00

54 lines
1.4 KiB
PHP

<?php
namespace App\Jobs;
use App\Models\Order;
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 Rooyesh\Wallet\interfaces\TransactionInterface;
use Rooyesh\Wallet\interfaces\WalletInterface;
class CheckOrder implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $order_id;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($order_id)
{
$this->order_id = $order_id;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$order = Order::findOrFail($this->order_id);
if ($order->sts == 1){
$order->sts = 3;
$order->save();
$wallet_interface = new WalletInterface($order->customer_id, 1);
new TransactionInterface($wallet_interface, $_inp = [
"cash" => $order->total_price,
"gold" => $order->amount,
'expire_at'=>now()->addYear(),
'active'=>true,
'order_id'=>$order->id,
'note'=>'کنسل شدن سفارش'
], 1, false,true,(-1*$order->amount));
}
}
}