This commit is contained in:
2026-06-11 16:41:28 +03:30
parent 76563be5cd
commit f329419c3a
4 changed files with 170 additions and 4 deletions
@@ -297,13 +297,14 @@ class DashboardController extends Controller
];
// Calculate total gold gifts from transactions
$giftsGold = 0.0;
foreach ($TransactionsAdmin as $TransactionAdmin) {
$response['Gifts'] += $TransactionAdmin->gold;
$giftsGold += (float) $TransactionAdmin->gold;
}
$response['Gifts'] = number_format($response['Gifts'], 3);
$response['Gifts'] = number_format($giftsGold, 3);
// Calculate total price of gold gifts
$response['GiftsPrise'] = floor($response['Gifts'] * Price::latest()->first()->price);
$lastGoldPrice = (float) (Price::latest()->first()?->price ?? 0);
$response['GiftsPrise'] = $lastGoldPrice > 0 ? (int) floor($giftsGold * $lastGoldPrice) : 0;
// Calculate order-related sums
foreach ($ords as $ord) {
$response['fullPriceM1'] += abs($ord->total_price_original - $ord->payment_amount);
@@ -15,6 +15,7 @@ use Illuminate\Support\Facades\Http;
use \App\Http\Controllers\Customer\FundController;
use App\Http\Controllers\Site\ReportController;
use App\Services\ConfigService;
use App\Services\ProductDisplayPriceService;
use App\Services\ProductPriceService;
use Illuminate\Support\Facades\Schema;
@@ -161,6 +162,10 @@ class ProductController extends SuperController
$products = Product::with(['file'])->where('active', 1)->get();
if (str_contains(request()->path(), '/customer/')) {
app(ProductDisplayPriceService::class)->enrichForApi($products);
}
if (Product::hasPriceOffsetColumn() && str_contains(request()->path(), '/customer/')) {
$products->each(function (Product $product) {
if ($product->reading_method) {
@@ -21,6 +21,7 @@ use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Mail;
use Morilog\Jalali\Jalalian;
use App\Services\ConfigService;
use App\Services\ProductDisplayPriceService;
class ReportController extends Controller
@@ -146,6 +147,7 @@ class ReportController extends Controller
protected function appendUpPrices(array $payload): array
{
$payload['up'] = $this->buildUpDownPrices();
app(ProductDisplayPriceService::class)->cacheLivePricePayload($payload);
return $payload;
}