fix skit2

This commit is contained in:
fifi97
2021-06-14 11:19:55 +08:00
12 changed files with 339 additions and 33 deletions
+9
View File
@@ -2268,6 +2268,15 @@ class GadaiController extends Controller
case 'WB':
$tarikhtawarruq = '2021-05-24';
break;
case 'APM':
$tarikhtawarruq = '2021-06-08';
break;
case 'ARM':
$tarikhtawarruq = '2021-06-08';
break;
case '020306':
$tarikhtawarruq = '2021-06-08';
break;
}
$rekod_emaspalsu = Gadai::on($cawangan['mysql'])
+4 -7
View File
@@ -37,14 +37,11 @@ class GlejerController extends Controller
public function Getglejer_Data($tarikh1,$tarikh2,$kodcaw)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$glejer=Glejer::on($cawangan['mysql'])->whereBetween('tarikh',[$tarikh1,$tarikh2])->orderBy('glcode','ASC')->get();
return response()->json($glejer);
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$db=$cawangan['mysql'];
$glejer=DB::connection($db)->select("SELECT glcode, descpt , SUM(debit)AS total_debit, SUM(kredit) AS total_kredit, SUM(hariini) AS totalharini FROM glejer where tarikh BETWEEN '".$tarikh1."' and '".$tarikh2."' GROUP BY glcode,descpt ORDER BY glcode asc");
return response()->json($glejer);
}
@@ -182,11 +182,6 @@ class LelongController extends Controller
->where('baki','>=',0)
->sum('baki');
}
// dd($bakilelong->toSql());
$ansrugi = AnsRugi::on($cawangan['mysql'])
->sum('bayaran');
@@ -0,0 +1,15 @@
<?php
namespace App\Http\Controllers;
use App\PortalBillplz;
use Illuminate\Http\Request;
class PortalBillplzController extends Controller
{
public function getCollectionIDCawangan(Request $request){
$collection_id = PortalBillplz::on('mysql7')->select('collection_id')->where('kodcaw',$request->kodcaw)->first();
return response()->json($collection_id['collection_id']);
}
}
@@ -0,0 +1,61 @@
<?php
namespace App\Http\Controllers;
use App\TacExpressPayment;
use Illuminate\Http\Request;
use Carbon\Carbon;
use Illuminate\Support\Facades\Http;
class TacExpressPaymentController extends Controller
{
public function generateTacExpressPayment(Request $request){
$currentDateTime = Carbon::now();
$expired_at = Carbon::now()->addMinutes(15);
TacExpressPayment::on('mysql7')->create([
'norujukan' => $request->norujukan,
'tac_no' => $request->otp_token,
'expired_at' => $expired_at
]);
$mobileno = '6'.$request->mobileno;
// $mobileno = '60189025461';
$messages = 'SPARE : SMS-OTP '. $request->otp_token . ' for one time usage on ' . $expired_at . '. Call AR-RAHN CARELINE CENTRE 1300-22-4343 if not request';
$status = Http::get('http://gateway.onewaysms.com.au:10001/api.aspx',[
'apiusername' => 'APIQ4LP5EMKXM',
'apipassword' => 'APIQ4LP5EMKXM7CQOX',
'senderid' => 'INFO',
'mobileno' => $mobileno,
'message'=> $messages,
'languagetype'=> 1
]);
return response($status);
}
public function getTacExpressPayment(Request $request){
$currentDateTime = Carbon::now();
$tac_data = TacExpressPayment::on('mysql7')->where([['norujukan',$request->norujukan],['expired_at','>',$currentDateTime]])->get();
if(sizeof($tac_data) > 0){
return response(1);
}else{
return response(0);
}
}
public function verifyTacExpressPayment(Request $request){
$currentDateTime = Carbon::now();
$tac_data = TacExpressPayment::on('mysql7')->where([['norujukan',$request->norujukan],['tac_no',$request->tac_token],['expired_at','>',$currentDateTime]])->get();
if(sizeof($tac_data) > 0){
return response(1);
}else{
return response(0);
}
}
}
+5 -15
View File
@@ -1023,7 +1023,7 @@ class TebusController extends Controller
$keuntungan = TransaksiKeuntungan::on('mysql7')
->join($cawangan['db_name'].'.gadai as db2','transaksi_keuntungan.norujukan','=','db2.norujukan')
->whereDate('transaksi_keuntungan.tarikh_bayaran', '<=', $request->tarikh)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<=', $dateSM)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<', $dateSM)
->whereYear('tarikh_bayaran','=',$current->year)
->whereNotNull('db2.hargajualan')
->sum('bayaran_keuntungan');
@@ -1031,7 +1031,7 @@ class TebusController extends Controller
$keuntunganreducing = TransaksiKeuntungan::on('mysql7')
->join($cawangan['db_name'].'.gadai as db2','transaksi_keuntungan.norujukan','=','db2.norujukan')
->where('transaksi_keuntungan.tarikh_bayaran' ,'<=', $request->tarikh)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<', $request->tarikh)
->whereDate('transaksi_keuntungan.tarikh_bayaran','>=', $dateSM)
->whereYear('tarikh_bayaran','=',$current->year)
->whereNotNull('db2.hargajualan')
@@ -1046,9 +1046,7 @@ class TebusController extends Controller
$join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at');
})
->where('trans.trans_type','!=','A')
// ->where('transaksi_keuntungan.tarikh_bayaran' ,'<=', $daterequest)
// ->where('transaksi_keuntungan.tarikh_bayaran','>=', $dateSM)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<=', $request->tarikh)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'=', $request->tarikh)
->whereDate('transaksi_keuntungan.tarikh_bayaran','>=', $dateSM)
->whereYear('tarikh_bayaran','=',$current->year)
->whereNotNull('db2.hargajualan')
@@ -1062,21 +1060,13 @@ class TebusController extends Controller
$join->on('transaksi_keuntungan.tarikh_bayaran', '=', 'trans.created_at');
})
->where('trans.trans_type','=','A')
// ->where('transaksi_keuntungan.tarikh_bayaran' ,'<=', $daterequest)
// ->where('transaksi_keuntungan.tarikh_bayaran','>=', $dateSM)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'<=', $request->tarikh)
->whereDate('transaksi_keuntungan.tarikh_bayaran' ,'=', $request->tarikh)
->whereDate('transaksi_keuntungan.tarikh_bayaran','>=', $dateSM)
->whereYear('tarikh_bayaran','=',$current->year)
->whereNotNull('db2.hargajualan')
->sum('bayaran_keuntungan');
dd($keuntunganreducing,$keuntungan,$bukanansuran,$ansuran);
// $total = $keuntungan + $keuntunganreducing + ($keuntunganreducinga - $keuntunganansuran);
// dd($total);
// $total = $keuntungan + $keuntunganreducing + $keuntunganansuran;
// $total = $keuntungan + $keuntunganreducing;
$total = ($keuntungan+$keuntunganreducing + $ansuran + $bukanansuran);
return response($total);
}
@@ -3,11 +3,22 @@
namespace App\Http\Controllers;
use App\TransactionOnline;
use App\Advansur;
use App\Transaction;
use App\TransaksiKeuntungan;
use App\Gadai;
use App\Cawangan;
use App\GlDetail;
use Illuminate\Http\Request;
use Carbon\Carbon;
class TransactionOnlineController extends Controller
{
public function getTransactionOnline(Request $request){
$transactionOnline = TransactionOnline::on('mysql7')->where('billplz_id',$request->billplz_id)->first();
return response()->json($transactionOnline);
}
public function getLatestNosiri(){
$current = Carbon::now();
$current = new Carbon();
@@ -25,19 +36,185 @@ class TransactionOnlineController extends Controller
'nokp' => $request->nokp,
'reference_no' => $request->reference_no,
'nosiri' => $request->nosiri,
'billplz_id' => $request->billplz_id,
'norujukan' => $request->norujukan,
'kodcaw' => $request->kodcaw,
'total_payment' => $request->total_payment,
'tarikh' => $current->toDateString(),
'masa' => $current->toTimeString()
'masa' => $current->toTimeString(),
'customer_name' => $request->customer_name
]);
return response()->json($transaction,201);
}
public function updateStatus(){
$transaction = TransactionOnline::on('mysql7')->where('reference_no','=',$request->reference_no)->update(array(
'status' => 1
public function updateStatus(Request $request){
$transaction = TransactionOnline::on('mysql7')->where('billplz_id','=',$request->billplz_id)->update(array(
'status' => $request->status,
'paid_at' => $request->paid_at
));
return response()->json($transaction,200);
}
public function updateTransactionOnline(){
$transactions = TransactionOnline::on('mysql7')->where([['status','PAID'],['update_status',0]])->get();
$current = Carbon::now();
$current = new Carbon();
foreach($transactions as $index=>$transaction){
$cawangan = Cawangan::on('mysql7')
->where('kodcaw','=',$transaction['kodcaw'])
->first();
$gadai_data = Gadai::on($cawangan['mysql'])->where([['norujukan',$transaction['norujukan']],['nokp',$transaction['nokp']]])->first();
if($gadai_data['hargajualan'] > 0){
$this->updateGadaiMarhunKaunter($transaction['kodcaw'],$transaction['norujukan'],$transaction['total_payment'],$transaction['paid_at']);
}else{
$this->createAdvansur($transaction['kodcaw'],$transaction['norujukan'],$transaction['total_payment'],$transaction['paid_at']);
}
GlDetail::on($cawangan['mysql'])->create([
'kodcaw' => $transaction['kodcaw'],
'tarikh' => $current->toDateString(),
'dtacct' => '1000/010',
'ktacct' => '1000/020',
'descpt' => 'SERAHAN BAYAR ONLINE - ' . $transaction['norujukan'],
'serahan' => $transaction['total_payment'],
'teller' => 'ONLINE'
]);
TransactionOnline::on('mysql7')->where([['norujukan',$transaction['norujukan'],['billplz_id',$transaction['billplz_id']]]])->update([
'update_status' => 1,
'update_serahan' => 1
]);
}
return response()->json('success');
}
public function kiraupahTawarruq($kodcaw,$norujukan){
$cawangan = Cawangan::on('mysql7')
->where('kodcaw','=',$kodcaw)
->first();
$gadai_data = Gadai::on($cawangan['mysql'])
->where('norujukan','=',$norujukan)
->first();
$bilang_bln = $gadai_data['tempoh'] - $gadai_data['tempohbayar'];
$upahsemasa_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['pinjaman']);
$upah_semasa_round = number_format($upahsemasa_raw,2);
$upah_semasa = (float)substr($upah_semasa_round, 0, -1);
return $upah_semasa;
}
public function kiraUpahRebet($kodcaw,$norujukan){
$cawangan = Cawangan::on('mysql7')
->where('kodcaw','=',$kodcaw)
->first();
$gadai_data = Gadai::on($cawangan['mysql'])
->where('norujukan','=',$norujukan)
->first();
$bilang_bln = $gadai_data['tempoh'] - $gadai_data['tempohbayar'];
$upahrebet_raw = $bilang_bln * (($gadai_data['kadarupah']/100 )* $gadai_data['bakipjm']);
$upah_rebet_round = number_format($upahrebet_raw,2);
$upah_rebet = (float)substr($upah_rebet_round, 0, -1);
return $upah_rebet;
}
public function updateGadaiMarhunKaunter($kodcaw,$norujukan,$bayaran,$paid_at){
$current = Carbon::now();
$current = new Carbon();
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
$upahsemasa = $this->kiraupahTawarruq($kodcaw,$norujukan);
$upahrebet = $this->kiraUpahRebet($kodcaw,$norujukan);
$total_bayaran_prev = Transaction::on('mysql7')->where([['norujukan','=',$norujukan],['trans_type','=','A']])->sum('duit_masuk');
$total_bayaran_semasa = $total_bayaran_prev + $bayaran;
if($total_bayaran_semasa >= $gadai['bakiupah']){
$lelong_tawarruq = 0;
}else{
$lelong_tawarruq = 1;
}
$baki_hargajualan = $gadai['bakihargajualan'] - $bayaran;
$baki_bayaran = $bayaran - $upahsemasa;
$baki_pinjaman = $gadai['bakipjm'] - $baki_bayaran;
$transaction = Transaction::on('mysql7')->create([
'trans_type' => 'A',
'norujukan' => $norujukan,
'nokp' => $gadai['nokp'],
'teller' => 'Online',
'kodcaw' => $kodcaw,
'duit_masuk' => $bayaran,
'created_at' => Carbon::parse($paid_at),
'bakiharga' => $baki_hargajualan,
]);
$transaction_upah = TransaksiKeuntungan::on('mysql7')->create([
'norujukan' => $norujukan,
'bayaran_keuntungan' => $upahsemasa,
'bayaran_pembiayaan' => $baki_bayaran,
'keuntungan_rebet'=> $upahrebet,
'tarikh_bayaran'=> Carbon::parse($paid_at),
'kodcaw'=> $kodcaw
]);
$update_gadai = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->update(array(
'bakipjm' => $baki_pinjaman,
'jbg' => 0,
't_update' => Carbon::parse($paid_at)->toDateString(),
'bakihargajualan' => $baki_hargajualan,
'tempohbayar' => $gadai['tempoh'],
'lelong_tawarruq' => $lelong_tawarruq
));
return response()->json($update_gadai, 200);
}
public function createAdvansur($kodcaw,$norujukan,$bayaran,$paid_at){
$current = Carbon::now();
$current = new Carbon();
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$gadai = Gadai::on($cawangan['mysql'])->where('norujukan',$norujukan)->first();
$create_advansur = Advansur::on($cawangan['mysql'])->create([
'tarikh'=> Carbon::parse($paid_at)->toDateString(),
'noresit'=> 0,
'norujukan' => $norujukan,
'nopelanggan' => $gadai['nopelanggan'],
'nilaimarhun' => $gadai['nilaimarhun'],
'pinjaman' => $gadai['pinjaman'],
'kadarupah' => $gadai['kadarupah'],
'glcode' => "1000/010",
'upahsebenar' => $bayaran,
'upahDibayar' => $bayaran,
'teller' => 'Online',
'prkod' => $gadai['prkod'],
'jbg' => $gadai['tempoh'],
'nowakil' => 0,
'hubungan' => 0,
'status' => 0,
'historygadaian' => $norujukan
]);
return response()->json($create_advansur ,201);
}
}
+1 -1
View File
@@ -321,7 +321,7 @@ class VaultController extends Controller
//Sebelum Tawarruq
if($kodcaw == 'KB2' || $kodcaw == 'WCY' || $kodcaw == '1STOP')
if($kodcaw == 'KB2' || $kodcaw == 'WCY' || $kodcaw == '1STOP' || $kodcaw == 'ARM' || $kodcaw == 'APM')
{
$serahanpkb = GlDetail::on($cawangan['mysql'])
->where('dtacct','=',$serahanpkb)
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class PortalBillplz extends Model
{
protected $table = 'portal_billplz_collection_id';
/**
* The attributes that are mass assignable.
*
* @var array
*/
// protected $fillable = [
// ];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
// protected $hidden = [];
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class TacExpressPayment extends Model
{
protected $table = 'tac_express_payment';
public $timestamps = false;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'norujukan','expired_at','tac_no'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
// protected $hidden = [];
}
+1 -1
View File
@@ -15,7 +15,7 @@ class TransactionOnline extends Model
* @var array
*/
protected $fillable = [
'nokp','reference_no','nosiri','total_payment','tarikh','masa','status'
'nokp','reference_no','nosiri','total_payment','tarikh','masa','status','billplz_id','kodcaw','norujukan','paid_at','customer_name','update_status','update_serahan'
];
/**
+10
View File
@@ -195,6 +195,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->get('online/transaction',['uses'=>'TransactionOnlineController@getLatestNosiri']);
$router->post('online/transaction',['uses'=>'TransactionOnlineController@create']);
$router->put('online/transaction',['uses'=>'TransactionOnlineController@updateStatus']);
$router->get('transaction/online/express',['uses'=>'TransactionOnlineController@getTransactionOnline']);
$router->get('transaction/online/update',['uses'=>'TransactionOnlineController@updateTransactionOnline']);
//ANSURAN UPAH API
@@ -422,6 +424,14 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->get('laporan/harian',['uses'=>'LaporanController@laporanHarian']);
$router->get('laporan/terkumpul',['uses'=>'LaporanController@laporanTerkumpul']);
//Collection ID Billplz
$router->get('billplz/collectionid',['uses'=>'PortalBillplzController@getCollectionIDCawangan']);
//Generate TAC Express Payment
$router->post('tac/generate/express_payment',['uses'=>'TacExpressPaymentController@generateTacExpressPayment']);
$router->get('tac/get/express_payment',['uses'=>'TacExpressPaymentController@getTacExpressPayment']);
$router->get('tac/verify/express_payment',['uses'=>'TacExpressPaymentController@verifyTacExpressPayment']);
});
$router->group(['prefix'=>'e-arrahn'], function () use ($router){