You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.6 KiB
PHTML
55 lines
1.6 KiB
PHTML
|
2 months ago
|
<?php
|
||
|
|
|
||
|
|
namespace App\Services;
|
||
|
|
|
||
|
|
use App\Models\User;
|
||
|
|
|
||
|
|
class UserFeatureRestrictionService
|
||
|
|
{
|
||
|
|
public const RECHARGE_MESSAGE = '充值服务暂时无法使用,请稍后再试。';
|
||
|
|
public const PURCHASE_MESSAGE = '套餐购买服务暂时无法使用,请稍后再试。';
|
||
|
|
public const INVITE_MESSAGE = '邀请服务暂时无法使用,请稍后再试。';
|
||
|
|
public const TICKET_MESSAGE = '工单服务暂时无法使用,请稍后再试。';
|
||
|
|
|
||
|
|
public static function isRechargeRestricted(User $user)
|
||
|
|
{
|
||
|
|
return (int) $user->restrict_recharge === 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function isBalancePurchaseRestricted(User $user)
|
||
|
|
{
|
||
|
|
return (int) $user->restrict_balance_purchase === 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function isInviteRestricted(User $user)
|
||
|
|
{
|
||
|
|
return (int) $user->restrict_invite === 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function isTicketRestricted(User $user)
|
||
|
|
{
|
||
|
|
return (int) $user->restrict_ticket === 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function isTransactionRecordsRestricted(User $user)
|
||
|
|
{
|
||
|
|
return (int) $user->restrict_transaction_records === 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function hasManualRestrictions(User $user)
|
||
|
|
{
|
||
|
|
return in_array(true, self::status($user), true);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function status(User $user)
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'recharge' => self::isRechargeRestricted($user),
|
||
|
|
'balance_purchase' => self::isBalancePurchaseRestricted($user),
|
||
|
|
'invite' => self::isInviteRestricted($user),
|
||
|
|
'ticket' => self::isTicketRestricted($user),
|
||
|
|
'transaction_records' => self::isTransactionRecordsRestricted($user),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|