fix notif

This commit is contained in:
2026-07-24 16:49:42 +03:30
parent eacf5181a9
commit 107cf5b291
10 changed files with 105 additions and 11 deletions
@@ -5,13 +5,14 @@ namespace App\Http\Controllers\Admin;
use App\DB\Te\TableEngine;
use App\Http\Controllers\Controller;
use App\Models\AppNotification;
use App\Models\AppNotificationRead;
use Illuminate\Http\Request;
class AppNotificationController extends Controller
{
public function table(Request $request)
{
$query = AppNotification::query();
$query = AppNotification::query()->withCount('reads');
TableEngine::create($query, $request->all())
->initSearch(['title', 'body', 'severity'])
@@ -62,6 +63,36 @@ class AppNotificationController extends Controller
return response()->json(true);
}
/** لیست مشتریانی که این اعلان را سین کرده‌اند */
public function readers(int $id)
{
AppNotification::findOrFail($id);
$rows = AppNotificationRead::query()
->where('notification_id', $id)
->with(['customer:id,name,fname,lname,mobile'])
->orderByDesc('read_at')
->orderByDesc('id')
->get();
$readers = $rows->map(function (AppNotificationRead $read) {
$customer = $read->customer;
$name = trim((string) ($customer?->name ?: trim(($customer?->fname ?? '') . ' ' . ($customer?->lname ?? ''))));
return [
'customer_id' => $read->customer_id,
'name' => $name !== '' ? $name : '—',
'mobile' => $customer?->mobile,
'read_at' => $read->read_at,
];
})->values();
return response()->json([
'reads_count' => $readers->count(),
'readers' => $readers,
]);
}
private function validatedPayload(Request $request, bool $partial = false): array
{
$rules = [
@@ -1357,7 +1357,7 @@ class SingleOrderController extends Controller
if ($hasApp && $hasProduct) {
$source = 'app+product';
$label = 'قیمت اپ + تب اختلاف محصول = ' . number_format($amount) . ' ریال / گرم';
$label = 'قیمت صفحه اصلی اپلیکیشن + تب اختلاف محصول = ' . number_format($amount) . ' ریال / گرم';
} elseif ($hasApp) {
$source = 'settings';
$label = ($lines[0]['label'] ?? 'اختلاف پایه اپ') . ' = ' . number_format($amount) . ' ریال';
@@ -267,10 +267,13 @@ class ReportController extends Controller
if ($config->isOutsideTradingHours()) {
$config->syncAppClosedFlag();
return $zeroResponse();
// نمایش قیمت صفحه اصلی حتی وقتی فروشگاه بسته است — معامله همچنان از سمت اپ بسته می‌ماند
if (! $config->shouldShowHomePriceWhenClosed()) {
return $zeroResponse();
}
} else {
Cnt::where('key', 'app_closed')->update(['value' => 'false']);
}
Cnt::where('key', 'app_closed')->update(['value' => 'false']);
}
/*