Compare commits

..

No commits in common. "d5c24ed3d1542c5954c6ce8cef830b18c8bd910f" and "f9048e791f8db02851770776b9ebee5f4cbe7098" have entirely different histories.

7 changed files with 37 additions and 28 deletions

View File

@ -69,6 +69,8 @@ class StatController extends Controller
'start_date' => 'nullable|date_format:Y-m-d', 'start_date' => 'nullable|date_format:Y-m-d',
'end_date' => 'nullable|date_format:Y-m-d', 'end_date' => 'nullable|date_format:Y-m-d',
'type' => 'nullable|in:paid_total,paid_count,commission_total,commission_count', 'type' => 'nullable|in:paid_total,paid_count,commission_total,commission_count',
'page' => 'nullable|integer|min:1',
'page_size' => 'nullable|integer|min:1|max:100'
]); ]);
$query = Stat::where('record_type', 'd'); $query = Stat::where('record_type', 'd');
@ -81,16 +83,25 @@ class StatController extends Controller
$query->where('record_at', '<=', strtotime($request->input('end_date') . ' 23:59:59')); $query->where('record_at', '<=', strtotime($request->input('end_date') . ' 23:59:59'));
} }
// Get total count for pagination
$total = $query->count();
// Apply pagination
$pageSize = $request->input('page_size', 31);
$page = $request->input('page', 1);
$statistics = $query->orderBy('record_at', 'DESC') $statistics = $query->orderBy('record_at', 'DESC')
->get(); ->forPage($page, $pageSize)
->get()
->toArray();
$summary = [ $summary = [
'paid_total' => 0, 'paid_total' => 0,
'paid_count' => 0, 'paid_count' => 0,
'commission_total' => 0, 'commission_total' => 0,
'commission_count' => 0, 'commission_count' => 0,
'start_date' => $request->input('start_date', date('Y-m-d', $statistics->last()->record_at)), 'start_date' => $request->input('start_date', date('Y-m-d', strtotime('-30 days'))),
'end_date' => $request->input('end_date', date('Y-m-d', $statistics->first()->record_at)), 'end_date' => $request->input('end_date', date('Y-m-d')),
'avg_paid_amount' => 0, 'avg_paid_amount' => 0,
'avg_commission_amount' => 0 'avg_commission_amount' => 0
]; ];
@ -146,6 +157,12 @@ class StatController extends Controller
'data' => [ 'data' => [
'list' => array_reverse($dailyStats), 'list' => array_reverse($dailyStats),
'summary' => $summary, 'summary' => $summary,
'pagination' => [
'total' => $total,
'current_page' => $page,
'page_size' => $pageSize,
'total_pages' => ceil($total / $pageSize)
]
] ]
]; ];
} }

View File

@ -70,9 +70,7 @@ class UserController extends Controller
$this->applyFiltersAndSorts($request, $userModel); $this->applyFiltersAndSorts($request, $userModel);
$users = $userModel->orderBy('id', 'desc')->paginate($pageSize, ['*'], 'page', $current); $users = $userModel->orderBy('id', 'desc')->paginate($pageSize, ['*'], 'page', $current);
$users->getCollection()->transform(function ($user) { $users->getCollection()->transform(function ($user) {
$user->subscribe_url = Helper::getSubscribeUrl($user->token); $user->subscribe_url = Helper::getSubscribeUrl( $user->token);
$user->balance = $user->balance / 100;
$user->commission_balance = $user->commission_balance / 100;
return $user; return $user;
}); });
return response([ return response([
@ -129,13 +127,7 @@ class UserController extends Controller
if (isset($params['banned']) && (int) $params['banned'] === 1) { if (isset($params['banned']) && (int) $params['banned'] === 1) {
$authService = new AuthService($user); $authService = new AuthService($user);
$authService->removeSession(); $authService->removeAllSession();
}
if (isset($params['balance'])) {
$params['balance'] = $params['balance'] * 100;
}
if (isset($params['commission_balance'])) {
$params['commission_balance'] = $params['commission_balance'] * 100;
} }
try { try {

View File

@ -42,7 +42,7 @@ class AuthService
return $this->user->tokens()->get()->toArray(); return $this->user->tokens()->get()->toArray();
} }
public function removeSession(): bool public function removeSession(string $sessionId): bool
{ {
$this->user->tokens()->delete(); $this->user->tokens()->delete();
return true; return true;

View File

@ -129,7 +129,7 @@ class ThemeService
*/ */
public function delete(string $theme): bool public function delete(string $theme): bool
{ {
if ($theme === admin_setting('current_theme') || in_array($theme, ['Xboard', 'v2board'])) { if ($theme === admin_setting('current_theme')) {
throw new Exception('Cannot delete active theme'); throw new Exception('Cannot delete active theme');
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long