fix up down price
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\SuperController;
|
||||
use App\Models\Cnt;
|
||||
use App\Models\Product;
|
||||
use App\Models\Setting;
|
||||
use App\DB\Te\TableEngine;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -140,6 +141,8 @@ class ProductController extends SuperController
|
||||
// }catch (\Exception $e){}
|
||||
|
||||
$config = app(ConfigService::class);
|
||||
$mainProductId = Cnt::where('key', 'main_product')->value('value');
|
||||
$hasExtremeKeys = Setting::whereIn('key', ['up_price', 'down_price'])->count() === 2;
|
||||
$products = Product::with([])->whereNotNull('reading_method')->get();
|
||||
foreach ($products as $product) {
|
||||
$collection = collect($RPrices);
|
||||
@@ -160,9 +163,14 @@ class ProductController extends SuperController
|
||||
'price' => $RPrice['price'],
|
||||
'price_profit' => $RPrice['profit'],
|
||||
]);
|
||||
$config->trackDailyPriceExtreme(
|
||||
(float) $RPrice['price'] + (float) ($RPrice['profit'] ?? 0)
|
||||
);
|
||||
$productPrice = (float) $RPrice['price'] + (float) ($RPrice['profit'] ?? 0);
|
||||
if (
|
||||
$hasExtremeKeys
|
||||
&& $mainProductId
|
||||
&& (int) $product->id === (int) $mainProductId
|
||||
) {
|
||||
$config->trackDailyPriceExtreme($productPrice);
|
||||
}
|
||||
|
||||
if ($product->bubble == 1) {
|
||||
$ReportController = new ReportController();
|
||||
@@ -181,7 +189,13 @@ class ProductController extends SuperController
|
||||
'price_profit' => 0,
|
||||
'updated_at' => \Carbon\Carbon::now()->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
$config->trackDailyPriceExtreme((float) $cp);
|
||||
if (
|
||||
$hasExtremeKeys
|
||||
&& $mainProductId
|
||||
&& Product::where('id', $mainProductId)->where('metal_id', 3)->exists()
|
||||
) {
|
||||
$config->trackDailyPriceExtreme((float) $cp);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(true);
|
||||
|
||||
Reference in New Issue
Block a user