update: package limit

This commit is contained in:
tokumeikoi
2022-08-02 16:37:42 +08:00
parent b0687b9dfd
commit 1c644e8c5f
7 changed files with 16 additions and 16 deletions

View File

@ -85,7 +85,7 @@ class OrderController extends Controller
abort(500, __('Subscription plan does not exist'));
}
if (!$planService->haveCapacity()) {
if (!$planService->haveCapacity() && $request->input('period') !== 'reset_price') {
abort(500, __('Current product is sold out'));
}

View File

@ -18,7 +18,8 @@ class PlanService
public function haveCapacity(): bool
{
if ($this->plan->capacity_limit === NULL) return true;
$count = User::where('plan_id', $this->plan->plan_id)->count();
$count = self::countActiveUsers();
$count = $count[$this->plan->plan_id];
return ($this->plan->capacity_limit - $count) > 0;
}

View File

@ -55,7 +55,6 @@ class UserService
{
if ($user->expired_at <= time() || $user->expired_at === NULL) return null;
// if reset method is not reset
if (!isset($user->plan->reset_traffic_method)) return null;
if ($user->plan->reset_traffic_method === 2) return null;
switch (true) {
case ($user->plan->reset_traffic_method === NULL): {