fix changes
This commit is contained in:
@@ -180,6 +180,54 @@ 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)
|
||||
// {
|
||||
// $marketPlaceId = $checkAlreadySold->associated_id;
|
||||
// if(MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->exists())
|
||||
// {
|
||||
// $getAIFData = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->first();
|
||||
// $oldUnit = (int)$getAIFData->no_of_units_you_wish_to_sell;
|
||||
// $newUnits = (int)$checkAlreadySold->no_of_units_you_wish_to_buy + $oldUnit;
|
||||
// $updateUnits = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->update([
|
||||
// 'no_of_units_you_wish_to_sell' => $newUnits,
|
||||
// ]);
|
||||
|
||||
// }
|
||||
// // elseif(MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->exists())
|
||||
// // {
|
||||
// // $getAIFData = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->first();
|
||||
// // $oldUnit = (int)$getAIFData->no_of_units_you_wish_to_sell;
|
||||
// // $newUnits = (int)$checkAlreadySold->no_of_units_you_wish_to_buy + $oldUnit;
|
||||
// // $updateUnits = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->update([
|
||||
// // 'no_of_units_you_wish_to_sell' => $newUnits,
|
||||
// // ]);
|
||||
|
||||
// // }
|
||||
// }else
|
||||
|
||||
|
||||
if($status == 'Sold'){
|
||||
$getMarketplaceBuyerUnit = MarketplaceBuyerForm::where('id', $buyerId)->first();
|
||||
$marketPlaceId = $getMarketplaceBuyerUnit->associated_id;
|
||||
$getUnits = (int)$getMarketplaceBuyerUnit->no_of_units_you_wish_to_buy;
|
||||
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)
|
||||
{
|
||||
$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']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$alreadySold = MarketplaceBuyerForm::where('id', $buyerId)->update([
|
||||
'status' => $status
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user