mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-03 02:58:42 +00:00
Extract ActivePaying function to UserService
This commit is contained in:
@@ -17,6 +17,7 @@ use App\Notifications\TicketCreated;
|
||||
use App\Notifications\TicketReplied;
|
||||
use App\Services\CouponService;
|
||||
use App\Services\ProxyService;
|
||||
use App\Services\UserService;
|
||||
use Cache;
|
||||
use DB;
|
||||
use Exception;
|
||||
@@ -43,6 +44,7 @@ class UserController extends Controller
|
||||
auth()->loginUsingId(Session::get('user'));
|
||||
Session::forget('user');
|
||||
}
|
||||
$userService = UserService::getInstance();
|
||||
$user = auth()->user();
|
||||
$totalTransfer = $user->transfer_enable;
|
||||
$usedTransfer = $user->used_traffic;
|
||||
@@ -69,7 +71,7 @@ class UserController extends Controller
|
||||
'unusedPercent' => $totalTransfer > 0 ? round($unusedTraffic / $totalTransfer, 2) * 100 : 0,
|
||||
'announcements' => Article::type(2)->latest()->simplePaginate(1), // 公告
|
||||
'isTrafficWarning' => $user->isTrafficWarning(), // 流量异常判断
|
||||
'paying_user' => $user->activePayingUser(), // 付费用户判断
|
||||
'paying_user' => $userService->isActivePaying(), // 付费用户判断
|
||||
'userLoginLog' => $user->loginLogs()->latest()->first(), // 近期登录日志
|
||||
'subscribe_status' => $user->subscribe->status,
|
||||
'subType' => $subType,
|
||||
|
||||
@@ -303,11 +303,6 @@ class User extends Authenticatable
|
||||
return UserHourlyDataFlow::userRecentUsed($this->id)->sum('total');
|
||||
}
|
||||
|
||||
public function activePayingUser()
|
||||
{ //付费用户判断
|
||||
return $this->orders()->active()->where('origin_amount', '>', 0)->exists();
|
||||
}
|
||||
|
||||
public function orders(): HasMany
|
||||
{
|
||||
return $this->hasMany(Order::class);
|
||||
|
||||
@@ -59,4 +59,9 @@ class UserService extends BaseService
|
||||
|
||||
return $isCode ? $aff : sysConfig('website_url').route('register', ['aff' => 1], false);
|
||||
}
|
||||
|
||||
public function isActivePaying(): bool
|
||||
{
|
||||
return self::$user->orders()->active()->where('origin_amount', '>', 0)->exists();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user