NASER optimize get price and order from goldir

This commit is contained in:
gholak tala
2026-04-04 07:47:17 +00:00
parent 81b53123b9
commit 76a344f9f2
2 changed files with 17 additions and 7 deletions
+11 -4
View File
@@ -131,6 +131,8 @@ class ReportController extends Controller
$gold_ir_price = $settingsMap->get('goldir_price');
$main_product_price = $settingsMap->get('main_product_price');
$open_buy = true;
$open_sell = true;
if($gold_ir_price == 'true'){
$goldir_price = 0;
try{
@@ -168,8 +170,13 @@ class ReportController extends Controller
Cnt::where('key', 'goldir_truly_buy_mazaneh')->update(['value' => $lp['sub_agent']['rate_buy_price']]);
Cnt::where('key', 'goldir_truly_sell_mazaneh')->update(['value' => $lp['sub_agent']['rate_sell_price']]);
Cnt::where('key', 'log')->update(['value' => json_encode($goldir, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)]);
Cnt::where('key', 'goldir_open_sell')->update(['value' => $lp['open_sell']? "true":"false"]);
Cnt::where('key', 'goldir_open_buy')->update(['value' => $lp['open_buy']? "true":"false"]);
if ($lp['open_sell'] == 'true' && $lp['open_buy'] == 'true') {
$open_buy = $lp['open_buy'];
$open_sell = $lp['open_sell'];
if ($lp['open_sell'] == 'true' || $lp['open_buy'] == 'true') {
$goldir_price = (int)$customPrice['price'];
}
// }
@@ -224,7 +231,7 @@ class ReportController extends Controller
$priceValue = 0;
}
$lastPrice = Price::latest()->first();
if (!$lastPrice || $lastPrice->price != $priceValue and $priceValue > 30000000) {
if (($lastPrice || $lastPrice->price !== $priceValue) && $priceValue > 30000000) {
$price = new Price();
$price->price = $priceValue; // Assign the cleaned price value
$price->time_at = Carbon::now()->toTimeString();
@@ -256,8 +263,8 @@ class ReportController extends Controller
$difference = $goldir_profit;
}
return [
'sell' => $priceValue !== 0 ? ceil($price->price - $difference) : 0,
'buy' => $priceValue !== 0 ? ceil($price->price + $difference) : 0,
'sell' => $priceValue !== 0 ? $open_sell ? ceil($price->price - $difference) : 0 : 0,
'buy' => $priceValue !== 0 ? $open_buy ? ceil($price->price + $difference) : 0 : 0,
'price_last' => $priceValue !== 0 ? ceil($price->price + $difference) : 0,
'price' => $priceValue,
'main_product' => $pr_price ?? 0,