fixing bid issue

This commit is contained in:
Ritikesh yadav
2024-05-16 11:53:28 +05:30
parent 8889b612de
commit 5a6f82f8a3
4 changed files with 32 additions and 21 deletions

View File

@@ -181,9 +181,9 @@ class OverviewController extends Controller
// return response()->json(['status' => 400, 'message' => 'This product has already been Sold']);
// }
// }
$checkAlreadySold = MarketplaceBuyerForm::where(['id'=>$buyerId,'status'=>'Sold'])->exists();
if(!$checkAlreadySold)
{
// $checkAlreadySold = MarketplaceBuyerForm::where(['id'=>$buyerId,'status'=>'Sold'])->exists();
// if(!$checkAlreadySold)
// {
// $marketPlaceId = $checkAlreadySold->associated_id;
// if(MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->exists())
// {
@@ -213,7 +213,7 @@ class OverviewController extends Controller
$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())
if(MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->exists() && $getMarketplaceBuyerUnit->table == 'marketplace_aif_sellers')
{
$getAIFData = MarketplaceAlternativeInvestmentFundSeller::where('id',$marketPlaceId)->first();
$oldUnit = (int)$getAIFData->no_of_units_you_wish_to_sell;
@@ -228,7 +228,7 @@ class OverviewController extends Controller
return response()->json(['status' => 400, 'message' => 'Bid units is more than seller units with '.abs($newUnits).' units']);
}
}else if(MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->exists())
}else if(MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->exists() && $getMarketplaceBuyerUnit->table == 'marketplace_fre_sellers')
{
// dd('inside');
$getFREData = MarketplaceFractionalRealEstateSeller::where('id',$marketPlaceId)->first();
@@ -262,7 +262,7 @@ class OverviewController extends Controller
}
// dd('outside');
}
}
// }
// dd('hello');
$alreadySold = MarketplaceBuyerForm::where('id', $buyerId)->update([
'status' => $status

View File

@@ -117,14 +117,15 @@ class MarketPlaceController extends Controller
// dd('helo');
// dd($request->all());
$offering = $this->viewOfferingData($slug);
// dd($offering['data']->id);
// dd($offering);
// $status = MarketplaceBuyerForm::where(['associated_id'=>$offering['data']->id,'status'=>'Sold'])->exists() ? 'SOLD':'OPEN';
$status = '';
$checkBIDExist = MarketplaceBuyerForm::where('associated_id', $offering['data']->id)->where('status', 'Sold')->exists();
$checkBIDExist = MarketplaceBuyerForm::where('associated_id', $offering['data']->id)->where('status', 'Sold')->get();
// dd($checkBIDExist);
if ($checkBIDExist) {
$buyerData = MarketplaceBuyerForm::where('associated_id', $offering['data']->id)->where('status', 'Sold')->get();
// dd($buyerData->toArray());
if (MarketplaceAlternativeInvestmentFundSeller::where('id', $buyerData[0]->associated_id)->exists()) {
// dd($buyerData[0]->associated_id);
if (MarketplaceAlternativeInvestmentFundSeller::where('id', $buyerData[0]->associated_id)->exists() && $offering['type'] == 'alternative-investment-funds') {
$totalSellUnits = 0;
$buyerData->each(function ($data) use ($totalSellUnits) {
return $totalSellUnits += (int)$data->no_of_units_you_wish_to_buy;
@@ -134,15 +135,18 @@ class MarketPlaceController extends Controller
$remainUnits = $aifData - $totalSellUnits;
if ($remainUnits <= 0) {
$status .= 'SOLD';
}else{
$status .= 'OPEN';
}
$status .= 'OPEN';
} elseif (MarketplaceFractionalRealEstateSeller::where('id', $buyerData[0]->associated_id)->exists()) {
} elseif (MarketplaceFractionalRealEstateSeller::where('id', $buyerData[0]->associated_id)->exists() && $offering['type'] == 'fractional-real-estate') {
$freData = MarketplaceFractionalRealEstateSeller::where('id', $buyerData[0]->associated_id)->first();
if($freData->current_market_value_of_the_property <= 0)
{
$status .= 'SOLD';
}
$status .= 'OPEN';
else{
$status .= 'OPEN';
}
}
} else {
$status .= 'OPEN';
@@ -155,6 +159,7 @@ class MarketPlaceController extends Controller
$type = $offering['type'];
$ownProduct = $offering['own-product'];
$logged_in = auth()->guard('users')->check() == true ? true : false;
// dd($status);
// dd('offering',$offering['invested_data']);
$investedData = $offering['invested_data'];

View File

@@ -107,8 +107,9 @@ class MarketplaceAlternativeInvestmentFundSeller extends Model
if($remainUnits <= 0)
{
return 'SOLD';
}else{
return 'OPEN';
}
return 'OPEN';
}
}else{
return 'OPEN';
@@ -144,17 +145,19 @@ class MarketplaceAlternativeInvestmentFundSeller extends Model
// $bids = MarketplaceBuyerForm::where(['associated_id' => $this->id, 'table' => 'marketplace_aif_sellers'])->get();
$bidArray = collect();
$bids->each(function($value) use ($bidArray,$values){
if($value->no_of_units_you_wish_to_buy < $values->no_of_units_you_wish_to_sell)
{
// $bidArray->push($value->getAttributes()['total_purchase_value']);
$bidArray->push($value->getAttributes()['offer_price_per_unit']);
}
$bidArray->push($value->getAttributes()['offer_price_per_unit']);
// if($value->no_of_units_you_wish_to_buy < $values->no_of_units_you_wish_to_sell)
// {
// // $bidArray->push($value->getAttributes()['total_purchase_value']);
// $bidArray->push($value->getAttributes()['offer_price_per_unit']);
// }
});
$noOfUnitHeld = (int)$values->current_or_latest_nav;
// $nav = intval($noOfUnitHeld) * intval($values->current_or_latest_nav);
$highestBid = intval($bidArray->max());
// $bid = ($highestBid - $nav)/(int)$nav * 100 ;
$bid = ($highestBid - $noOfUnitHeld)/(int)$noOfUnitHeld * 100 ;
$bid = $highestBid != 0 ? ($highestBid - (int)$noOfUnitHeld)/(int)$noOfUnitHeld * 100 : 0 ;
// dd($bid);
if(count($bids))
{
return round($bid,3);

View File

@@ -80,7 +80,8 @@ class MarketplaceFractionalRealEstateSeller extends Model
// $buyerData->each(function($data) use($totalSellUnits){
// return $totalSellUnits += (int)$data->no_of_units_you_wish_to_buy;
// });
if(MarketplaceFractionalRealEstateSeller::where('id',$id)->exists())
// $id = $this->id;
if(MarketplaceBuyerForm::where(['associated_id'=>$id,'table' => 'marketplace_fre_sellers'])->exists())
{
$getFREData = MarketplaceFractionalRealEstateSeller::where('id',$id)->first();
// $aifData = (int)$getFREData->no_of_units_you_wish_to_sell;
@@ -89,7 +90,9 @@ class MarketplaceFractionalRealEstateSeller extends Model
{
return 'SOLD';
}
else{
return 'OPEN';
}
}else{
return 'OPEN';
}