added failover failed
This commit is contained in:
@@ -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'
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
@@ -598,7 +598,7 @@ class LelongController extends Controller
|
|||||||
|
|
||||||
if($cawangan['tagarrahnbid'] == 1){
|
if($cawangan['tagarrahnbid'] == 1){
|
||||||
if(env('APP_ENV') != 'production'){
|
if(env('APP_ENV') != 'production'){
|
||||||
$link = 'https://niklah.arrahn.com.my/api/portalApi';
|
$link = 'http://adminbid.arrahn/api/portalApi';
|
||||||
}else{
|
}else{
|
||||||
$link = 'http://adminbid.arrahn/api/portalApi';
|
$link = 'http://adminbid.arrahn/api/portalApi';
|
||||||
}
|
}
|
||||||
|
|||||||
+221
-187
@@ -15,6 +15,7 @@ use App\KomuditiPurchase;
|
|||||||
use App\KomuditiTransaksi;
|
use App\KomuditiTransaksi;
|
||||||
use App\Marhun;
|
use App\Marhun;
|
||||||
use App\FailoverTransaction;
|
use App\FailoverTransaction;
|
||||||
|
use App\FailoverTransactionFailed;
|
||||||
use App\Moratorium;
|
use App\Moratorium;
|
||||||
use App\Support\OnePercent;
|
use App\Support\OnePercent;
|
||||||
use App\Tebus;
|
use App\Tebus;
|
||||||
@@ -947,15 +948,17 @@ class Penebusan
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
$failover_response = $this->handleFailOverTransaction($kodcaw,'create',$norujukan,$request->teller);
|
$failover_response = $this->handleFailOverTransaction($kodcaw,'create',$norujukan,$request->teller);
|
||||||
DB::transaction(function () use ($failover_response,$kodcaw,$norujukan,$gadai,$cawangan,$array_tebus,$array_trans) {
|
// DB::connection($cawangan['mysql'])->transaction(function () use ($failover_response,$kodcaw,$norujukan,$gadai,$cawangan,$array_tebus,$array_trans) {
|
||||||
$this->saveTebus($kodcaw,$norujukan,$gadai,$cawangan,$array_tebus);
|
DB::connection($cawangan['mysql'])->beginTransaction();
|
||||||
$this->createTransaction($cawangan,$kodcaw,$norujukan,$array_trans,$failover_response['id']);
|
$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->saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base);
|
||||||
$this->createTransactionBase($norujukan,$kodcaw,$array_trans_base);
|
$this->createTransactionBase($norujukan,$kodcaw,$array_trans_base);
|
||||||
});
|
// });
|
||||||
|
|
||||||
$this->handleFailOverTransaction($kodcaw,'done',$norujukan,$request->teller,$failover_response['id']);
|
$this->handleFailOverTransaction($kodcaw,'done',$norujukan,$request->teller,$failover_response['id']);
|
||||||
|
|
||||||
@@ -963,13 +966,19 @@ class Penebusan
|
|||||||
'result' => 'success',
|
'result' => 'success',
|
||||||
'data' => 1
|
'data' => 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
DB::connection($cawangan['mysql'])->commit();
|
||||||
|
DB::connection('mysql7')->commit();
|
||||||
|
|
||||||
return response()->json($array_response);
|
return response()->json($array_response);
|
||||||
|
|
||||||
}catch(\Exception $e){
|
}catch(\Exception $e){
|
||||||
if (isset($failover_response['id'])) {
|
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 = [
|
$array_response = [
|
||||||
'result' => 'error',
|
'result' => 'error',
|
||||||
'data' => $e->getMessage()
|
'data' => $e->getMessage()
|
||||||
@@ -1041,39 +1050,40 @@ class Penebusan
|
|||||||
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
$upah_rebet = $this->kiraUpahRebetSebenar($kodcaw,$norujukan);
|
||||||
|
|
||||||
$array_onepercent_rebet = $this->kiraupahUjrahOnePercentRebate($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'];
|
Tebus::on($cawangan['mysql'])->create([
|
||||||
$ujrah_rebet = $array_onepercent_rebet['ujrah'] - $upah_rebet['ujrah'];
|
'kodcaw'=> $kodcaw,
|
||||||
|
'norujukan'=> $norujukan,
|
||||||
Tebus::on($cawangan['mysql'])->create([
|
'nopelanggan' => $array_tebus['nopelanggan'],
|
||||||
'kodcaw'=> $kodcaw,
|
'jenisbyr' => "TN",
|
||||||
'norujukan'=> $norujukan,
|
'jenistebus' => $array_tebus['jenistebus'],
|
||||||
'nopelanggan' => $array_tebus['nopelanggan'],
|
'glcode' => "0",
|
||||||
'jenisbyr' => "TN",
|
't_tebus' => $current->toDateString(),
|
||||||
'jenistebus' => $array_tebus['jenistebus'],
|
'jbg' => $gadai['tempoh'],
|
||||||
'glcode' => "0",
|
'kadarupah' => $gadai['kadarupah'],
|
||||||
't_tebus' => $current->toDateString(),
|
'nilaimarhun' => $gadai['nilaimarhun'],
|
||||||
'jbg' => $gadai['tempoh'],
|
'pinjaman' => $gadai['pinjaman'],
|
||||||
'kadarupah' => $gadai['kadarupah'],
|
'ansuran' => 0.00,
|
||||||
'nilaimarhun' => $gadai['nilaimarhun'],
|
'addpinjaman' => $array_tebus['addpinjaman'],
|
||||||
'pinjaman' => $gadai['pinjaman'],
|
'bakipjm' => $harga_tebus['harga'],
|
||||||
'ansuran' => 0.00,
|
'bakiupah' => $upah_tebus,
|
||||||
'addpinjaman' => $array_tebus['addpinjaman'],
|
'terima' => "*",
|
||||||
'bakipjm' => $harga_tebus['harga'],
|
'kodgl' => "0",
|
||||||
'bakiupah' => $upah_tebus,
|
'nowakil' => $array_tebus['nowakil'],
|
||||||
'terima' => "*",
|
'rebate' => $rebet,
|
||||||
'kodgl' => "0",
|
'marhuntebus' => $array_tebus['marhun'],
|
||||||
'nowakil' => $array_tebus['nowakil'],
|
'historygadaian' => $norujukan,
|
||||||
'rebate' => $rebet,
|
'tarikhbyrn' => $current->toDateString(),
|
||||||
'marhuntebus' => $array_tebus['marhun'],
|
'teller' => $array_tebus['teller'],
|
||||||
'historygadaian' => $norujukan,
|
'ujrah' => $ujrah_rebet,
|
||||||
'tarikhbyrn' => $current->toDateString(),
|
'onepercent' => $onepercent_rebet,
|
||||||
'teller' => $array_tebus['teller'],
|
]);
|
||||||
'ujrah' => $ujrah_rebet,
|
}catch(\Exception $e){
|
||||||
'onepercent' => $onepercent_rebet,
|
throw new \Exception("Error in Tebus: " . $e->getMessage());
|
||||||
]);
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base){
|
private function saveTebusBase($kodcaw,$norujukan,$gadai,$array_tebus_base){
|
||||||
@@ -1095,36 +1105,40 @@ class Penebusan
|
|||||||
|
|
||||||
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
$upah_rebet_sebenar = $harga_tebus['harga'] - $gadai['bakipjm'];
|
||||||
|
|
||||||
TransaksiKeuntungan::on('mysql7')->create([
|
try{
|
||||||
'norujukan' => $norujukan,
|
TransaksiKeuntungan::on('mysql7')->create([
|
||||||
'bayaran_keuntungan' => $upah_tebus,
|
'norujukan' => $norujukan,
|
||||||
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
'bayaran_keuntungan' => $upah_tebus,
|
||||||
'keuntungan_rebet' => $upah_rebet_sebenar,
|
'bayaran_pembiayaan' => $bayaran_pembiayaan,
|
||||||
'tarikh_bayaran'=> $current,
|
'keuntungan_rebet' => $upah_rebet_sebenar,
|
||||||
'kodcaw'=> $kodcaw,
|
'tarikh_bayaran'=> $current,
|
||||||
'ujrah' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $ujrah : 0,
|
'kodcaw'=> $kodcaw,
|
||||||
'ujrah_rebet' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $ujrah_rebet : 0,
|
'ujrah' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $ujrah : 0,
|
||||||
'onepercent' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $onepercent : 0,
|
'ujrah_rebet' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $ujrah_rebet : 0,
|
||||||
'onepercent_rebet' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $onepercent_rebet : 0,
|
'onepercent' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $onepercent : 0,
|
||||||
'margin_semasa' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $margin_semasa : 0,
|
'onepercent_rebet' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $onepercent_rebet : 0,
|
||||||
'tempoh' => $gadai['tempoh'],
|
'margin_semasa' => ($array_tebus_base['jeniskeuntungan'] == 'onepercent') ? $margin_semasa : 0,
|
||||||
'beza_tempoh' => ($gadai['tempoh'] - $gadai['tempohbayar']),
|
'tempoh' => $gadai['tempoh'],
|
||||||
]);
|
'beza_tempoh' => ($gadai['tempoh'] - $gadai['tempohbayar']),
|
||||||
|
]);
|
||||||
|
|
||||||
$baki_hargajualan = $gadai['bakihargajualan'] - $array_tebus_base['bakipinjaman'];
|
$baki_hargajualan = $gadai['bakihargajualan'] - $array_tebus_base['bakipinjaman'];
|
||||||
Transaction::on('mysql7')->create([
|
Transaction::on('mysql7')->create([
|
||||||
'trans_type' => $array_tebus_base['jenistebus'],
|
'trans_type' => $array_tebus_base['jenistebus'],
|
||||||
'norujukan' => $norujukan,
|
'norujukan' => $norujukan,
|
||||||
'nokp' => $gadai['nokp'],
|
'nokp' => $gadai['nokp'],
|
||||||
'teller' => $array_tebus_base['teller'],
|
'teller' => $array_tebus_base['teller'],
|
||||||
'kodcaw' => $kodcaw,
|
'kodcaw' => $kodcaw,
|
||||||
'duit_masuk' => $array_tebus_base['totalbayaran'],
|
'duit_masuk' => $array_tebus_base['totalbayaran'],
|
||||||
'created_at' => $current,
|
'created_at' => $current,
|
||||||
'bakiharga' => $baki_hargajualan,
|
'bakiharga' => $baki_hargajualan,
|
||||||
'nowakil' => (int)$array_tebus_base['nowakil'],
|
'nowakil' => (int)$array_tebus_base['nowakil'],
|
||||||
'duitpelanggan' => isset($array_tebus_base['duitpelanggan']) ? $array_tebus_base['duitpelanggan'] : 0,
|
'duitpelanggan' => isset($array_tebus_base['duitpelanggan']) ? $array_tebus_base['duitpelanggan'] : 0,
|
||||||
'bakipelanggan' => isset($array_tebus_base['bakipelanggan']) ? $array_tebus_base['bakipelanggan'] : 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){
|
private function createTransaction($cawangan,$kodcaw,$norujukan,$array_trans,$fail_id = 0){
|
||||||
@@ -1139,122 +1153,127 @@ class Penebusan
|
|||||||
$new_transaction = sprintf("%04d",$new_sirig);
|
$new_transaction = sprintf("%04d",$new_sirig);
|
||||||
$new_sag_number = strtoupper($cawangan['kodcaw']) . $current->year . $current->month . $current->day . '-' .$new_transaction;
|
$new_sag_number = strtoupper($cawangan['kodcaw']) . $current->year . $current->month . $current->day . '-' .$new_transaction;
|
||||||
|
|
||||||
Gadai::on($cawangan['mysql'])->create([
|
try{
|
||||||
'kodcaw'=>$kodcaw,
|
Gadai::on($cawangan['mysql'])->create([
|
||||||
'norujukan' => $new_sag_number,
|
'kodcaw'=>$kodcaw,
|
||||||
'nopelanggan' => $array_trans['nopelanggan'],
|
'norujukan' => $new_sag_number,
|
||||||
'nokp' => $array_trans['noic'],
|
'nopelanggan' => $array_trans['nopelanggan'],
|
||||||
'sirig' => $new_sirig,
|
'nokp' => $array_trans['noic'],
|
||||||
't_gadai' => $current->toDateString(),
|
'sirig' => $new_sirig,
|
||||||
'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,
|
|
||||||
't_gadai' => $current->toDateString(),
|
't_gadai' => $current->toDateString(),
|
||||||
'bil' => $marhunloop['kuantiti'],
|
'sttebus' => '',
|
||||||
'marhun' => $marhunloop['marhun'],
|
'masa' =>$current->toTimeString(),
|
||||||
'nota' => $marhunloop['nota'],
|
'tagbaru' => 1
|
||||||
'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
|
|
||||||
];
|
|
||||||
|
|
||||||
if($marhunToCreate['berat_batu_permata'] == '') {
|
$marhun = Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->get();
|
||||||
$marhunToCreate['berat_batu_permata'] = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
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');
|
$harga = ($array_trans['jenisAT'] == 'hargalama') ? $marhunloop['harga'] : $harga_emas['harga'];
|
||||||
$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');
|
|
||||||
|
|
||||||
$margin_pinjaman = ($array_trans['pinjaman'] / $total_nilai_marhun);
|
$nilai_marhun = (floatval($harga) * floatval($marhunloop['berat']));
|
||||||
|
|
||||||
$t_matang = Carbon::now();
|
$marhunToCreate = [
|
||||||
$t_matang = $t_matang->addMonths(6)->subDays(1);
|
'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();
|
if($marhunToCreate['berat_batu_permata'] == '') {
|
||||||
$t_kontrak = $t_kontrak->addMonths(12)->subDays(1);
|
$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();
|
$total_nilai_marhun = Marhun::on($cawangan['mysql'])->where('norujukan',$new_sag_number)->sum('n_marhun');
|
||||||
$keuntungan = $onepercentservices->kiraanKeuntunganSebenar($array_trans['pinjaman'],$total_nilai_marhun,$kadar_raw['kadarujrah'],$margin_pinjaman);
|
$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']);
|
$margin_pinjaman = ($array_trans['pinjaman'] / $total_nilai_marhun);
|
||||||
$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;
|
$t_matang = Carbon::now();
|
||||||
|
$t_matang = $t_matang->addMonths(6)->subDays(1);
|
||||||
|
|
||||||
Gadai::on($cawangan['mysql'])
|
$t_kontrak = Carbon::now();
|
||||||
->where('norujukan','=',$new_sag_number)
|
$t_kontrak = $t_kontrak->addMonths(12)->subDays(1);
|
||||||
->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(
|
$kadar_raw = KadarUpah::where('min','<=',$total_nilai_marhun)->where('max','>=',$total_nilai_marhun)->where('group_id',$cawangan['group_id'])->first();
|
||||||
'sttebus' => "T",
|
|
||||||
't_update' => $current->toDateString(),
|
$onepercentservices = new Calculation();
|
||||||
'historygadaian' => $new_sag_number,
|
$keuntungan = $onepercentservices->kiraanKeuntunganSebenar($array_trans['pinjaman'],$total_nilai_marhun,$kadar_raw['kadarujrah'],$margin_pinjaman);
|
||||||
'tag_tebus' => $array_trans['jenistebus'],
|
|
||||||
));
|
$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);
|
$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();
|
$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;
|
$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([
|
KomuditiPurchase::on('mysql7')->where('id','=',$komuditi_current['id'])->update([
|
||||||
'unit_komuditi' => $update_unit
|
'unit_komuditi' => $update_unit
|
||||||
]);
|
]);
|
||||||
|
|
||||||
KomuditiTransaksi::on('mysql7')->create([
|
KomuditiTransaksi::on('mysql7')->create([
|
||||||
'unit_komuditi' => $update_unit,
|
'unit_komuditi' => $update_unit,
|
||||||
'nosijil'=>$komuditi_current['no_sijil'],
|
'nosijil'=>$komuditi_current['no_sijil'],
|
||||||
'norujukan' => $norujukan,
|
'norujukan' => $norujukan,
|
||||||
'kodcaw' => $kodcaw,
|
'kodcaw' => $kodcaw,
|
||||||
'teller' => $array_trans_base['teller'],
|
'teller' => $array_trans_base['teller'],
|
||||||
'masa' => $current->toTimeString(),
|
'masa' => $current->toTimeString(),
|
||||||
'tarikh' => $current->toDateString()
|
'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();
|
$current = Carbon::now();
|
||||||
|
|
||||||
if($status == 'create'){
|
if($status == 'create'){
|
||||||
@@ -1304,18 +1328,28 @@ class Penebusan
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
}else if($status == 'done'){
|
}else if($status == 'done'){
|
||||||
return FailoverTransaction::on('mysql7')->where('id',$fail_id)->update([
|
return FailoverTransaction::on('mysql7')->where('id',$fail_id)->where('old_norujukan',$norujukan)->update([
|
||||||
'new_norujukan' => $norujukan,
|
|
||||||
'db_caw' => true,
|
'db_caw' => true,
|
||||||
'db_online' => true,
|
'db_online' => true,
|
||||||
'status' => 'resolved',
|
'status' => 'resolved',
|
||||||
'resolve_time' => $current
|
'resolve_time' => $current
|
||||||
]);
|
]);
|
||||||
}else{
|
}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,
|
'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');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user