Merge branch 'main' of https://github.com/Ritikeshyadav/my-freeu into RitikeshFreeu

This commit is contained in:
Ritikesh yadav
2024-05-15 14:39:26 +05:30
24 changed files with 227 additions and 144 deletions

View File

@@ -208,59 +208,60 @@ class OverviewController extends Controller
// }else
// dd($request->all());
// if($status == 'Sold'){
$getMarketplaceBuyerUnit = MarketplaceBuyerForm::where('id', $buyerId)->first();
$marketPlaceId = $getMarketplaceBuyerUnit->associated_id;
$getUnits = (int)$getMarketplaceBuyerUnit->no_of_units_you_wish_to_buy ?? 0;
$getBuyingPurchaseValue = (int)$getMarketplaceBuyerUnit->getAttributes()['total_purchase_value'];
if(MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->exists())
{
$getAIFData = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->first();
$oldUnit = (int)$getAIFData->no_of_units_you_wish_to_sell;
$newUnits = $oldUnit - (int)$getUnits;
if($newUnits >= 0)
if($status == 'Sold'){
$getMarketplaceBuyerUnit = MarketplaceBuyerForm::where('id', $buyerId)->first();
$marketPlaceId = $getMarketplaceBuyerUnit->associated_id;
$getUnits = (int)$getMarketplaceBuyerUnit->no_of_units_you_wish_to_buy ?? 0;
$getBuyingPurchaseValue = (int)$getMarketplaceBuyerUnit->getAttributes()['total_purchase_value'];
if(MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->exists())
{
$updateUnits = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->update([
'no_of_units_you_wish_to_sell' => $newUnits,
$getAIFData = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->first();
$oldUnit = (int)$getAIFData->no_of_units_you_wish_to_sell;
$newUnits = $oldUnit - (int)$getUnits;
if($newUnits >= 0)
{
$updateUnits = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->update([
'no_of_units_you_wish_to_sell' => $newUnits,
]);
}
else{
return response()->json(['status' => 400, 'message' => 'Bid units is more than seller units with '.abs($newUnits).' units']);
}
}else if(MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->exists())
{
// dd('inside');
$getFREData = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->first();
if((int)$getFREData->current_market_value_of_the_property <= 0)
{
return response()->json(['status' => 400, 'message' => 'Product cannot be sold. because product has no value.']);
}
$freValue = (int)$getFREData->current_market_value_of_the_property;
$nowValue = $freValue - $getBuyingPurchaseValue;
$percentage = ($freValue - $getBuyingPurchaseValue) / $freValue * 100;
$expectedSellingPrice = (int)$getFREData->expected_selling_price;
$updateExpectedSellingPrice = $expectedSellingPrice * ($percentage / 100);
// dd($percentage,$updateExpectedSellingPrice);
if($nowValue <= 0)
{
$updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([
'current_market_value_of_the_property' => 0,
'expected_selling_price' => 0,
]);
}else if($nowValue > 0){
$updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([
'current_market_value_of_the_property' => $nowValue,
'expected_selling_price' => $updateExpectedSellingPrice,
]);
}
// else{
// return response()->json(['status' => 400, 'message' => 'Bid price is more than seller price with ₹'.abs($nowValue)]);
// }
}
else{
return response()->json(['status' => 400, 'message' => 'Bid units is more than seller units with '.abs($newUnits).' units']);
}
}else if(MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->exists())
{
// dd('inside');
$getFREData = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->first();
if((int)$getFREData->current_market_value_of_the_property <= 0)
{
return response()->json(['status' => 400, 'message' => 'Product cannot be sold. because product has no value.']);
}
$freValue = (int)$getFREData->current_market_value_of_the_property;
$nowValue = $freValue - $getBuyingPurchaseValue;
$percentage = ($freValue - $getBuyingPurchaseValue) / $freValue * 100;
$expectedSellingPrice = (int)$getFREData->expected_selling_price;
$updateExpectedSellingPrice = $expectedSellingPrice * ($percentage / 100);
// dd($percentage,$updateExpectedSellingPrice);
if($nowValue <= 0)
{
$updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([
'current_market_value_of_the_property' => 0,
'expected_selling_price' => 0,
]);
}else if($nowValue > 0){
$updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([
'current_market_value_of_the_property' => $nowValue,
'expected_selling_price' => $updateExpectedSellingPrice,
]);
}
// else{
// return response()->json(['status' => 400, 'message' => 'Bid price is more than seller price with ₹'.abs($nowValue)]);
// }
// dd('outside');
}
// dd('outside');
}
// dd('hello');
$alreadySold = MarketplaceBuyerForm::where('id', $buyerId)->update([