diff --git a/app/Http/Controllers/Customer/CustomerController.php b/app/Http/Controllers/Customer/CustomerController.php index 3c630f1..a82548c 100644 --- a/app/Http/Controllers/Customer/CustomerController.php +++ b/app/Http/Controllers/Customer/CustomerController.php @@ -199,7 +199,7 @@ class CustomerController extends Controller $referrer = $customer->referral; $total_referrals = Customer::where('referral_to_id', $referrer->referral_id)->where('is_legal', '!=', 0)->get()->count(); $referral_limit = Setting::where('key', 'referral_limit')->first(); - $gift_permision = $referral_limit->active ? $total_referrals < $referral_limit->value ? true : false : true ; + $gift_permision = $referral_limit->is_active ? $total_referrals < $referral_limit->value ? true : false : true ; if ($gift_permision && $gift_for_inviter > 0) { // dd($gift_for_inviter > 0, $gift_for_invited > 0); diff --git a/app/Http/Controllers/Single/SingleOrderController.php b/app/Http/Controllers/Single/SingleOrderController.php index 43d6859..b2ce055 100644 --- a/app/Http/Controllers/Single/SingleOrderController.php +++ b/app/Http/Controllers/Single/SingleOrderController.php @@ -39,6 +39,11 @@ class SingleOrderController extends Controller throw new UnprocessableEntityHttpException('عدم ارائه سرویس.'); } } + if($this->Config('close_price') == 'true'){ + if(Cnt::where('key', 'app_closed')->first()['value'] == "true"){ + throw new UnprocessableEntityHttpException('عدم ارائه سرویس.'); + } + } // throw new UnprocessableEntityHttpException('به دلیل نوسانات سفارشات بسته میباشد.'); $transactionType = $data['direction'] == 1 ? "خرید" : "فروش"; @@ -49,12 +54,6 @@ class SingleOrderController extends Controller if($latestPrice->price == 0){ throw new UnprocessableEntityHttpException('عدم ارائه سرویس.'); } - - if($this->Config('close_price') == 'true'){ - if(Cnt::where('key', 'app_closed')->first()['value'] == "true"){ - throw new UnprocessableEntityHttpException('عدم ارائه سرویس.'); - } - } $data['all_price'] = $latestPrice; $data['price'] = $latestPrice->price; $data['price_id'] = $latestPrice->id; diff --git a/app/Http/Controllers/Site/ReportController.php b/app/Http/Controllers/Site/ReportController.php index d83cc65..bf3e9ba 100644 --- a/app/Http/Controllers/Site/ReportController.php +++ b/app/Http/Controllers/Site/ReportController.php @@ -21,6 +21,7 @@ use Illuminate\Support\Facades\Mail; use Morilog\Jalali\Jalalian; use App\Http\Controllers\Admin\ProductController; + class ReportController extends Controller { public function candleChart() @@ -74,7 +75,6 @@ class ReportController extends Controller public function upDownPrice() { -// $difference = config('fee.single'); $difference = Setting::where('key', 'fee_single')->first()->value; $today = Carbon::now()->format("Y-m-d"); $prises = Price::where('date_at', $today)->get("price"); @@ -94,22 +94,10 @@ class ReportController extends Controller } } if (count($prises) === 0) { - // Fetching the current gold price from the API - $response = Http::get('https://www.tala.ir/ajax/price'); - $data = $response->json(); + $price = Price::orderBy('id', 'desc')->first(); + $priceValue = $price->price; - // Clean the price value retrieved from API - $data['gold']['gold_18k']['v'] = str_replace(',', '', $data['gold']['gold_18k']['v']); - $priceValue = $data['gold']['gold_18k']['v'] * 10; // Assuming the multiplication by 10 is needed - - // Create and save the new Price instance - $price = new Price(); - $price->price = $priceValue; // Assign the cleaned and calculated price value - $price->time_at = Carbon::now()->toTimeString(); // Set current time - $price->date_at = Carbon::now()->toDateString(); // Set current date - $price->save(); // Save to the database - - return ['sell' => $price->price - $difference, 'buy' => $price->price + $difference]; + return ['sell' => $priceValue - $difference, 'buy' => $priceValue + $difference]; } else { // Assuming $minP and $maxP are defined elsewhere in your code @@ -124,21 +112,36 @@ class ReportController extends Controller public function lastPrice() { $closed = false; - if($this->Config('close_price') == 'true'){ - $current = Carbon::now()->format("H:i:s"); - $start = "20:00:00"; - $end = "11:00:00"; - if($current >= $start || $current <= $end){ - $closed = true; +// if(auth('customer')->id() == 525){dd($close_setting->is_active == '1');} + + if($this->Config('close_price') == 'true'){ + $current = Carbon::now(); + $start = Carbon::today()->setTime(11, 0); + $end = Carbon::today()->setTime(20, 0); +// if(auth('customer')->id() == 525){dd("2026-05-08 23:00:00" >= $start && "2026-05-08 23:00:00" <= $end);} + + if(!$current->between($start, $end)){ + +// $closed = true; Cnt::where('key', 'app_closed')->update(['value' => "true"]); Cnt::where('key', 'goldir_closed')->update(['value' => "true"]); $liman_price = 0; + return [ + 'sell' => 0, + 'buy' => 0, + 'price_last' => 0, + 'price' => 0, + 'main_product' => 0, + 'taban_gohar' => 0, + 'goldir' => 0, + 'closed'=> true, + 'time'=>now()->format('H:i:s'), + ]; }else{ Cnt::where('key', 'app_closed')->update(['value' => "false"]); Cnt::where('key', 'goldir_closed')->update(['value' => "false"]); } - } // $difference = config('fee.single'); $settings = Setting::whereIn('key', ['fee_single', 'goldir_price', 'tabanGohar_price', 'main_product_price'])->get(); @@ -248,7 +251,7 @@ class ReportController extends Controller $priceValue = 0; } $lastPrice = Price::latest()->first(); - if (($lastPrice || $lastPrice->price !== $priceValue) && $priceValue > 30000000) { + if (!$closed && (($lastPrice || $lastPrice->price !== $priceValue) && $priceValue > 30000000)) { $price = new Price(); $price->price = $priceValue; // Assign the cleaned price value $price->time_at = Carbon::now()->toTimeString(); @@ -288,6 +291,7 @@ class ReportController extends Controller 'taban_gohar' => $tgn ?? 0, 'goldir' => $goldir_price ?? 0, 'closed'=>$closed ?? null, + 'time'=>now(), ]; } else { return [];