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'];
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('atmcards', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('crdno')->nullable();
|
||||
$table->string('accflag')->nullable();
|
||||
$table->string('cracc1')->nullable();
|
||||
$table->string('cracc2')->nullable();
|
||||
$table->string('cracc3')->nullable();
|
||||
$table->string('cracc4')->nullable();
|
||||
$table->string('cracc5')->nullable();
|
||||
$table->string('craccnam1')->nullable();
|
||||
$table->string('craccnam2')->nullable();
|
||||
$table->string('craccnam3')->nullable();
|
||||
$table->string('craccnam4')->nullable();
|
||||
$table->string('craccnam5')->nullable();
|
||||
$table->string('crsts')->nullable();
|
||||
$table->string('cttype')->nullable();
|
||||
$table->string('ctdesc')->nullable();
|
||||
$table->string('branch')->nullable();
|
||||
$table->string('currency')->nullable();
|
||||
$table->decimal('fee', 10, 2)->nullable();
|
||||
$table->timestamp('last_update')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('atmcards');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user