Files
online.tbbank.gov.tm-larave…/app/Jobs/SendSberToSystem.php
2026-03-12 02:35:29 +05:00

65 lines
1.7 KiB
PHP

<?php
namespace App\Jobs;
use App\Modules\SberPaymentOrder\Models\SberPaymentOrderItem;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class SendSberToSystem implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* The number of seconds the job can run before timing out.
*
* @var int
*/
public $timeout = 5;
/**
* Create a new job instance.
*/
public function __construct()
{
//
}
/**
* Execute the job.
*/
public function handle(): void
{
$ignore = DB::table('ignore_sber_payments')->pluck('payment_id');
$orderItems = SberPaymentOrderItem::query()
->where('paid', true)
->where('synced_with_system', false)
->whereDate('created_at', '>', '2025-09-05')
->whereIntegerNotInRaw('id', $ignore)
->limit(2)
->get()
->each(function ($orderItem) {
if (! $orderItem) {
return;
}
$result = syncSberWithAzatAPI($orderItem);
if (isset($result['error'])) {
ignoreSberPayment($result['error'], $orderItem);
Log::channel('sber_job')->error(json_encode([
'error' => $result['error'],
'orderItem' => $orderItem,
]));
}
});
}
}