NASER fix issues in getting price and close orders
This commit is contained in:
@@ -199,7 +199,7 @@ class CustomerController extends Controller
|
|||||||
$referrer = $customer->referral;
|
$referrer = $customer->referral;
|
||||||
$total_referrals = Customer::where('referral_to_id', $referrer->referral_id)->where('is_legal', '!=', 0)->get()->count();
|
$total_referrals = Customer::where('referral_to_id', $referrer->referral_id)->where('is_legal', '!=', 0)->get()->count();
|
||||||
$referral_limit = Setting::where('key', 'referral_limit')->first();
|
$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) {
|
if ($gift_permision && $gift_for_inviter > 0) {
|
||||||
// dd($gift_for_inviter > 0, $gift_for_invited > 0);
|
// dd($gift_for_inviter > 0, $gift_for_invited > 0);
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ class SingleOrderController extends Controller
|
|||||||
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
|
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($this->Config('close_price') == 'true'){
|
||||||
|
if(Cnt::where('key', 'app_closed')->first()['value'] == "true"){
|
||||||
|
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// throw new UnprocessableEntityHttpException('به دلیل نوسانات سفارشات بسته میباشد.');
|
// throw new UnprocessableEntityHttpException('به دلیل نوسانات سفارشات بسته میباشد.');
|
||||||
$transactionType = $data['direction'] == 1 ? "خرید" : "فروش";
|
$transactionType = $data['direction'] == 1 ? "خرید" : "فروش";
|
||||||
@@ -49,12 +54,6 @@ class SingleOrderController extends Controller
|
|||||||
if($latestPrice->price == 0){
|
if($latestPrice->price == 0){
|
||||||
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
|
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;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use Illuminate\Support\Facades\Mail;
|
|||||||
use Morilog\Jalali\Jalalian;
|
use Morilog\Jalali\Jalalian;
|
||||||
use App\Http\Controllers\Admin\ProductController;
|
use App\Http\Controllers\Admin\ProductController;
|
||||||
|
|
||||||
|
|
||||||
class ReportController extends Controller
|
class ReportController extends Controller
|
||||||
{
|
{
|
||||||
public function candleChart()
|
public function candleChart()
|
||||||
@@ -74,7 +75,6 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
public function upDownPrice()
|
public function upDownPrice()
|
||||||
{
|
{
|
||||||
// $difference = config('fee.single');
|
|
||||||
$difference = Setting::where('key', 'fee_single')->first()->value;
|
$difference = Setting::where('key', 'fee_single')->first()->value;
|
||||||
$today = Carbon::now()->format("Y-m-d");
|
$today = Carbon::now()->format("Y-m-d");
|
||||||
$prises = Price::where('date_at', $today)->get("price");
|
$prises = Price::where('date_at', $today)->get("price");
|
||||||
@@ -94,22 +94,10 @@ class ReportController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count($prises) === 0) {
|
if (count($prises) === 0) {
|
||||||
// Fetching the current gold price from the API
|
$price = Price::orderBy('id', 'desc')->first();
|
||||||
$response = Http::get('https://www.tala.ir/ajax/price');
|
$priceValue = $price->price;
|
||||||
$data = $response->json();
|
|
||||||
|
|
||||||
// Clean the price value retrieved from API
|
return ['sell' => $priceValue - $difference, 'buy' => $priceValue + $difference];
|
||||||
$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];
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Assuming $minP and $maxP are defined elsewhere in your code
|
// Assuming $minP and $maxP are defined elsewhere in your code
|
||||||
@@ -124,21 +112,36 @@ class ReportController extends Controller
|
|||||||
public function lastPrice()
|
public function lastPrice()
|
||||||
{
|
{
|
||||||
$closed = false;
|
$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){
|
// if(auth('customer')->id() == 525){dd($close_setting->is_active == '1');}
|
||||||
$closed = true;
|
|
||||||
|
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', 'app_closed')->update(['value' => "true"]);
|
||||||
Cnt::where('key', 'goldir_closed')->update(['value' => "true"]);
|
Cnt::where('key', 'goldir_closed')->update(['value' => "true"]);
|
||||||
$liman_price = 0;
|
$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{
|
}else{
|
||||||
Cnt::where('key', 'app_closed')->update(['value' => "false"]);
|
Cnt::where('key', 'app_closed')->update(['value' => "false"]);
|
||||||
Cnt::where('key', 'goldir_closed')->update(['value' => "false"]);
|
Cnt::where('key', 'goldir_closed')->update(['value' => "false"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// $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();
|
||||||
@@ -248,7 +251,7 @@ class ReportController extends Controller
|
|||||||
$priceValue = 0;
|
$priceValue = 0;
|
||||||
}
|
}
|
||||||
$lastPrice = Price::latest()->first();
|
$lastPrice = Price::latest()->first();
|
||||||
if (($lastPrice || $lastPrice->price !== $priceValue) && $priceValue > 30000000) {
|
if (!$closed && (($lastPrice || $lastPrice->price !== $priceValue) && $priceValue > 30000000)) {
|
||||||
$price = new Price();
|
$price = new Price();
|
||||||
$price->price = $priceValue; // Assign the cleaned price value
|
$price->price = $priceValue; // Assign the cleaned price value
|
||||||
$price->time_at = Carbon::now()->toTimeString();
|
$price->time_at = Carbon::now()->toTimeString();
|
||||||
@@ -288,6 +291,7 @@ class ReportController extends Controller
|
|||||||
'taban_gohar' => $tgn ?? 0,
|
'taban_gohar' => $tgn ?? 0,
|
||||||
'goldir' => $goldir_price ?? 0,
|
'goldir' => $goldir_price ?? 0,
|
||||||
'closed'=>$closed ?? null,
|
'closed'=>$closed ?? null,
|
||||||
|
'time'=>now(),
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
Reference in New Issue
Block a user