fix notif
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,4 +23,9 @@ class AppNotificationRead extends Model
|
||||
{
|
||||
return $this->belongsTo(AppNotification::class, 'notification_id');
|
||||
}
|
||||
|
||||
public function customer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -768,8 +768,8 @@ class BalanceReportService
|
||||
$source = $feeSource ?? $this->resolveOrderFeeSourceKey();
|
||||
if ($source === 'app+product') {
|
||||
return $direction === 2
|
||||
? 'قیمت اپ (sell_fee) + تب اختلاف محصول'
|
||||
: 'قیمت اپ (buy_fee) + تب اختلاف محصول';
|
||||
? 'قیمت صفحه اصلی اپلیکیشن (sell_fee) + تب اختلاف محصول'
|
||||
: 'قیمت صفحه اصلی اپلیکیشن (buy_fee) + تب اختلاف محصول';
|
||||
}
|
||||
if ($source === 'settings') {
|
||||
return $direction === 2
|
||||
|
||||
@@ -492,6 +492,12 @@ class ConfigService
|
||||
return $this->getBool('close_price', false);
|
||||
}
|
||||
|
||||
/** خارج از ساعت کاری، قیمت صفحه اصلی را نشان بده (معامله همچنان بسته) */
|
||||
public function shouldShowHomePriceWhenClosed(): bool
|
||||
{
|
||||
return $this->getBool('show_home_price_when_closed', false);
|
||||
}
|
||||
|
||||
/** @return array{start: string, end: string} */
|
||||
public function tradingHourBounds(): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user