diff --git a/app/Http/Controllers/Admin/TahesabController.php b/app/Http/Controllers/Admin/TahesabController.php index 6ae184c..9eb5ae0 100644 --- a/app/Http/Controllers/Admin/TahesabController.php +++ b/app/Http/Controllers/Admin/TahesabController.php @@ -359,4 +359,18 @@ class TahesabController extends Controller } + public function healthCheck() + { + $tahesab = Http::withoutVerifying()->withHeaders([ + 'Content-Type' => 'application/json', + 'DBName'=> 'tahesabDB1', + 'Authorization'=> 'Bearer K7F5P8H2Q1O4I8M8M4J3L4L3W8N2A2P6I2T4I8N4E2T2N2D7O7Y5K3W6P2N4G3X2T1T4C5V4I1X2T6S1' + ])->post('https://217.114.40.30:8081/', ["CheckHealth" => [] ])->json(); + + if($tahesab['Api_Status'] === "OK" && $tahesab['DB_Status'] === "OK"){ + return true; + }else{ + return false; + } + } } diff --git a/app/Http/Controllers/Single/SingleOrderController.php b/app/Http/Controllers/Single/SingleOrderController.php index 5d6af04..34f089b 100644 --- a/app/Http/Controllers/Single/SingleOrderController.php +++ b/app/Http/Controllers/Single/SingleOrderController.php @@ -30,7 +30,9 @@ class SingleOrderController extends Controller public function store(Request $request) { $goldir = Cnt::where('key', 'goldir_closed')->first(); - if(isset($goldir) && $goldir['value'] == "true"){ + $tahesab = new TahesabController(); + $healthCheck = $tahesab->healthCheck(); + if(isset($goldir) && $goldir['value'] == "true" && $healthCheck){ throw new UnprocessableEntityHttpException('عدم ارائه سرویس.'); } diff --git a/app/Http/Controllers/Site/ReportController.php b/app/Http/Controllers/Site/ReportController.php index fffb315..007c504 100644 --- a/app/Http/Controllers/Site/ReportController.php +++ b/app/Http/Controllers/Site/ReportController.php @@ -152,9 +152,9 @@ class ReportController extends Controller $buy = $lp['sub_agent']['rate_buy_gram_price']; $sell = $lp['sub_agent']['rate_sell_gram_price']; - $customPrice['price'] = ($buy + $sell) / 2; + $customPrice['price'] = (ceil($buy) + ceil($sell)) / 2; Cnt::where('key', 'goldir_price')->update(['value' => (float)$customPrice['price']]);//was float - $customPrice['diff'] = ($buy - $sell) / 2; + $customPrice['diff'] = (ceil($buy) - ceil($sell)) / 2; Cnt::where('key', 'goldir_diff')->update(['value' => (float)$customPrice['diff']]);//was float Cnt::where('key', 'goldir_mazaneh')->update(['value' => ((float)$customPrice['price'] * 4.331802)]); @@ -239,10 +239,14 @@ class ReportController extends Controller } $price = Price::orderBy('id', 'desc')->first(); if ($price) { + if($this->Config('goldir_price') == 'true' && $goldir_price !==0){ + $goldir_profit = Cnt::where('key', 'goldir_diff')->first()['value']; + $difference = $goldir_profit; + } return [ - 'sell' => $price->price - $difference, - 'buy' => $price->price + $difference, - 'price_last' => $price->price + $difference, + 'sell' => ceil($price->price - $difference), + 'buy' => ceil($price->price + $difference), + 'price_last' => ceil($price->price + $difference), 'price' => $priceValue, 'main_product' => $pr_product['price'] + $pr_product['price_profit'], 'taban_gohar' => $tgn ?? 0,