fixing fractional bid issue
This commit is contained in:
@@ -180,9 +180,9 @@ class OverviewController extends Controller
|
||||
// return response()->json(['status' => 400, 'message' => 'This product has already been Sold']);
|
||||
// }
|
||||
// }
|
||||
// $checkAlreadySold = MarketplaceBuyerForm::where(['id'=>$buyerId,'status'=>'Sold'])->first();
|
||||
// if($checkAlreadySold)
|
||||
// {
|
||||
$checkAlreadySold = MarketplaceBuyerForm::where(['id'=>$buyerId,'status'=>'Sold'])->exists();
|
||||
if(!$checkAlreadySold)
|
||||
{
|
||||
// $marketPlaceId = $checkAlreadySold->associated_id;
|
||||
// if(MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->exists())
|
||||
// {
|
||||
@@ -206,28 +206,53 @@ class OverviewController extends Controller
|
||||
// // }
|
||||
// }else
|
||||
|
||||
|
||||
if($status == 'Sold'){
|
||||
// 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;
|
||||
$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)
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
|
||||
$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();
|
||||
$freValue = (int)$getFREData->current_market_value_of_the_property;
|
||||
$nowValue = $freValue - $getBuyingPurchaseValue;
|
||||
// $nowValue = -10;
|
||||
// dd($freValue,' - ',$getBuyingPurchaseValue,' = ',$nowValue);
|
||||
// dd($nowValue < 0 ? 'negative '.$nowValue : 'positive '.$nowValue);
|
||||
if($nowValue <= 0)
|
||||
{
|
||||
$updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([
|
||||
'current_market_value_of_the_property' => 0,
|
||||
]);
|
||||
}else if($nowValue > 0){
|
||||
$updatePrice = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->update([
|
||||
'current_market_value_of_the_property' => $nowValue,
|
||||
]);
|
||||
}
|
||||
// else{
|
||||
// return response()->json(['status' => 400, 'message' => 'Bid price is more than seller price with ₹'.abs($nowValue)]);
|
||||
// }
|
||||
}
|
||||
// dd('outside');
|
||||
}
|
||||
// dd('hello');
|
||||
$alreadySold = MarketplaceBuyerForm::where('id', $buyerId)->update([
|
||||
'status' => $status
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user