feat(atmcard): tambahkan model dan migrasi untuk tabel atmcards
- Menambahkan model Atmcard untuk mengelola data kartu ATM. - Membuat migrasi untuk tabel atmcards dengan atribut yang diperlukan. - Menambahkan job BiayaKartu untuk menyinkronkan data kartu dari database Oracle.
This commit is contained in:
81
app/Jobs/BiayaKartu.php
Normal file
81
app/Jobs/BiayaKartu.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Webstatement\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Webstatement\Models\Atmcard;
|
||||
|
||||
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 syncAtmCards()
|
||||
{
|
||||
try {
|
||||
$start = 0;
|
||||
$limit = 100;
|
||||
$loop = 1;
|
||||
|
||||
while ($loop) {
|
||||
$cards = DB::connection('oracle')
|
||||
->table('IST77.VW_CMS_VCARD')
|
||||
->where('crsts', 1)
|
||||
->skip($start)
|
||||
->take($limit)
|
||||
->get();
|
||||
|
||||
foreach ($cards as $card) {
|
||||
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,
|
||||
]);
|
||||
}
|
||||
|
||||
if (count($cards) < $limit) {
|
||||
$loop = 0;
|
||||
}
|
||||
$start += $limit;
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
Log::error('SyncDwh: syncCurrency: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
17
app/Models/Atmcard.php
Normal file
17
app/Models/Atmcard.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Webstatement\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// use Modules\Webstatement\Database\Factories\AtmcardFactory;
|
||||
|
||||
class Atmcard extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
Reference in New Issue
Block a user