added last seen 2
This commit is contained in:
@@ -14,6 +14,7 @@ use App\Models\Setting;
|
|||||||
use App\Services\AssetSummaryService;
|
use App\Services\AssetSummaryService;
|
||||||
use App\Services\BalanceReportService;
|
use App\Services\BalanceReportService;
|
||||||
use App\Services\ConfigService;
|
use App\Services\ConfigService;
|
||||||
|
use App\Services\CustomerPresenceService;
|
||||||
use App\Services\ReferralGiftService;
|
use App\Services\ReferralGiftService;
|
||||||
use App\Services\WalletBalanceService;
|
use App\Services\WalletBalanceService;
|
||||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||||
@@ -54,6 +55,28 @@ class CustomerController extends SuperController
|
|||||||
|
|
||||||
return response()->json($users);
|
return response()->json($users);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* مشتریان با SSE فعال در بازهٔ آنلاین بودن (last_seen_at تازه).
|
||||||
|
*/
|
||||||
|
public function onlineList()
|
||||||
|
{
|
||||||
|
$threshold = now()->subSeconds(CustomerPresenceService::ONLINE_THRESHOLD_SECONDS);
|
||||||
|
|
||||||
|
$rows = Customer::query()
|
||||||
|
->where('is_archive', false)
|
||||||
|
->whereNotNull('last_seen_at')
|
||||||
|
->where('last_seen_at', '>=', $threshold)
|
||||||
|
->orderByDesc('last_seen_at')
|
||||||
|
->get(['id', 'name', 'mobile', 'last_seen_at', 'active', 'trade_active', 'type']);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'count' => $rows->count(),
|
||||||
|
'online_within_seconds' => CustomerPresenceService::ONLINE_THRESHOLD_SECONDS,
|
||||||
|
'rows' => $rows,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function updateAdmin(Request $request , $id)
|
public function updateAdmin(Request $request , $id)
|
||||||
{
|
{
|
||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ Route::middleware('auth:user')->group(function (){
|
|||||||
|
|
||||||
//--------customer
|
//--------customer
|
||||||
Route::post('/customer/table',[CustomerController::class,'tableWallets']);
|
Route::post('/customer/table',[CustomerController::class,'tableWallets']);
|
||||||
|
Route::get('/customer/online',[CustomerController::class,'onlineList']);
|
||||||
Route::get('/customer/{id}/assets',[CustomerController::class,'assetsSummary']);
|
Route::get('/customer/{id}/assets',[CustomerController::class,'assetsSummary']);
|
||||||
Route::get('/customer/active/{id}',[CustomerController::class,'active']);
|
Route::get('/customer/active/{id}',[CustomerController::class,'active']);
|
||||||
Route::get('/customer/archive/{id}',[CustomerController::class,'archive']);
|
Route::get('/customer/archive/{id}',[CustomerController::class,'archive']);
|
||||||
|
|||||||
Reference in New Issue
Block a user