NASER add close condition in last api and close orders when app is closed
This commit is contained in:
@@ -123,6 +123,23 @@ 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;
|
||||
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');
|
||||
$settings = Setting::whereIn('key', ['fee_single', 'goldir_price', 'tabanGohar_price', 'main_product_price'])->get();
|
||||
$settingsMap = $settings->pluck('value', 'key');
|
||||
@@ -133,7 +150,7 @@ class ReportController extends Controller
|
||||
|
||||
$open_buy = true;
|
||||
$open_sell = true;
|
||||
if($gold_ir_price == 'true'){
|
||||
if($gold_ir_price == 'true' && !$closed){
|
||||
$goldir_price = 0;
|
||||
try{
|
||||
$goldir = Http::timeout(7)->withOptions([
|
||||
@@ -189,13 +206,13 @@ class ReportController extends Controller
|
||||
} 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'];
|
||||
$pr_product = Product::find($main_product_id);
|
||||
$pr_price = $pr_product['price'] + $pr_product['price_profit'];
|
||||
}
|
||||
|
||||
if($taban_gohar_price == 'true') {
|
||||
if($taban_gohar_price == 'true' && !$closed) {
|
||||
try {
|
||||
$taban_gohar = Http::withOptions([
|
||||
'curl' => [
|
||||
@@ -221,11 +238,11 @@ class ReportController extends Controller
|
||||
// $ref = false;
|
||||
// }
|
||||
|
||||
if($gold_ir_price == 'true' && $goldir_price !== 0) {
|
||||
if($gold_ir_price == 'true' && ($goldir_price??0) !== 0 && !$closed) {
|
||||
$priceValue = (int)$goldir_price;
|
||||
}elseif($taban_gohar_price == 'true' && $tgn !== 0){
|
||||
}elseif($taban_gohar_price == 'true' && ($tgn??0) !== 0 && !$closed){
|
||||
$priceValue = $tgn;
|
||||
}elseif($main_product_price == 'true' && $pr_price !== 0){
|
||||
}elseif($main_product_price == 'true' && ($pr_price??0) !== 0 && !$closed){
|
||||
$priceValue = $pr_price;
|
||||
}else{
|
||||
$priceValue = 0;
|
||||
@@ -269,7 +286,8 @@ class ReportController extends Controller
|
||||
'price' => $priceValue,
|
||||
'main_product' => $pr_price ?? 0,
|
||||
'taban_gohar' => $tgn ?? 0,
|
||||
'goldir' => $goldir_price ?? 0
|
||||
'goldir' => $goldir_price ?? 0,
|
||||
'closed'=>$closed ?? null,
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user