added failover failed

This commit is contained in:
Hafifie PKB
2024-11-18 20:20:36 +08:00
parent 5d18764a34
commit 3f4d0412df
4 changed files with 288 additions and 188 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class FailoverTransactionFailed extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'failover_transaction_failed';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'original_id',
'kodcaw',
'norujukan',
'code_error',
'error_message'
];
}
+1 -1
View File
@@ -598,7 +598,7 @@ class LelongController extends Controller
if($cawangan['tagarrahnbid'] == 1){
if(env('APP_ENV') != 'production'){
$link = 'https://niklah.arrahn.com.my/api/portalApi';
$link = 'http://adminbid.arrahn/api/portalApi';
}else{
$link = 'http://adminbid.arrahn/api/portalApi';
}
+221 -187
View File
@@ -15,6 +15,7 @@ use App\KomuditiPurchase;
use App\KomuditiTransaksi;
use App\Marhun;
use App\FailoverTransaction;
use App\FailoverTransactionFailed;
use App\Moratorium;
use App\Support\OnePercent;
use App\Tebus;
@@ -947,15 +948,17 @@ class Penebusan
try{
$failover_response = $this->handleFailOverTransaction($kodcaw,'create',$norujukan,$request->teller);
DB::transaction(function () use ($failover_response,$kodcaw,$norujukan,$gadai,$cawangan,$array_tebus,$array_trans) {
$this->saveTebus($kodcaw,$norujukan,$gadai,$cawangan,$array_tebus);
$this->createTransaction($cawangan,$kodcaw,$norujukan,$array_trans,$failover_response['id']);
});
// DB::connection($cawangan['mysql'])->transaction(function () use ($failover_response,$kodcaw,$norujukan,$gadai,$cawangan,$array_tebus,$array_trans) {
DB::connection($cawangan['mysql'])->beginTransaction();
$this->saveTebus($kodcaw,$norujukan,$gadai,$cawangan,$array_tebus);
$this->createTransaction($cawangan,$kodcaw,$norujukan,$array_trans,$failover_response['id']);
// });
DB::connection('mysql7')->transaction(function () use ($kodcaw,$norujukan,$gadai,$array_tebus_base,$array_trans_base) {
DB::connection('mysql7')->beginTransaction();
// DB::connection('mysql7')->transaction(function () use ($kodcaw,$norujukan,$gadai,$array_tebus_base,$array_trans_base) {
$this->saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base);
$this->createTransactionBase($norujukan,$kodcaw,$array_trans_base);
});
// });
$this->handleFailOverTransaction($kodcaw,'done',$norujukan,$request->teller,$failover_response['id']);
@@ -963,13 +966,19 @@ class Penebusan
'result' => 'success',
'data' => 1
];
DB::connection($cawangan['mysql'])->commit();
DB::connection('mysql7')->commit();
return response()->json($array_response);
}catch(\Exception $e){
if (isset($failover_response['id'])) {
$this->handleFailOverTransaction($kodcaw,'fail',$norujukan,$request->teller,$failover_response['id']);
$this->handleFailOverTransaction($kodcaw,'fail',$norujukan,$request->teller,$failover_response['id'],$e->getCode(),$e->getMessage());
}
DB::connection($cawangan['mysql'])->rollBack();
DB::connection('mysql7')->rollBack();
$array_response = [
'result' => 'error',
'data' => $e->getMessage()
@@ -1041,39 +1050,40 @@ class Penebusan
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
$array_onepercent_rebet = $this->kiraupahUjrahOnePercentRebate($kodcaw,$norujukan);
try{
$onepercent_rebet = $array_onepercent_rebet['onepercent'] - $upah_rebet['onepercent'];
$ujrah_rebet = $array_onepercent_rebet['ujrah'] - $upah_rebet['ujrah'];
$onepercent_rebet = $array_onepercent_rebet['onepercent'] - $upah_rebet['onepercent'];
$ujrah_rebet = $array_onepercent_rebet['ujrah'] - $upah_rebet['ujrah'];
Tebus::on($cawangan['mysql'])->create([
'kodcaw'=> $kodcaw,
'norujukan'=> $norujukan,
'nopelanggan' => $array_tebus['nopelanggan'],
'jenisbyr' => "TN",
'jenistebus' => $array_tebus['jenistebus'],
'glcode' => "0",
't_tebus' => $current->toDateString(),
'jbg' => $gadai['tempoh'],
'kadarupah' => $gadai['kadarupah'],
'nilaimarhun' => $gadai['nilaimarhun'],
'pinjaman' => $gadai['pinjaman'],
'ansuran' => 0.00,
'addpinjaman' => $array_tebus['addpinjaman'],
'bakipjm' => $harga_tebus['harga'],
'bakiupah' => $upah_tebus,
'terima' => "*",
'kodgl' => "0",
'nowakil' => $array_tebus['nowakil'],
'rebate' => $rebet,
'marhuntebus' => $array_tebus['marhun'],
'historygadaian' => $norujukan,
'tarikhbyrn' => $current->toDateString(),
'teller' => $array_tebus['teller'],
'ujrah' => $ujrah_rebet,
'onepercent' => $onepercent_rebet,
]);
Tebus::on($cawangan['mysql'])->create([
'kodcaw'=> $kodcaw,
'norujukan'=> $norujukan,
'nopelanggan' => $array_tebus['nopelanggan'],
'jenisbyr' => "TN",
'jenistebus' => $array_tebus['jenistebus'],
'glcode' => "0",
't_tebus' => $current->toDateString(),
'jbg' => $gadai['tempoh'],
'kadarupah' => $gadai['kadarupah'],
'nilaimarhun' => $gadai['nilaimarhun'],
'pinjaman' => $gadai['pinjaman'],
'ansuran' => 0.00,
'addpinjaman' => $array_tebus['addpinjaman'],
'bakipjm' => $harga_tebus['harga'],
'bakiupah' => $upah_tebus,
'terima' => "*",
'kodgl' => "0",
'nowakil' => $array_tebus['nowakil'],
'rebate' => $rebet,
'marhuntebus' => $array_tebus['marhun'],
'historygadaian' => $norujukan,
'tarikhbyrn' => $current->toDateString(),
'teller' => $array_tebus['teller'],
'ujrah' => $ujrah_rebet,
'onepercent' => $onepercent_rebet,
]);
}catch(\Exception $e){
throw new \Exception("Error in Tebus: " . $e->getMessage());
}
}
private function saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base){
@@ -1095,36 +1105,40 @@ class Penebusan
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
TransaksiKeuntungan::on('mysql7')->create([
'norujukan' => $norujukan,
'bayaran_keuntungan' => $upah_tebus,
'bayaran_pembiayaan' => $bayaran_pembiayaan,
'keuntungan_rebet' => $upah_rebet_sebenar,
'tarikh_bayaran'=> $current,
'kodcaw'=> $kodcaw,
'ujrah' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $ujrah : 0,
'ujrah_rebet' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $ujrah_rebet : 0,
'onepercent' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $onepercent : 0,
'onepercent_rebet' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $onepercent_rebet : 0,
'margin_semasa' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $margin_semasa : 0,
'tempoh' => $gadai['tempoh'],
'beza_tempoh' => ($gadai['tempoh'] - $gadai['tempohbayar']),
]);
try{
TransaksiKeuntungan::on('mysql7')->create([
'norujukan' => $norujukan,
'bayaran_keuntungan' => $upah_tebus,
'bayaran_pembiayaan' => $bayaran_pembiayaan,
'keuntungan_rebet' => $upah_rebet_sebenar,
'tarikh_bayaran'=> $current,
'kodcaw'=> $kodcaw,
'ujrah' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $ujrah : 0,
'ujrah_rebet' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $ujrah_rebet : 0,
'onepercent' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $onepercent : 0,
'onepercent_rebet' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $onepercent_rebet : 0,
'margin_semasa' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $margin_semasa : 0,
'tempoh' => $gadai['tempoh'],
'beza_tempoh' => ($gadai['tempoh'] - $gadai['tempohbayar']),
]);
$baki_hargajualan = $gadai['bakihargajualan'] - $array_tebus_base['bakipinjaman'];
Transaction::on('mysql7')->create([
'trans_type' => $array_tebus_base['jenistebus'],
'norujukan' => $norujukan,
'nokp' => $gadai['nokp'],
'teller' => $array_tebus_base['teller'],
'kodcaw' => $kodcaw,
'duit_masuk' => $array_tebus_base['totalbayaran'],
'created_at' => $current,
'bakiharga' => $baki_hargajualan,
'nowakil' => (int)$array_tebus_base['nowakil'],
'duitpelanggan' => isset($array_tebus_base['duitpelanggan']) ? $array_tebus_base['duitpelanggan'] : 0,
'bakipelanggan' => isset($array_tebus_base['bakipelanggan']) ? $array_tebus_base['bakipelanggan'] : 0
]);
$baki_hargajualan = $gadai['bakihargajualan'] - $array_tebus_base['bakipinjaman'];
Transaction::on('mysql7')->create([
'trans_type' => $array_tebus_base['jenistebus'],
'norujukan' => $norujukan,
'nokp' => $gadai['nokp'],
'teller' => $array_tebus_base['teller'],
'kodcaw' => $kodcaw,
'duit_masuk' => $array_tebus_base['totalbayaran'],
'created_at' => $current,
'bakiharga' => $baki_hargajualan,
'nowakil' => (int)$array_tebus_base['nowakil'],
'duitpelanggan' => isset($array_tebus_base['duitpelanggan']) ? $array_tebus_base['duitpelanggan'] : 0,
'bakipelanggan' => isset($array_tebus_base['bakipelanggan']) ? $array_tebus_base['bakipelanggan'] : 0
]);
}catch(\Exception $e){
throw new \Exception("Error in TebusBase: " . $e->getMessage());
}
}
private function createTransaction($cawangan,$kodcaw,$norujukan,$array_trans,$fail_id = 0){
@@ -1139,122 +1153,127 @@ class Penebusan
$new_transaction = sprintf("%04d",$new_sirig);
$new_sag_number = strtoupper($cawangan['kodcaw']) . $current->year . $current->month . $current->day . '-' .$new_transaction;
Gadai::on($cawangan['mysql'])->create([
'kodcaw'=>$kodcaw,
'norujukan' => $new_sag_number,
'nopelanggan' => $array_trans['nopelanggan'],
'nokp' => $array_trans['noic'],
'sirig' => $new_sirig,
't_gadai' => $current->toDateString(),
'sttebus' => '',
'masa' =>$current->toTimeString(),
'tagbaru' => 1
]);
$marhun = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->get();
foreach($marhun as $marhunloop){
$karatbaru = (strpos($marhunloop['karat'], '.') !== false) ? str_replace('-','.',$marhunloop['karat']) : $marhunloop['karat'];
$karatbaru = $marhunloop['karat'];
$harga_emas = HargaEmas::on('mysql7')->select('harga')->where('karat','=',$karatbaru)->first();
$harga = ($array_trans['jenisAT'] == 'hargalama') ? $marhunloop['harga'] : $harga_emas['harga'];
$nilai_marhun = (floatval($harga) * floatval($marhunloop['berat']));
$marhunToCreate = [
'kodcaw'=> $kodcaw,
'norujukan'=> $new_sag_number,
try{
Gadai::on($cawangan['mysql'])->create([
'kodcaw'=>$kodcaw,
'norujukan' => $new_sag_number,
'nopelanggan' => $array_trans['nopelanggan'],
'nokp' => $array_trans['noic'],
'sirig' => $new_sirig,
't_gadai' => $current->toDateString(),
'bil' => $marhunloop['kuantiti'],
'marhun' => $marhunloop['marhun'],
'nota' => $marhunloop['nota'],
'tag_permata' => $marhunloop['tag_permata'] != null ? $marhunloop['tag_permata'] : 0,
'berat_batu_permata' => $marhunloop['berat_batu_permata'] != null ? $marhunloop['berat_batu_permata'] : '',
'karat' => $marhunloop['karat'],
'berat' => $marhunloop['berat_emas'],
'harga' => $harga,
'n_marhun' => $nilai_marhun
];
'sttebus' => '',
'masa' =>$current->toTimeString(),
'tagbaru' => 1
]);
if($marhunToCreate['berat_batu_permata'] == '') {
$marhunToCreate['berat_batu_permata'] = null;
};
$marhun = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->get();
Marhun::on($cawangan['mysql'])->create($marhunToCreate);
}
foreach($marhun as $marhunloop){
$karatbaru = (strpos($marhunloop['karat'], '.') !== false) ? str_replace('-','.',$marhunloop['karat']) : $marhunloop['karat'];
$karatbaru = $marhunloop['karat'];
$harga_emas = HargaEmas::on('mysql7')->select('harga')->where('karat','=',$karatbaru)->first();
$total_nilai_marhun = Marhun::on($cawangan['mysql'])->where('norujukan',$new_sag_number)->sum('n_marhun');
$total_bil_marhun = Marhun::on($cawangan['mysql'])->where('norujukan',$new_sag_number)->sum('bil');
$total_berat_marhun = Marhun::on($cawangan['mysql'])->where('norujukan',$new_sag_number)->sum('berat');
$harga = ($array_trans['jenisAT'] == 'hargalama') ? $marhunloop['harga'] : $harga_emas['harga'];
$margin_pinjaman = ($array_trans['pinjaman'] / $total_nilai_marhun);
$nilai_marhun = (floatval($harga) * floatval($marhunloop['berat']));
$t_matang = Carbon::now();
$t_matang = $t_matang->addMonths(6)->subDays(1);
$marhunToCreate = [
'kodcaw'=> $kodcaw,
'norujukan'=> $new_sag_number,
't_gadai' => $current->toDateString(),
'bil' => $marhunloop['kuantiti'],
'marhun' => $marhunloop['marhun'],
'nota' => $marhunloop['nota'],
'tag_permata' => $marhunloop['tag_permata'] != null ? $marhunloop['tag_permata'] : 0,
'berat_batu_permata' => $marhunloop['berat_batu_permata'] != null ? $marhunloop['berat_batu_permata'] : '',
'karat' => $marhunloop['karat'],
'berat' => $marhunloop['berat_emas'],
'harga' => $harga,
'n_marhun' => $nilai_marhun
];
$t_kontrak = Carbon::now();
$t_kontrak = $t_kontrak->addMonths(12)->subDays(1);
if($marhunToCreate['berat_batu_permata'] == '') {
$marhunToCreate['berat_batu_permata'] = null;
};
$kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->where('group_id',$cawangan['group_id'])->first();
Marhun::on($cawangan['mysql'])->create($marhunToCreate);
}
$onepercentservices = new Calculation();
$keuntungan = $onepercentservices->kiraanKeuntunganSebenar($array_trans['pinjaman'],$total_nilai_marhun,$kadar_raw['kadarujrah'],$margin_pinjaman);
$total_nilai_marhun = Marhun::on($cawangan['mysql'])->where('norujukan',$new_sag_number)->sum('n_marhun');
$total_bil_marhun = Marhun::on($cawangan['mysql'])->where('norujukan',$new_sag_number)->sum('bil');
$total_berat_marhun = Marhun::on($cawangan['mysql'])->where('norujukan',$new_sag_number)->sum('berat');
$upah1 = $onepercentservices->getRoundedMethod($keuntungan['keuntungan']);
$upah6 = $onepercentservices->getRoundedMethod($upah1 * 6);
$upah12 = $onepercentservices->getRoundedMethod($upah1 * 12);
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
$akrual_ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah'] * 0.5);
$akrual_onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent'] * 0.5);
$margin_pinjaman = ($array_trans['pinjaman'] / $total_nilai_marhun);
$hargajualan = $array_trans['pinjaman'] + $upah12;
$t_matang = Carbon::now();
$t_matang = $t_matang->addMonths(6)->subDays(1);
Gadai::on($cawangan['mysql'])
->where('norujukan','=',$new_sag_number)
->update(array(
'nilaimarhun' => $total_nilai_marhun,
'berat'=> $total_berat_marhun,
'pinjaman' => $array_trans['pinjaman'],
'kadarupah' => $kadar_raw['kadarujrah'],
'marhun' => $array_trans['marhun'],
'percentpinj' => $margin_pinjaman,
'teller' => $array_trans['teller'],
'bakipjm' => $array_trans['pinjaman'],
'bakiupah' => $upah6,
'jbg' => 0.5,
't_update' => $current->toDateString(),
'cetak' => 0,
'upah12' => $upah12,
'hargajualan' => $hargajualan,
'bakihargajualan' => $hargajualan,
'tagserah' => 0,
't_matang' => $t_matang,
't_matang1' => $t_kontrak,
'tempoh' => 0.5,
'kuantiti' => $total_bil_marhun,
'tagkomuditi' => 0,
'upahdibayar' => 0.00,
'tempohbayar' => 0.00,
'lelong_tawarruq' => 1,
'kadarujrah' => $kadar_raw['kadarujrah'],
'ujrah' => $ujrah,
'onepercent' => $onepercent,
'margin_semasa' => $margin_pinjaman,
'tagbaru' => 1,
'tunggakanujrah' => $akrual_ujrah,
'tunggakanonepercent' => $akrual_onepercent,
));
$t_kontrak = Carbon::now();
$t_kontrak = $t_kontrak->addMonths(12)->subDays(1);
Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
'sttebus' => "T",
't_update' => $current->toDateString(),
'historygadaian' => $new_sag_number,
'tag_tebus' => $array_trans['jenistebus'],
));
$kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->where('group_id',$cawangan['group_id'])->first();
$onepercentservices = new Calculation();
$keuntungan = $onepercentservices->kiraanKeuntunganSebenar($array_trans['pinjaman'],$total_nilai_marhun,$kadar_raw['kadarujrah'],$margin_pinjaman);
$upah1 = $onepercentservices->getRoundedMethod($keuntungan['keuntungan']);
$upah6 = $onepercentservices->getRoundedMethod($upah1 * 6);
$upah12 = $onepercentservices->getRoundedMethod($upah1 * 12);
$ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah']);
$onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent']);
$akrual_ujrah = $onepercentservices->getRoundedMethod($keuntungan['ujrah'] * 0.5);
$akrual_onepercent = $onepercentservices->getRoundedMethod($keuntungan['onepercent'] * 0.5);
$hargajualan = $array_trans['pinjaman'] + $upah12;
Gadai::on($cawangan['mysql'])
->where('norujukan','=',$new_sag_number)
->update(array(
'nilaimarhun' => $total_nilai_marhun,
'berat'=> $total_berat_marhun,
'pinjaman' => $array_trans['pinjaman'],
'kadarupah' => $kadar_raw['kadarujrah'],
'marhun' => $array_trans['marhun'],
'percentpinj' => $margin_pinjaman,
'teller' => $array_trans['teller'],
'bakipjm' => $array_trans['pinjaman'],
'bakiupah' => $upah6,
'jbg' => 0.5,
't_update' => $current->toDateString(),
'cetak' => 0,
'upah12' => $upah12,
'hargajualan' => $hargajualan,
'bakihargajualan' => $hargajualan,
'tagserah' => 0,
't_matang' => $t_matang,
't_matang1' => $t_kontrak,
'tempoh' => 0.5,
'kuantiti' => $total_bil_marhun,
'tagkomuditi' => 0,
'upahdibayar' => 0.00,
'tempohbayar' => 0.00,
'lelong_tawarruq' => 1,
'kadarujrah' => $kadar_raw['kadarujrah'],
'ujrah' => $ujrah,
'onepercent' => $onepercent,
'margin_semasa' => $margin_pinjaman,
'tagbaru' => 1,
'tunggakanujrah' => $akrual_ujrah,
'tunggakanonepercent' => $akrual_onepercent,
));
Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
'sttebus' => "T",
't_update' => $current->toDateString(),
'historygadaian' => $new_sag_number,
'tag_tebus' => $array_trans['jenistebus'],
));
$this->handleFailOverTransaction($kodcaw,'update',$new_sag_number,$array_trans['teller'],$fail_id);
}catch(\Exception $e){
throw new \Exception("Error in Transaction: " . $e->getMessage());
}
}
@@ -1264,25 +1283,30 @@ class Penebusan
$komuditi_current = KomuditiPurchase::on('mysql7')->where('date_purchase','=',$current->toDateString())->orderBy('created_at','desc')->first();
$unit_current = isset($komuditi_current['unit_komuditi']) ? $komuditi_current['unit_komuditi']: 0;
throw new \Exception('testis');
$update_unit = $unit_current - $array_trans_base['pinjaman'];
try{
$update_unit = $unit_current - $array_trans_base['pinjaman'];
KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
'unit_komuditi' => $update_unit
]);
KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
'unit_komuditi' => $update_unit
]);
KomuditiTransaksi::on('mysql7')->create([
'unit_komuditi' => $update_unit,
'nosijil'=>$komuditi_current['no_sijil'],
'norujukan' => $norujukan,
'kodcaw' => $kodcaw,
'teller' => $array_trans_base['teller'],
'masa' => $current->toTimeString(),
'tarikh' => $current->toDateString()
]);
KomuditiTransaksi::on('mysql7')->create([
'unit_komuditi' => $update_unit,
'nosijil'=>$komuditi_current['no_sijil'],
'norujukan' => $norujukan,
'kodcaw' => $kodcaw,
'teller' => $array_trans_base['teller'],
'masa' => $current->toTimeString(),
'tarikh' => $current->toDateString()
]);
}catch(\Exception $e){
throw new \Exception("Error in TransactionBase: " . $e->getMessage());
}
}
private function handleFailOverTransaction($kodcaw,$status,$norujukan,$teller,$fail_id = 0){
private function handleFailOverTransaction($kodcaw,$status,$norujukan,$teller,$fail_id = 0,$code_error = 500,$error_message = ''){
$current = Carbon::now();
if($status == 'create'){
@@ -1304,18 +1328,28 @@ class Penebusan
]);
}else if($status == 'done'){
return FailoverTransaction::on('mysql7')->where('id',$fail_id)->update([
'new_norujukan' => $norujukan,
return FailoverTransaction::on('mysql7')->where('id',$fail_id)->where('old_norujukan',$norujukan)->update([
'db_caw' => true,
'db_online' => true,
'status' => 'resolved',
'resolve_time' => $current
]);
}else{
return FailoverTransaction::on('mysql7')->where('id',$fail_id)->update([
FailoverTransaction::on('mysql7')->where('id',$fail_id)->where('old_norujukan',$norujukan)->update([
'old_norujukan' => $norujukan,
'status' => 'fail',
'status' => 'failed',
]);
FailoverTransactionFailed::on('mysql7')->create([
'original_id' => $fail_id,
'kodcaw' => $kodcaw,
'norujukan' => $norujukan,
'code_error' => $code_error,
'error_message' => $error_message,
]);
return;
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFailoverTransactionFailedTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('failover_transaction_failed', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('original_id'); // Reference to failover_transaction
$table->string('kodcaw');
$table->string('norujukan');
$table->integer('code_error');
$table->text('error_message')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('failover_transaction_failed');
}
}