NASER add close condition in last api and close orders when app is closed

This commit is contained in:
gholak tala
2026-05-02 18:47:02 +00:00
parent 562edfadd9
commit f602b519a1
2 changed files with 35 additions and 7 deletions
@@ -45,6 +45,16 @@ class SingleOrderController extends Controller
if (auth('customer')->id()) { if (auth('customer')->id()) {
$data['customer_id'] = auth('customer')->id(); $data['customer_id'] = auth('customer')->id();
$latestPrice = Price::latest()->first(); $latestPrice = Price::latest()->first();
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['all_price'] = $latestPrice;
$data['price'] = $latestPrice->price; $data['price'] = $latestPrice->price;
$data['price_id'] = $latestPrice->id; $data['price_id'] = $latestPrice->id;
+25 -7
View File
@@ -123,6 +123,23 @@ class ReportController extends Controller
public function lastPrice() 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;
Cnt::where('key', 'app_closed')->update(['value' => "true"]);
Cnt::where('key', 'goldir_closed')->update(['value' => "true"]);
$liman_price = 0;
}else{
Cnt::where('key', 'app_closed')->update(['value' => "true"]);
Cnt::where('key', 'goldir_closed')->update(['value' => "true"]);
}
}
// $difference = config('fee.single'); // $difference = config('fee.single');
$settings = Setting::whereIn('key', ['fee_single', 'goldir_price', 'tabanGohar_price', 'main_product_price'])->get(); $settings = Setting::whereIn('key', ['fee_single', 'goldir_price', 'tabanGohar_price', 'main_product_price'])->get();
$settingsMap = $settings->pluck('value', 'key'); $settingsMap = $settings->pluck('value', 'key');
@@ -133,7 +150,7 @@ class ReportController extends Controller
$open_buy = true; $open_buy = true;
$open_sell = true; $open_sell = true;
if($gold_ir_price == 'true'){ if($gold_ir_price == 'true' && !$closed){
$goldir_price = 0; $goldir_price = 0;
try{ try{
$goldir = Http::timeout(7)->withOptions([ $goldir = Http::timeout(7)->withOptions([
@@ -189,13 +206,13 @@ class ReportController extends Controller
} catch (\Exception $e) {$goldir_price = 0;} } catch (\Exception $e) {$goldir_price = 0;}
} }
if($main_product_price == 'true'){ if($main_product_price == 'true' && !$closed){
$main_product_id = Cnt::where('key', 'main_product')->first()['value']; $main_product_id = Cnt::where('key', 'main_product')->first()['value'];
$pr_product = Product::find($main_product_id); $pr_product = Product::find($main_product_id);
$pr_price = $pr_product['price'] + $pr_product['price_profit']; $pr_price = $pr_product['price'] + $pr_product['price_profit'];
} }
if($taban_gohar_price == 'true') { if($taban_gohar_price == 'true' && !$closed) {
try { try {
$taban_gohar = Http::withOptions([ $taban_gohar = Http::withOptions([
'curl' => [ 'curl' => [
@@ -221,11 +238,11 @@ class ReportController extends Controller
// $ref = false; // $ref = false;
// } // }
if($gold_ir_price == 'true' && $goldir_price !== 0) { if($gold_ir_price == 'true' && ($goldir_price??0) !== 0 && !$closed) {
$priceValue = (int)$goldir_price; $priceValue = (int)$goldir_price;
}elseif($taban_gohar_price == 'true' && $tgn !== 0){ }elseif($taban_gohar_price == 'true' && ($tgn??0) !== 0 && !$closed){
$priceValue = $tgn; $priceValue = $tgn;
}elseif($main_product_price == 'true' && $pr_price !== 0){ }elseif($main_product_price == 'true' && ($pr_price??0) !== 0 && !$closed){
$priceValue = $pr_price; $priceValue = $pr_price;
}else{ }else{
$priceValue = 0; $priceValue = 0;
@@ -269,7 +286,8 @@ class ReportController extends Controller
'price' => $priceValue, 'price' => $priceValue,
'main_product' => $pr_price ?? 0, 'main_product' => $pr_price ?? 0,
'taban_gohar' => $tgn ?? 0, 'taban_gohar' => $tgn ?? 0,
'goldir' => $goldir_price ?? 0 'goldir' => $goldir_price ?? 0,
'closed'=>$closed ?? null,
]; ];
} else { } else {
return []; return [];