fix register 3

This commit is contained in:
2026-06-01 18:46:57 +03:30
parent 205d4c2502
commit 0a50125ee9
4 changed files with 68 additions and 15 deletions
@@ -12,7 +12,8 @@ use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
use Illuminate\Support\Facades\Http;
use \App\Http\Controllers\Customer\FundController;
use App\Http\Controllers\Site\ReportController ;
use App\Http\Controllers\Site\ReportController;
use App\Services\ConfigService;
class ProductController extends SuperController
@@ -138,6 +139,7 @@ class ProductController extends SuperController
// }
// }catch (\Exception $e){}
$config = app(ConfigService::class);
$products = Product::with([])->whereNotNull('reading_method')->get();
foreach ($products as $product) {
$collection = collect($RPrices);
@@ -158,6 +160,9 @@ class ProductController extends SuperController
'price' => $RPrice['price'],
'price_profit' => $RPrice['profit'],
]);
$config->trackDailyPriceExtreme(
(float) $RPrice['price'] + (float) ($RPrice['profit'] ?? 0)
);
if ($product->bubble == 1) {
$ReportController = new ReportController();
@@ -176,6 +181,7 @@ class ProductController extends SuperController
'price_profit' => 0,
'updated_at' => \Carbon\Carbon::now()->format('Y-m-d H:i:s'),
]);
$config->trackDailyPriceExtreme((float) $cp);
}
return response()->json(true);
+26 -12
View File
@@ -75,20 +75,36 @@ class ReportController extends Controller
public function upDownPrice()
{
$upSetting = Setting::where('key', 'up_price')->first();
$downSetting = Setting::where('key', 'down_price')->first();
if ($upSetting && $downSetting) {
$today = Carbon::now()->format('Y-m-d');
$updatedToday = $upSetting->updated_at
&& $upSetting->updated_at->format('Y-m-d') === $today;
if ($updatedToday) {
$down = (float) $downSetting->value;
$up = (float) $upSetting->value;
if ($down > 0 && $up > 0) {
return ['sell' => $down, 'buy' => $up];
}
}
}
$difference = Setting::where('key', 'fee_single')->first()->value;
$today = Carbon::now()->format("Y-m-d");
$prises = Price::where('date_at', $today)->get("price");
$minP = 0; // Initialize to the highest possible value
$maxP = 0; // Initialize to the lowest possible value
$minP = 0;
$maxP = 0;
foreach ($prises as $p) {
// Initialize $minP to the first price if it's null
if ($minP == 0 || $p->price < $minP) {
$minP = $p->price;
}
// Initialize $maxP to the first price if it's null
if ($maxP == 0 || $p->price > $maxP) {
$maxP = $p->price;
}
@@ -98,15 +114,9 @@ class ReportController extends Controller
$priceValue = $price->price;
return ['sell' => $priceValue - $difference, 'buy' => $priceValue + $difference];
} else {
// Assuming $minP and $maxP are defined elsewhere in your code
return ['sell' => $minP - $difference, 'buy' => $maxP + $difference];
}
// return $prises;
// $add_sell_price = config('add_sell_price.major');
// $price = PriceCandle::whereDate('date_at',)->first();
// $price_price = Price::orderBy('id','desc')->first();
return ['sell' => $minP - $difference, 'buy' => $maxP + $difference];
}
public function lastPrice()
@@ -452,6 +462,10 @@ class ReportController extends Controller
$priceLast = ceil($priceValue + $difference);
}
if (!$closed && $priceValue > 0) {
$config->trackDailyPriceExtreme((float) $priceValue);
}
return [
'sell' => $sell,
'buy' => $buy,
+1 -1
View File
@@ -12,7 +12,7 @@ class Price extends Model
"price",
"date_at",
"time_at",
"user_id"
"user_id",
];
public function user()
{
+34 -1
View File
@@ -13,9 +13,42 @@ class ConfigService
public function UpdateConfig($name, $value)
{
return \App\Models\Setting::updateOrCreate(
return Setting::updateOrCreate(
['key' => $name],
['value' => $value]
);
}
public function trackDailyPriceExtreme(float $price): void
{
if ($price <= 0) {
return;
}
$upSetting = Setting::where('key', 'up_price')->first();
$downSetting = Setting::where('key', 'down_price')->first();
if (!$upSetting || !$downSetting) {
return;
}
$priceInt = (int) round($price);
$today = now()->toDateString();
if (!$upSetting->updated_at || $upSetting->updated_at->toDateString() !== $today) {
$this->UpdateConfig('up_price', $priceInt);
$this->UpdateConfig('down_price', $priceInt);
return;
}
$currentUp = (float) ($upSetting->value ?: 0);
$currentDown = (float) ($downSetting->value ?: 0);
if ($currentUp <= 0 || $priceInt > $currentUp) {
$this->UpdateConfig('up_price', $priceInt);
}
if ($currentDown <= 0 || $priceInt < $currentDown) {
$this->UpdateConfig('down_price', $priceInt);
}
}
}