update: logic optimization

This commit is contained in:
tokumeikoi
2021-12-31 01:48:21 +08:00
parent e1a8d6ca35
commit 45a5022d82
8 changed files with 1257 additions and 1244 deletions

View File

@ -78,6 +78,16 @@ class OrderController extends Controller
abort(500, __('Subscription plan does not exist'));
}
if ($plan[$request->input('period')] === NULL) {
abort(500, __('This payment period cannot be purchased, please choose another period'));
}
if ($request->input('period') === 'reset_price') {
if ($user->expired_at <= time() || !$user->plan_id) {
abort(500, __('Subscription has expired or no active subscription, unable to purchase Data Reset Package'));
}
}
if ((!$plan->show && !$plan->renew) || (!$plan->show && $user->plan_id !== $plan->id)) {
if ($request->input('period') !== 'reset_price') {
abort(500, __('This subscription has been sold out, please choose another subscription'));
@ -88,15 +98,6 @@ class OrderController extends Controller
abort(500, __('This subscription cannot be renewed, please change to another subscription'));
}
if ($plan[$request->input('period')] === NULL) {
abort(500, __('This payment period cannot be purchased, please choose another period'));
}
if ($request->input('period') === 'reset_price') {
if ($user->expired_at <= time() || !$user->plan_id) {
abort(500, __('Subscription has expired or no active subscription, unable to purchase Data Reset Package'));
}
}
if (!$plan->show && $plan->renew && !$userService->isAvailable($user)) {
abort(500, __('This subscription has expired, please change to another subscription'));