added some feature for accounting and price
This commit is contained in:
@@ -52,6 +52,8 @@ class ProductController extends SuperController
|
||||
->select($this->select)
|
||||
->export($query_table);
|
||||
|
||||
$this->enrichAdminTablePrices($query_table['rows'] ?? null);
|
||||
|
||||
if (Schema::hasColumn((new Product)->getTable(), 'auto_open_at')) {
|
||||
$query_table['auto_open_at'] = Product::selectRaw(
|
||||
'SEC_TO_TIME(AVG(TIME_TO_SEC(TIME(auto_open_at)))) as avg_time'
|
||||
@@ -83,6 +85,8 @@ class ProductController extends SuperController
|
||||
->select($this->select)
|
||||
->export($query_table);
|
||||
|
||||
$this->enrichAdminTablePrices($query_table['rows'] ?? null);
|
||||
|
||||
return $query_table;
|
||||
}
|
||||
|
||||
@@ -557,6 +561,27 @@ class ProductController extends SuperController
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* جدول ادمین — قیمت لحظهای روی مدل (بدون UPDATE دیتابیس)، مثل فرم ویرایش و اپ مشتری.
|
||||
*
|
||||
* @param iterable<Product>|null $rows
|
||||
*/
|
||||
private function enrichAdminTablePrices($rows): void
|
||||
{
|
||||
if ($rows === null || app(ConfigService::class)->isStore()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$products = collect($rows)->filter(fn ($row) => $row instanceof Product);
|
||||
if ($products->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$displayPriceService = app(ProductDisplayPriceService::class);
|
||||
$displayPriceService->warmLivePriceCache();
|
||||
$displayPriceService->enrichForApi($products);
|
||||
}
|
||||
|
||||
private function filterProductData(array $data): array
|
||||
{
|
||||
if (!Product::hasPriceOffsetColumn()) {
|
||||
@@ -616,6 +641,12 @@ class ProductController extends SuperController
|
||||
unset($data['inventory']);
|
||||
}
|
||||
|
||||
if (!Product::hasOverrideTradingHoursColumn()) {
|
||||
unset($data['override_trading_hours']);
|
||||
} elseif (array_key_exists('override_trading_hours', $data)) {
|
||||
$data['override_trading_hours'] = !empty($data['override_trading_hours']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user