Improve Get /insurances/networks

This commit is contained in:
Djery-Tom 2022-02-01 08:23:52 +01:00
parent c3e69f71fc
commit 1436dbda22
2 changed files with 34 additions and 17 deletions

View File

@ -42,12 +42,22 @@ class InsuranceController extends Controller
* name="country_id",
* description="ID du pays",
* in="query",
* required=true,
* required=false,
* @OA\Schema(
* type="integer",
* default=78
* )
* ),
* @OA\Parameter(
* parameter="user_id",
* name="user_id",
* description="ID de l'utilisateur",
* in="query",
* required=true,
* @OA\Schema(
* type="integer",
* )
* ),
* @OA\Response(
* response=200,
* description="OK",
@ -66,26 +76,33 @@ class InsuranceController extends Controller
public function getInsurancesNetworks(Request $request)
{
$this->validate($request, [
'country_id' => 'nullable|integer|exists:countries,id'
'country_id' => 'nullable|integer|exists:countries,id',
'user_id' => 'nullable|integer|exists:users,id'
]);
$country = CountriesCurrency::findOrFail($request->input('country_id'));
$user_id = $request->input('user_id');
if (!empty($user_id)) {
$insurances = DB::select("SELECT n.id , n.name FROM networks n JOIN configWallet cw ON cw.id_network = n.id JOIN nh_networks_configs nhc
ON nhc.network_id = n.id JOIN nh_insurances nhi ON nhi.network_id = n.id WHERE nhi.user_id = :user_id AND cw.type = 'ilink_sante' AND n.status = 1", ['user_id' => $user_id]);
$insurances = DB::select("SELECT n.id , n.name , nhc.age_limit_of_insured_and_spouse, nhc.age_limit_of_child_beneficiary, nhc.max_number_of_beneficiaries, nhc.id as nhc_id
} else {
$country = CountriesCurrency::findOrFail($request->input('country_id'));
$insurances = DB::select("SELECT n.id , n.name , nhc.age_limit_of_insured_and_spouse, nhc.age_limit_of_child_beneficiary, nhc.max_number_of_beneficiaries, nhc.id as nhc_id
FROM networks n JOIN configWallet cw ON cw.id_network = n.id JOIN nh_networks_configs nhc
ON nhc.network_id = n.id WHERE n.country_id = :countryId AND cw.type = 'ilink_sante' AND n.status = 1", ['countryId' => $request->input('country_id')]);
foreach ($insurances as $insurance) {
$months_prices = DB::select("SELECT id, number_of_months , min_amount FROM nh_months_prices_grid WHERE nh_network_config_id = :nhc_id",
['nhc_id' => $insurance->nhc_id]);
foreach ($insurances as $insurance) {
$months_prices = DB::select("SELECT id, number_of_months , min_amount FROM nh_months_prices_grid WHERE nh_network_config_id = :nhc_id",
['nhc_id' => $insurance->nhc_id]);
foreach ($months_prices as $mp) {
$mp->min_amount = $this->toMoneyWithCurrencyCode($mp->min_amount, $country->currency_code ?? 'XAF');
foreach ($months_prices as $mp) {
$mp->min_amount = $this->toMoneyWithCurrencyCode($mp->min_amount, $country->currency_code ?? 'XAF');
}
$insurance->months_prices = $months_prices;
unset($insurance->nhc_id);
}
$insurance->months_prices = $months_prices;
unset($insurance->nhc_id);
}
return $this->successResponse($insurances);
}

View File

@ -146,13 +146,13 @@
<div class=WordSection1>
<span style='font-size:11.0pt;font-family:"Tahoma",sans-serif;color:black'>iLink World Corporation</span>
<span style='font-size:11.0pt;font-family:"Tahoma",sans-serif;color:black'>{{$hyper->network}}</span>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Tahoma",sans-serif;
color:black;margin-left: 45px;'>-------------------</span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Tahoma",sans-serif;
color:black'>Le numérique au service de l'inclusion financière</span></p>
{{-- <p class=MsoNormal><span style='font-size:11.0pt;font-family:"Tahoma",sans-serif;--}}
{{--color:black'>Le numérique au service de l'inclusion financière</span></p>--}}
<p class=MsoNormal align=center style='text-align:center ; margin-top: 150px'>
<b><u><span style='font-size:16.0pt;font-family:"Garamond",serif;color:black'>
@ -203,7 +203,7 @@ color:black'>Le numérique au service de l'inclusion financière</span></p>
<td width=113 valign=top style='width:84.55pt;background:#F2F2F2;padding:
0in 5.4pt 0in 5.4pt ; margin-right: 10.25pt'>
<p class=MsoNormal align=center style='text-align:center'><b><span
style='font-size:9.0pt;font-family:"Garamond",serif;color:black'>{{$hyper->lastname}}</span></b>
style='font-size:9.0pt;font-family:"Garamond",serif;color:black'>{{$hyper->network}}</span></b>
</p>
</td>
</tr>
@ -211,7 +211,7 @@ color:black'>Le numérique au service de l'inclusion financière</span></p>
<td width=142 valign=top style='width:106.35pt;border:none;border-right:solid #7F7F7F 1.0pt;
background:white;padding:0in 5.4pt 0in 5.4pt'>
<p class=MsoNormal align=right style='text-align:right'><i><span
style='font-size:9.0pt;font-family:"Garamond",serif;color:black'>{{__('messages.insurance_name')}}</span></i>
style='font-size:9.0pt;font-family:"Garamond",serif;color:black'>{{__('messages.institution_name')}}</span></i>
</p>
</td>
<td width=180 valign=top style='width:134.65pt;padding:0in 5.4pt 0in 5.4pt'>