pembetulan api untuk pelanggan baru
This commit is contained in:
@@ -9,6 +9,7 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Services\Reports\GadaianService as ReportGadaianService;
|
||||
use App\Helper;
|
||||
use App\Services\Reports\RingkasanHarianService as ReportRingkasanHarianService;
|
||||
|
||||
|
||||
class AnalisaController extends Controller
|
||||
@@ -41,27 +42,21 @@ class AnalisaController extends Controller
|
||||
];
|
||||
})->values()->toArray();
|
||||
|
||||
$summary_gadaian_data = array_map(function ($db_connection) use ($startDate, $endDate) {
|
||||
$query = Gadai::on($db_connection)
|
||||
->select(
|
||||
DB::raw('count(DISTINCT nokp) as total_pelanggan_baru'),
|
||||
DB::raw('sum(berat) as sum_berat'),
|
||||
DB::raw('sum(nilaimarhun) as sum_nilai_marhun'),
|
||||
DB::raw('sum(pinjaman) as sum_pinjaman')
|
||||
)
|
||||
->whereIn('nokp', function ($sub) use ($startDate, $endDate) {
|
||||
$sub->select('nokp')
|
||||
->from('gadai as g2')
|
||||
->groupBy('nokp')
|
||||
->havingRaw('MIN(t_gadai) BETWEEN ? AND ?', [$startDate, $endDate]);
|
||||
});
|
||||
|
||||
return $query->get()->toArray();
|
||||
}, $active_cawangan_db_connection);
|
||||
|
||||
$response = array_map(function ($cawangan_detail, $summary_gadaian_data) {
|
||||
return array_merge($cawangan_detail, $summary_gadaian_data[0]);
|
||||
}, $active_cawangan_detail, $summary_gadaian_data);
|
||||
// Iterate through each branch and get data
|
||||
$response = array_map(function ($db_connection, $cawangan_detail) use ($request) {
|
||||
// Pass the required parameters to the service constructor
|
||||
$reportRingkasanHarianService = new ReportRingkasanHarianService($cawangan_detail['kodcaw'], $request);
|
||||
|
||||
// Get the customer count from the service
|
||||
$bilangan_customer_baru = $reportRingkasanHarianService->getCustomerSummary(); // Call public method
|
||||
|
||||
// Return the response
|
||||
return [
|
||||
'kodcaw' => $cawangan_detail['kodcaw'],
|
||||
'details_caw' => $cawangan_detail['details_caw'],
|
||||
'total_pelanggan_baru' => $bilangan_customer_baru,
|
||||
];
|
||||
}, $active_cawangan_db_connection, $active_cawangan_detail);
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
@@ -266,6 +266,12 @@ class RingkasanHarianService
|
||||
|
||||
}
|
||||
|
||||
// Public method that calls the private method
|
||||
public function getCustomerSummary()
|
||||
{
|
||||
return $this->getBilanganCustomerBaru(); // Access the private method here
|
||||
}
|
||||
|
||||
private function getBayarRugiLelong()
|
||||
{
|
||||
$bayarRugiLelong = TuntutBaki::on($this->connectionCawangan)
|
||||
|
||||
Reference in New Issue
Block a user