Bugfix/list clickup issue (#5)
Reviewed-on: #5 Co-authored-by: ISMAIL MASSERAN <ismail@koppkb.com> Co-committed-by: ISMAIL MASSERAN <ismail@koppkb.com>
This commit was merged in pull request #5.
This commit is contained in:
@@ -2,21 +2,20 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Resit;
|
||||
use App\Http\Controllers\ApiController;
|
||||
use App\Services\BillplzService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Payment;
|
||||
use App\Http\Controllers\ApiController;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CheckBillplzPayments extends Command
|
||||
{
|
||||
protected $signature = 'billplz:semak
|
||||
{--date= : Date in YYYY-MM-DD format}
|
||||
{--preview : Preview pending resits only}';
|
||||
|
||||
protected $description = 'Check Billplz payment status and update database';
|
||||
|
||||
protected $billplzService;
|
||||
@@ -28,85 +27,86 @@ class CheckBillplzPayments extends Command
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$date = $this->option('date') ?? now()->toDateString();
|
||||
$preview = $this->option('preview');
|
||||
{
|
||||
$date = $this->option('date') ?? now()->toDateString();
|
||||
$preview = $this->option('preview');
|
||||
|
||||
// Validate date
|
||||
try {
|
||||
$dateObj = Carbon::createFromFormat('Y-m-d', $date);
|
||||
} catch (\Exception $e) {
|
||||
$this->error("Invalid date format. Use YYYY-MM-DD.");
|
||||
return 1;
|
||||
}
|
||||
// Validate date
|
||||
try {
|
||||
$dateObj = Carbon::createFromFormat('Y-m-d', $date);
|
||||
} catch (\Exception $e) {
|
||||
$this->error('Invalid date format. Use YYYY-MM-DD.');
|
||||
|
||||
$this->info("Retrying Billplz check for date: {$dateObj->toDateString()}");
|
||||
return 1;
|
||||
}
|
||||
|
||||
$date = $dateObj->toDateString();
|
||||
$this->info("Retrying Billplz check for date: {$dateObj->toDateString()}");
|
||||
|
||||
$pendingResits = DB::table('resit as r')
|
||||
->join('payment as p', 'p.resit_id', '=', 'r.id')
|
||||
->join(DB::raw('(
|
||||
$date = $dateObj->toDateString();
|
||||
|
||||
$pendingResits = DB::table('resit as r')
|
||||
->join('payment as p', 'p.resit_id', '=', 'r.id')
|
||||
->join(DB::raw('(
|
||||
SELECT user_id, total_payment, MIN(id) AS min_id
|
||||
FROM payment
|
||||
GROUP BY user_id, total_payment
|
||||
) as unique_payment'), 'p.id', '=', 'unique_payment.min_id')
|
||||
->whereNull('r.status')
|
||||
->where('p.status', 0)
|
||||
->whereNotNull('r.billplz_id')
|
||||
->whereDate('r.created_at', $date)
|
||||
->where('r.billplz_id', 'NOT LIKE', '%CDM%')
|
||||
->select('r.*', 'p.id as payment_id', 'p.total_payment')
|
||||
->distinct()
|
||||
->get();
|
||||
->whereNull('r.status')
|
||||
->where('p.status', 0)
|
||||
->whereNotNull('r.billplz_id')
|
||||
->whereDate('r.created_at', $date)
|
||||
->where('r.billplz_id', 'NOT LIKE', '%CDM%')
|
||||
->select('r.*', 'p.id as payment_id', 'p.total_payment')
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
if ($pendingResits->isEmpty()) {
|
||||
$this->info('Tiada Resit belum dibayar ditemui.');
|
||||
return 0;
|
||||
}
|
||||
if ($pendingResits->isEmpty()) {
|
||||
$this->info('Tiada Resit belum dibayar ditemui.');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($preview) {
|
||||
$this->info('Preview mode aktif. Senarai Resit:');
|
||||
foreach ($pendingResits as $resit) {
|
||||
$this->line("Resit ID: {$resit->id} | Billplz ID: {$resit->billplz_id} | Jumlah: RM{$resit->total_payment}");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($preview) {
|
||||
$this->info("Preview mode aktif. Senarai Resit:");
|
||||
foreach ($pendingResits as $resit) {
|
||||
$this->line("Resit ID: {$resit->id} | Billplz ID: {$resit->billplz_id} | Jumlah: RM{$resit->total_payment}");
|
||||
$this->info("Semak Resit ID: {$resit->id}");
|
||||
|
||||
$billData = $this->billplzService->testGetBill($resit->billplz_id);
|
||||
|
||||
if (isset($billData['error'])) {
|
||||
$this->error("❌ Gagal semak Billplz untuk Resit {$resit->id}: {$billData['details']}");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($billData['paid']) && $billData['paid'] === true) {
|
||||
// Simulate Request object
|
||||
$data = [
|
||||
'billplz' => [
|
||||
'id' => $resit->billplz_id,
|
||||
'paid' => 'true',
|
||||
'paid_at' => $billData['paid_at'] ?? now()->toDateTimeString(),
|
||||
],
|
||||
];
|
||||
// dd($data);
|
||||
|
||||
$apiController = App::make(ApiController::class);
|
||||
$apiController->processPaidResit($data);
|
||||
// dd($fakeRequest);
|
||||
|
||||
$this->info("✅ Resit ID {$resit->id} handled via processPaidResit.");
|
||||
} else {
|
||||
$this->info("ℹ️ Resit ID {$resit->id} masih belum dibayar.");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
$this->info('Semakan semula Billplz selesai.');
|
||||
}
|
||||
|
||||
foreach ($pendingResits as $resit) {
|
||||
$this->info("Semak Resit ID: {$resit->id}");
|
||||
|
||||
$billData = $this->billplzService->testGetBill($resit->billplz_id);
|
||||
|
||||
if (isset($billData['error'])) {
|
||||
$this->error("❌ Gagal semak Billplz untuk Resit {$resit->id}: {$billData['details']}");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($billData['paid']) && $billData['paid'] === true) {
|
||||
// Simulate Request object
|
||||
$data = [
|
||||
'billplz' => [
|
||||
'id' => $resit->billplz_id,
|
||||
'paid' => 'true',
|
||||
'paid_at' => $billData['paid_at'] ?? now()->toDateTimeString(),
|
||||
]
|
||||
];
|
||||
// dd($data);
|
||||
|
||||
$apiController = App::make(ApiController::class);
|
||||
$apiController->processPaidResit($data);
|
||||
// dd($fakeRequest);
|
||||
|
||||
|
||||
$this->info("✅ Resit ID {$resit->id} handled via processPaidResit.");
|
||||
}else {
|
||||
$this->info("ℹ️ Resit ID {$resit->id} masih belum dibayar.");
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Semakan semula Billplz selesai.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,32 +40,32 @@ class WebpMakeExecutables extends Command
|
||||
$DS = DIRECTORY_SEPARATOR;
|
||||
|
||||
$cwebp_compilers = [
|
||||
'Windows' => 'binaries' . $DS . 'libwebp-1.2.4-windows-x64' . $DS . 'bin' . $DS . 'cwebp',
|
||||
'Linux' => 'binaries' . $DS . 'libwebp-1.2.4-linux-x86-64' . $DS . 'bin' . $DS .'cwebp',
|
||||
'Windows' => 'binaries'.$DS.'libwebp-1.2.4-windows-x64'.$DS.'bin'.$DS.'cwebp',
|
||||
'Linux' => 'binaries'.$DS.'libwebp-1.2.4-linux-x86-64'.$DS.'bin'.$DS.'cwebp',
|
||||
'Darwin' => [
|
||||
'X86-64' => 'binaries' . $DS . 'libwebp-1.2.4-mac-X86-64' . $DS . 'bin' . $DS . 'cwebp',
|
||||
'arm64' => 'binaries' . $DS . 'libwebp-1.2.4-mac-arm64' . $DS . 'bin' . $DS .'cwebp',
|
||||
'X86-64' => 'binaries'.$DS.'libwebp-1.2.4-mac-X86-64'.$DS.'bin'.$DS.'cwebp',
|
||||
'arm64' => 'binaries'.$DS.'libwebp-1.2.4-mac-arm64'.$DS.'bin'.$DS.'cwebp',
|
||||
],
|
||||
];
|
||||
|
||||
$server_operating_system = explode(' ', trim(php_uname()))[0];
|
||||
$server_processor_architecture = trim(php_uname('m'));
|
||||
|
||||
if ($server_operating_system === 'Windows') {
|
||||
$this->error('Windows OS are not permitted');
|
||||
|
||||
if($server_operating_system === 'Windows'){
|
||||
$this->error('Windows OS are not permitted');
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($server_operating_system === 'Darwin') {
|
||||
$webp_binary_path = resource_path($cwebp_compilers['Darwin'][$server_processor_architecture]);
|
||||
$webp_binary_path = resource_path($cwebp_compilers['Darwin'][$server_processor_architecture]);
|
||||
}
|
||||
|
||||
if ($server_operating_system === 'Linux') {
|
||||
$webp_binary_path = resource_path($cwebp_compilers[$server_operating_system]);
|
||||
}
|
||||
|
||||
exec('chmod +x ' . $webp_binary_path, $output, $result);
|
||||
exec('chmod +x '.$webp_binary_path, $output, $result);
|
||||
|
||||
$this->info('Webp binaries are now executables');
|
||||
}
|
||||
|
||||
@@ -42,13 +42,10 @@ class kemaskiniCawanganLelong extends Command
|
||||
{
|
||||
|
||||
$lelong = Lelong::with('cawangan')->select('id')->get();
|
||||
foreach($lelong as $lel)
|
||||
{
|
||||
foreach($lel->cawangan as $caw)
|
||||
{
|
||||
foreach ($lelong as $lel) {
|
||||
foreach ($lel->cawangan as $caw) {
|
||||
$lelong_bid = LelongBid::where('kodcaw', $caw->caw_code)->where('lelong_id', $lel->id)->first();
|
||||
if($lelong_bid == null)
|
||||
{
|
||||
if ($lelong_bid == null) {
|
||||
CawanganLelong::where('caw_id', $caw->id)->where('lelong_id', $lel->id)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\LelongBid;
|
||||
use App\Models\Gadai;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\TransaksiKeuntungan;
|
||||
use App\Models\LelongBid;
|
||||
use App\Models\LelongTebus;
|
||||
use App\Models\LogUser;
|
||||
use App\Models\TransaksiKeuntungan;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class kemaskiniLelong extends Command
|
||||
@@ -49,71 +49,70 @@ class kemaskiniLelong extends Command
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
$data = [];
|
||||
|
||||
$lelongbids = LelongBid::where('status_jual',0)->get();
|
||||
$lelongbids = LelongBid::where('status_jual', 0)->get();
|
||||
|
||||
foreach($lelongbids as $index=>$lelongbid){
|
||||
$gadai = Gadai::on($lelongbid->kodcaw)->where('norujukan',$lelongbid->norujukan)->first();
|
||||
foreach ($lelongbids as $index => $lelongbid) {
|
||||
$gadai = Gadai::on($lelongbid->kodcaw)->where('norujukan', $lelongbid->norujukan)->first();
|
||||
$keluar_lelong = false;
|
||||
$sebab_keluar = '';
|
||||
if($lelongbid->fasa == '1'){
|
||||
if($gadai->sttebus == 'T'){
|
||||
if ($lelongbid->fasa == '1') {
|
||||
if ($gadai->sttebus == 'T') {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'T';
|
||||
}elseif($gadai->sttebus == 'L'){
|
||||
} elseif ($gadai->sttebus == 'L') {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'L';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$telahbayar = $gadai->hargajualan - $gadai->bakihargajualan;
|
||||
$upah6bln_raw = $gadai->bakiupah - 0.5;
|
||||
if(bcdiv($telahbayar,1,1) >= bcdiv($upah6bln_raw,1,1)){
|
||||
if (bcdiv($telahbayar, 1, 1) >= bcdiv($upah6bln_raw, 1, 1)) {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'A';
|
||||
$updategadai = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->post(config('app.api_url').'taglel/revert',[
|
||||
'kodcaw'=>$lelongbid->kodcaw,
|
||||
'norujukan'=>$lelongbid->norujukan
|
||||
])
|
||||
->json();
|
||||
}else{
|
||||
if($gadai->tagbaru == '0'){
|
||||
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan',$lelongbid->norujukan)->sum('keuntungan_rebet');
|
||||
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan',$lelongbid->norujukan)->sum('bayaran_keuntungan');
|
||||
->post(config('app.api_url').'taglel/revert', [
|
||||
'kodcaw' => $lelongbid->kodcaw,
|
||||
'norujukan' => $lelongbid->norujukan,
|
||||
])
|
||||
->json();
|
||||
} else {
|
||||
if ($gadai->tagbaru == '0') {
|
||||
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan', $lelongbid->norujukan)->sum('keuntungan_rebet');
|
||||
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan', $lelongbid->norujukan)->sum('bayaran_keuntungan');
|
||||
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
|
||||
if($gadai->tempohbayar == $gadai->tempoh ){
|
||||
if ($gadai->tempohbayar == $gadai->tempoh) {
|
||||
$keuntungan = 0.00;
|
||||
}else{
|
||||
} else {
|
||||
$jbg = $gadai->tempoh - $gadai->tempohbayar;
|
||||
$jbg2 = 12 - $gadai->tempohbayar;
|
||||
if($gadai->tempoh <= '12.00'){
|
||||
$keuntungan = bcdiv(($jbg)*$gadai->kadarupah/100*$gadai->bakipjm,1,1)-$beza_keuntungan;
|
||||
}else{
|
||||
$keuntungan = bcdiv(($jbg2)*$gadai->kadarupah/100*$gadai->bakipjm,1,1)-$beza_keuntungan;
|
||||
if ($gadai->tempoh <= '12.00') {
|
||||
$keuntungan = bcdiv(($jbg) * $gadai->kadarupah / 100 * $gadai->bakipjm, 1, 1) - $beza_keuntungan;
|
||||
} else {
|
||||
$keuntungan = bcdiv(($jbg2) * $gadai->kadarupah / 100 * $gadai->bakipjm, 1, 1) - $beza_keuntungan;
|
||||
}
|
||||
|
||||
}
|
||||
$checkdataxlaku = LelongBid::where('norujukan', $lelongbid->norujukan)
|
||||
->where('xlaku', 1)
|
||||
->first();
|
||||
if (!$checkdataxlaku) {
|
||||
if (! $checkdataxlaku) {
|
||||
$lelongbid->jbg = $gadai->tempoh;
|
||||
$lelongbid->pinjaman = $gadai->bakipjm;
|
||||
$lelongbid->bakiupah = $keuntungan;
|
||||
$lelongbid->save();
|
||||
}
|
||||
}else if($gadai->tagbaru == '1'){
|
||||
//kiraan keuntungan ujrah
|
||||
} elseif ($gadai->tagbaru == '1') {
|
||||
// kiraan keuntungan ujrah
|
||||
$jeniskeuntungan = 'onepercent';
|
||||
// $keuntungan1 = Http::get(config('app.api_ujrah_url'). 'upahrebettawarruq/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan.'/'.$jeniskeuntungan)->json();
|
||||
$ujrahonepercentrebet = Http::get(config('app.api_ujrah_url'). 'kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json();
|
||||
$ujrahonepercentrebet = Http::get(config('app.api_ujrah_url').'kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json();
|
||||
$rounded_ujrah = $ujrahonepercentrebet['ujrah'];
|
||||
$rounded_onepercent = $ujrahonepercentrebet['onepercent'];
|
||||
$keuntungan = $rounded_ujrah + $rounded_onepercent;
|
||||
|
||||
$checkdataxlaku = LelongBid::where('norujukan', $lelongbid->norujukan)
|
||||
->where('xlaku', 1)
|
||||
->first();
|
||||
if (!$checkdataxlaku) {
|
||||
->where('xlaku', 1)
|
||||
->first();
|
||||
if (! $checkdataxlaku) {
|
||||
$lelongbid->jbg = $gadai->tempoh;
|
||||
$lelongbid->pinjaman = $gadai->bakipjm;
|
||||
$lelongbid->bakiupah = $keuntungan;
|
||||
@@ -125,56 +124,53 @@ class kemaskiniLelong extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($gadai->sttebus == 'T'){
|
||||
} else {
|
||||
if ($gadai->sttebus == 'T') {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'T';
|
||||
}elseif($gadai->sttebus == 'L'){
|
||||
} elseif ($gadai->sttebus == 'L') {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'L';
|
||||
}else{
|
||||
if($gadai->tagbaru == '0'){
|
||||
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan',$lelongbid->norujukan)->sum('keuntungan_rebet');
|
||||
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan',$lelongbid->norujukan)->sum('bayaran_keuntungan');
|
||||
} else {
|
||||
if ($gadai->tagbaru == '0') {
|
||||
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan', $lelongbid->norujukan)->sum('keuntungan_rebet');
|
||||
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan', $lelongbid->norujukan)->sum('bayaran_keuntungan');
|
||||
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
|
||||
if($gadai->tempohbayar == 12){
|
||||
if ($gadai->tempohbayar == 12) {
|
||||
$keuntungan = 0.00;
|
||||
}
|
||||
elseif($gadai->tempohbayar == $gadai->tempoh ){
|
||||
} elseif ($gadai->tempohbayar == $gadai->tempoh) {
|
||||
$keuntungan = 0.00;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$jbg = $gadai->tempoh - $gadai->tempohbayar;
|
||||
$jbg2 = 12 - $gadai->tempohbayar;
|
||||
if($gadai->tempoh <= '12.00'){
|
||||
$keuntungan = bcdiv(($jbg)*$gadai->kadarupah/100*$gadai->bakipjm,1,1)-$beza_keuntungan;
|
||||
}else{
|
||||
$keuntungan = bcdiv(($jbg2)*$gadai->kadarupah/100*$gadai->bakipjm,1,1)-$beza_keuntungan;
|
||||
if ($gadai->tempoh <= '12.00') {
|
||||
$keuntungan = bcdiv(($jbg) * $gadai->kadarupah / 100 * $gadai->bakipjm, 1, 1) - $beza_keuntungan;
|
||||
} else {
|
||||
$keuntungan = bcdiv(($jbg2) * $gadai->kadarupah / 100 * $gadai->bakipjm, 1, 1) - $beza_keuntungan;
|
||||
}
|
||||
}
|
||||
$checkdataxlaku = LelongBid::where('norujukan', $lelongbid->norujukan)
|
||||
->where('xlaku', 1)
|
||||
->first();
|
||||
if (!$checkdataxlaku) {
|
||||
if (! $checkdataxlaku) {
|
||||
$lelongbid->jbg = $gadai->tempoh;
|
||||
$lelongbid->pinjaman = $gadai->bakipjm;
|
||||
$lelongbid->bakiupah = $keuntungan;
|
||||
$lelongbid->save();
|
||||
}
|
||||
}elseif($gadai->tagbaru == '1'){
|
||||
//kiraan keuntungan ujrah
|
||||
} elseif ($gadai->tagbaru == '1') {
|
||||
// kiraan keuntungan ujrah
|
||||
$jeniskeuntungan = 'onepercent';
|
||||
// $keuntungan1 = Http::get(config('app.api_ujrah_url'). 'upahrebettawarruq/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan.'/'.$jeniskeuntungan)->json();
|
||||
$ujrahonepercentrebet = Http::get(config('app.api_ujrah_url'). 'kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json();
|
||||
$ujrahonepercentrebet = Http::get(config('app.api_ujrah_url').'kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json();
|
||||
$rounded_ujrah = $ujrahonepercentrebet['ujrah'];
|
||||
$rounded_onepercent = $ujrahonepercentrebet['onepercent'];
|
||||
$keuntungan = $rounded_ujrah + $rounded_onepercent;
|
||||
|
||||
|
||||
$checkdataxlaku = LelongBid::where('norujukan', $lelongbid->norujukan)
|
||||
->where('xlaku', 1)
|
||||
->first();
|
||||
if (!$checkdataxlaku) {
|
||||
if (! $checkdataxlaku) {
|
||||
$lelongbid->jbg = $gadai->tempoh;
|
||||
$lelongbid->pinjaman = $gadai->bakipjm;
|
||||
$lelongbid->bakiupah = $keuntungan;
|
||||
@@ -186,7 +182,7 @@ class kemaskiniLelong extends Command
|
||||
}
|
||||
}
|
||||
|
||||
if($keluar_lelong == true){
|
||||
if ($keluar_lelong == true) {
|
||||
$lelongtebus = new LelongTebus;
|
||||
$lelongtebus->tarikh = $currentdate;
|
||||
$lelongtebus->kodcaw = $lelongbid->kodcaw;
|
||||
@@ -201,27 +197,26 @@ class kemaskiniLelong extends Command
|
||||
$lelongtebus->save();
|
||||
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = User::where('name','System')->first()->id;
|
||||
$loguser->user_id = User::where('name', 'System')->first()->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = 'System';
|
||||
$loguser->nama_user = 'System';
|
||||
$loguser->norujukan = $gadai->norujukan;
|
||||
$loguser->nota = $sebab_keluar == 'A' ? ' KELUAR LELONG '.$lelongbid->lelong_id : ' TEBUS LELONG '.$lelongbid->lelong_id ;
|
||||
$loguser->nota = $sebab_keluar == 'A' ? ' KELUAR LELONG '.$lelongbid->lelong_id : ' TEBUS LELONG '.$lelongbid->lelong_id;
|
||||
$loguser->save();
|
||||
|
||||
$lelongbid->delete();
|
||||
}else{
|
||||
} else {
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = User::where('name','System')->first()->id;
|
||||
$loguser->user_id = User::where('name', 'System')->first()->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = 'System';
|
||||
$loguser->nama_user = 'System';
|
||||
$loguser->norujukan = $gadai->norujukan;
|
||||
if($gadai->tagbaru == '0'){
|
||||
$loguser->nota = $lelongbid->lelong_id.' Kemaskini Tempoh/Bakipjm/Keuntungan SAG LAMA' ;
|
||||
}
|
||||
elseif($gadai->tagbaru == '1'){
|
||||
$loguser->nota = $lelongbid->lelong_id.' Kemaskini Tempoh/Bakipjm/Keuntungan UJRAH '.$keuntungan ;
|
||||
if ($gadai->tagbaru == '0') {
|
||||
$loguser->nota = $lelongbid->lelong_id.' Kemaskini Tempoh/Bakipjm/Keuntungan SAG LAMA';
|
||||
} elseif ($gadai->tagbaru == '1') {
|
||||
$loguser->nota = $lelongbid->lelong_id.' Kemaskini Tempoh/Bakipjm/Keuntungan UJRAH '.$keuntungan;
|
||||
}
|
||||
$loguser->save();
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\LelongBid;
|
||||
use App\Models\Gadai;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\TransaksiKeuntungan;
|
||||
use App\Models\LelongBid;
|
||||
use App\Models\LelongTebus;
|
||||
use App\Models\LogUser;
|
||||
use App\Models\TransaksiKeuntungan;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class kemaskiniLelongUjrah extends Command
|
||||
@@ -49,46 +49,45 @@ class kemaskiniLelongUjrah extends Command
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
$data = [];
|
||||
|
||||
$lelongbids = LelongBid::where('status_jual',0)->where('tagujrah','1')->get();
|
||||
$lelongbids = LelongBid::where('status_jual', 0)->where('tagujrah', '1')->get();
|
||||
// dd($lelongbids);
|
||||
|
||||
foreach($lelongbids as $index=>$lelongbid){
|
||||
$gadai = Gadai::on($lelongbid->kodcaw)->where('norujukan',$lelongbid->norujukan)->first();
|
||||
foreach ($lelongbids as $index => $lelongbid) {
|
||||
$gadai = Gadai::on($lelongbid->kodcaw)->where('norujukan', $lelongbid->norujukan)->first();
|
||||
$keluar_lelong = false;
|
||||
$sebab_keluar = '';
|
||||
if($lelongbid->fasa == '1'){
|
||||
if($gadai->sttebus == 'T'){
|
||||
if ($lelongbid->fasa == '1') {
|
||||
if ($gadai->sttebus == 'T') {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'T';
|
||||
}elseif($gadai->sttebus == 'L'){
|
||||
} elseif ($gadai->sttebus == 'L') {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'L';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$telahbayar = $gadai->hargajualan - $gadai->bakihargajualan;
|
||||
$upah6bln_raw = $gadai->bakiupah - 0.5;
|
||||
if(bcdiv($telahbayar,1,1) >= bcdiv($upah6bln_raw,1,1)){
|
||||
if (bcdiv($telahbayar, 1, 1) >= bcdiv($upah6bln_raw, 1, 1)) {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'A';
|
||||
$updategadai = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->post(config('app.api_url').'taglel/revert',[
|
||||
'kodcaw'=>$lelongbid->kodcaw,
|
||||
'norujukan'=>$lelongbid->norujukan
|
||||
])
|
||||
->json();
|
||||
}else{
|
||||
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan',$lelongbid->norujukan)->sum('keuntungan_rebet');
|
||||
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan',$lelongbid->norujukan)->sum('bayaran_keuntungan');
|
||||
->post(config('app.api_url').'taglel/revert', [
|
||||
'kodcaw' => $lelongbid->kodcaw,
|
||||
'norujukan' => $lelongbid->norujukan,
|
||||
])
|
||||
->json();
|
||||
} else {
|
||||
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan', $lelongbid->norujukan)->sum('keuntungan_rebet');
|
||||
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan', $lelongbid->norujukan)->sum('bayaran_keuntungan');
|
||||
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
|
||||
if($gadai->tempohbayar == $gadai->tempoh ){
|
||||
if ($gadai->tempohbayar == $gadai->tempoh) {
|
||||
$keuntungan = 0.00;
|
||||
$rounded_ujrah = 0.00;
|
||||
$rounded_onepercent = 0.00;
|
||||
}else{
|
||||
//kiraan keuntungan ujrah
|
||||
} else {
|
||||
// kiraan keuntungan ujrah
|
||||
$jeniskeuntungan = 'onepercent';
|
||||
// $keuntungan1 = Http::get(config('app.api_ujrah_url'). 'upahrebettawarruq/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan.'/'.$jeniskeuntungan)->json();
|
||||
$ujrahonepercentrebet = Http::get(config('app.api_ujrah_url'). 'kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json();
|
||||
$ujrahonepercentrebet = Http::get(config('app.api_ujrah_url').'kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json();
|
||||
$rounded_ujrah = $ujrahonepercentrebet['ujrah'];
|
||||
$rounded_onepercent = $ujrahonepercentrebet['onepercent'];
|
||||
$keuntungan = $rounded_ujrah + $rounded_onepercent;
|
||||
@@ -97,62 +96,60 @@ class kemaskiniLelongUjrah extends Command
|
||||
$checkdataxlaku = LelongBid::where('norujukan', $lelongbid->norujukan)
|
||||
->where('xlaku', 1)
|
||||
->first();
|
||||
if (!$checkdataxlaku) {
|
||||
if (! $checkdataxlaku) {
|
||||
$lelongbid->jbg = $gadai->tempoh;
|
||||
$lelongbid->pinjaman = $gadai->bakipjm;
|
||||
$lelongbid->bakiupah = $keuntungan;
|
||||
$lelongbid->ujrah = $rounded_ujrah;
|
||||
$lelongbid->onepercent = $rounded_onepercent;
|
||||
$lelongbid->bakiupah = $keuntungan;
|
||||
$lelongbid->ujrah = $rounded_ujrah;
|
||||
$lelongbid->onepercent = $rounded_onepercent;
|
||||
$lelongbid->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if($gadai->sttebus == 'T'){
|
||||
} else {
|
||||
if ($gadai->sttebus == 'T') {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'T';
|
||||
}elseif($gadai->sttebus == 'L'){
|
||||
} elseif ($gadai->sttebus == 'L') {
|
||||
$keluar_lelong = true;
|
||||
$sebab_keluar = 'L';
|
||||
}else{
|
||||
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan',$lelongbid->norujukan)->sum('keuntungan_rebet');
|
||||
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan',$lelongbid->norujukan)->sum('bayaran_keuntungan');
|
||||
} else {
|
||||
$total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan', $lelongbid->norujukan)->sum('keuntungan_rebet');
|
||||
$total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan', $lelongbid->norujukan)->sum('bayaran_keuntungan');
|
||||
$beza_keuntungan = $total_untung_asal - $total_untung_rebet;
|
||||
if($gadai->tempohbayar == 12){
|
||||
if ($gadai->tempohbayar == 12) {
|
||||
$keuntungan = 0.00;
|
||||
$rounded_ujrah = 0.00;
|
||||
$rounded_onepercent = 0.00;
|
||||
}
|
||||
elseif($gadai->tempohbayar == $gadai->tempoh ){
|
||||
} elseif ($gadai->tempohbayar == $gadai->tempoh) {
|
||||
$keuntungan = 0.00;
|
||||
$rounded_ujrah = 0.00;
|
||||
$rounded_onepercent = 0.00;
|
||||
}
|
||||
else{
|
||||
//kiraan keuntungan ujrah
|
||||
} else {
|
||||
// kiraan keuntungan ujrah
|
||||
$jeniskeuntungan = 'onepercent';
|
||||
// $keuntungan1 = Http::get(config('app.api_ujrah_url'). 'upahrebettawarruq/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan.'/'.$jeniskeuntungan)->json();
|
||||
$ujrahonepercentrebet = Http::get(config('app.api_ujrah_url'). 'kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json();
|
||||
$ujrahonepercentrebet = Http::get(config('app.api_ujrah_url').'kiraupahUjrahOnePercentRebate/'.$lelongbid->kodcaw.'/'.$lelongbid->norujukan)->json();
|
||||
$rounded_ujrah = $ujrahonepercentrebet['ujrah'];
|
||||
$rounded_onepercent = $ujrahonepercentrebet['onepercent'];
|
||||
$keuntungan = $rounded_ujrah + $rounded_onepercent;
|
||||
|
||||
|
||||
}
|
||||
$checkdataxlaku = LelongBid::where('norujukan', $lelongbid->norujukan)
|
||||
->where('xlaku', 1)
|
||||
->first();
|
||||
if (!$checkdataxlaku) {
|
||||
if (! $checkdataxlaku) {
|
||||
$lelongbid->jbg = $gadai->tempoh;
|
||||
$lelongbid->pinjaman = $gadai->bakipjm;
|
||||
$lelongbid->bakiupah = $keuntungan;
|
||||
$lelongbid->ujrah = $rounded_ujrah;
|
||||
$lelongbid->onepercent = $rounded_onepercent;
|
||||
$lelongbid->ujrah = $rounded_ujrah;
|
||||
$lelongbid->onepercent = $rounded_onepercent;
|
||||
$lelongbid->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($keluar_lelong == true){
|
||||
if ($keluar_lelong == true) {
|
||||
$lelongtebus = new LelongTebus;
|
||||
$lelongtebus->tarikh = $currentdate;
|
||||
$lelongtebus->kodcaw = $lelongbid->kodcaw;
|
||||
@@ -167,23 +164,23 @@ class kemaskiniLelongUjrah extends Command
|
||||
$lelongtebus->save();
|
||||
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = User::where('name','System')->first()->id;
|
||||
$loguser->user_id = User::where('name', 'System')->first()->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = 'System';
|
||||
$loguser->nama_user = 'System';
|
||||
$loguser->norujukan = $gadai->norujukan;
|
||||
$loguser->nota = $sebab_keluar == 'A' ? ' KELUAR LELONG UJRAH '.$lelongbid->lelong_id : ' TEBUS LELONG UJRAH '.$lelongbid->lelong_id ;
|
||||
$loguser->nota = $sebab_keluar == 'A' ? ' KELUAR LELONG UJRAH '.$lelongbid->lelong_id : ' TEBUS LELONG UJRAH '.$lelongbid->lelong_id;
|
||||
$loguser->save();
|
||||
|
||||
$lelongbid->delete();
|
||||
}else{
|
||||
} else {
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = User::where('name','System')->first()->id;
|
||||
$loguser->user_id = User::where('name', 'System')->first()->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = 'System';
|
||||
$loguser->nama_user = 'System';
|
||||
$loguser->norujukan = $gadai->norujukan;
|
||||
$loguser->nota = $lelongbid->lelong_id.' Kemaskini Tempoh/Bakipjm/Keuntungan Ujrah' ;
|
||||
$loguser->nota = $lelongbid->lelong_id.' Kemaskini Tempoh/Bakipjm/Keuntungan Ujrah';
|
||||
$loguser->save();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ class Kernel extends ConsoleKernel
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
|
||||
Reference in New Issue
Block a user