feat(webstatement): tambahkan kolom baru dan perbaiki kode job sinkronisasi ATM card
- Menambahkan kolom `crdate` pada tabel `atmcards` di database. - Memperbaiki struktur dan penyesuaian format kode pada file `BiayaKartu.php`. - Menyelaraskan alignment konstanta, parameter, dan body fungsi untuk meningkatkan keterbacaan. - Menambahkan pengelolaan data `crdate` dalam proses sinkronisasi kartu ATM. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
@@ -4,14 +4,14 @@ namespace Modules\Webstatement\Jobs;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Bus\Queueable;
|
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\DB;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
|
||||||
use Modules\Webstatement\Models\Atmcard;
|
use Modules\Webstatement\Models\Atmcard;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Foundation\Bus\Dispatchable;
|
|
||||||
|
|
||||||
class BiayaKartu implements ShouldQueue
|
class BiayaKartu implements ShouldQueue
|
||||||
{
|
{
|
||||||
@@ -29,37 +29,20 @@ class BiayaKartu implements ShouldQueue
|
|||||||
/**
|
/**
|
||||||
* Execute the job.
|
* Execute the job.
|
||||||
*/
|
*/
|
||||||
public function handle(): void
|
public function handle()
|
||||||
|
: void
|
||||||
{
|
{
|
||||||
set_time_limit(self::MAX_EXECUTION_TIME);
|
set_time_limit(self::MAX_EXECUTION_TIME);
|
||||||
$this->syncAtmCards();
|
$this->syncAtmCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get account information from the API
|
|
||||||
*
|
|
||||||
* @param string $accountNumber
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getAccountInfo(string $accountNumber): array
|
|
||||||
{
|
|
||||||
$url = env('FIORANO_URL') . self::API_BASE_PATH;
|
|
||||||
$path = self::API_INQUIRY_PATH;
|
|
||||||
$data = [
|
|
||||||
'accountNo' => $accountNumber
|
|
||||||
];
|
|
||||||
|
|
||||||
$response = Http::post($url . $path, $data);
|
|
||||||
|
|
||||||
return $response->json();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronize ATM cards data from Oracle database
|
* Synchronize ATM cards data from Oracle database
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function syncAtmCards(): void
|
private function syncAtmCards()
|
||||||
|
: void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
@@ -86,6 +69,7 @@ class BiayaKartu implements ShouldQueue
|
|||||||
* Fetch a batch of ATM cards from the database
|
* Fetch a batch of ATM cards from the database
|
||||||
*
|
*
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
|
*
|
||||||
* @return \Illuminate\Support\Collection
|
* @return \Illuminate\Support\Collection
|
||||||
*/
|
*/
|
||||||
private function fetchCardBatch(int $offset)
|
private function fetchCardBatch(int $offset)
|
||||||
@@ -104,9 +88,11 @@ class BiayaKartu implements ShouldQueue
|
|||||||
* Process a batch of ATM cards
|
* Process a batch of ATM cards
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Support\Collection $cards
|
* @param \Illuminate\Support\Collection $cards
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function processCardBatch($cards): void
|
private function processCardBatch($cards)
|
||||||
|
: void
|
||||||
{
|
{
|
||||||
foreach ($cards as $card) {
|
foreach ($cards as $card) {
|
||||||
try {
|
try {
|
||||||
@@ -118,14 +104,37 @@ class BiayaKartu implements ShouldQueue
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get account information from the API
|
||||||
|
*
|
||||||
|
* @param string $accountNumber
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getAccountInfo(string $accountNumber)
|
||||||
|
: array
|
||||||
|
{
|
||||||
|
$url = env('FIORANO_URL') . self::API_BASE_PATH;
|
||||||
|
$path = self::API_INQUIRY_PATH;
|
||||||
|
$data = [
|
||||||
|
'accountNo' => $accountNumber
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = Http::post($url . $path, $data);
|
||||||
|
|
||||||
|
return $response->json();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update or create ATM card record
|
* Update or create ATM card record
|
||||||
*
|
*
|
||||||
* @param object $card
|
* @param object $card
|
||||||
* @param array $accountInfo
|
* @param array $accountInfo
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function updateOrCreateAtmCard(object $card, array $accountInfo): void
|
private function updateOrCreateAtmCard(object $card, array $accountInfo)
|
||||||
|
: void
|
||||||
{
|
{
|
||||||
Atmcard::updateOrCreate(
|
Atmcard::updateOrCreate(
|
||||||
['crdno' => $card->crdno],
|
['crdno' => $card->crdno],
|
||||||
@@ -145,6 +154,7 @@ class BiayaKartu implements ShouldQueue
|
|||||||
'cttype' => $card->cttype,
|
'cttype' => $card->cttype,
|
||||||
'ctdesc' => $card->ctdesc,
|
'ctdesc' => $card->ctdesc,
|
||||||
'last_update' => $card->lastupdate,
|
'last_update' => $card->lastupdate,
|
||||||
|
'crdate' => $card->crdate,
|
||||||
'branch' => $accountInfo['acctCompany'],
|
'branch' => $accountInfo['acctCompany'],
|
||||||
'currency' => $accountInfo['acctCurrency'],
|
'currency' => $accountInfo['acctCurrency'],
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ return new class extends Migration
|
|||||||
$table->string('crsts')->nullable();
|
$table->string('crsts')->nullable();
|
||||||
$table->string('cttype')->nullable();
|
$table->string('cttype')->nullable();
|
||||||
$table->string('ctdesc')->nullable();
|
$table->string('ctdesc')->nullable();
|
||||||
|
$table->string('crdate')->nullable();
|
||||||
$table->string('branch')->nullable();
|
$table->string('branch')->nullable();
|
||||||
$table->string('currency')->nullable();
|
$table->string('currency')->nullable();
|
||||||
$table->decimal('fee', 10, 2)->nullable();
|
$table->decimal('fee', 10, 2)->nullable();
|
||||||
|
|||||||
Reference in New Issue
Block a user