- Menambahkan metode getAccountInfo untuk mengambil informasi saldo akun dari layanan eksternal. - Memperbarui metode syncAtmCards untuk menyertakan informasi cabang dan mata uang dari akun yang disinkronkan.
100 lines
3.3 KiB
PHP
100 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Webstatement\Jobs;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Modules\Webstatement\Models\Atmcard;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
class BiayaKartu implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
set_time_limit(24 * 60 * 60);
|
|
$this->syncAtmCards();
|
|
}
|
|
|
|
function getAccountInfo($accountNumber){
|
|
$url = $_ENV['FIORANO_URL'].'/restgateway/services/IGATEToCoreBankingServices';
|
|
$path = '/InquiryBalanceService';
|
|
$data = [
|
|
'accountNo' => $accountNumber
|
|
];
|
|
|
|
$response = Http::post($url.$path, $data);
|
|
|
|
return $response->json();
|
|
}
|
|
|
|
function syncAtmCards()
|
|
{
|
|
try {
|
|
$start = 0;
|
|
$limit = 100;
|
|
$loop = 1;
|
|
|
|
while ($loop) {
|
|
$cards = DB::connection('oracle')
|
|
->table('IST77.VW_CMS_VCARD')
|
|
->where('crsts', 1)
|
|
->where('ACCFLAG','!=',null)
|
|
->where('ACCFLAG', '>', 0)
|
|
->skip($start)
|
|
->take($limit)
|
|
->get();
|
|
|
|
foreach ($cards as $card) {
|
|
$accountInfo = $this->getAccountInfo($card->accflag);
|
|
Atmcard::updateOrCreate([
|
|
'crdno' => $card->crdno
|
|
], [
|
|
'accflag' => $card->accflag,
|
|
'cracc1' => $card->cracc1,
|
|
'cracc2' => $card->cracc2,
|
|
'cracc3' => $card->cracc3,
|
|
'cracc4' => $card->cracc4,
|
|
'cracc5' => $card->cracc5,
|
|
'craccnam1' => $card->craccnam1,
|
|
'craccnam2' => $card->craccnam2,
|
|
'craccnam3' => $card->craccnam3,
|
|
'craccnam4' => $card->craccnam4,
|
|
'craccnam5' => $card->craccnam5,
|
|
'crsts' => $card->crsts,
|
|
'cttype' => $card->cttype,
|
|
'ctdesc' => $card->ctdesc,
|
|
'last_update' => $card->lastupdate,
|
|
'branch' => $accountInfo->acctCompany,
|
|
'currency' => $accountInfo->acctCurrency,
|
|
]);
|
|
}
|
|
|
|
if (count($cards) < $limit) {
|
|
$loop = 0;
|
|
}
|
|
$start += $limit;
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
Log::error('SyncDwh: syncCurrency: ' . $e->getMessage());
|
|
}
|
|
}
|
|
}
|