diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 900be598e..cbf891a0c 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -74,12 +74,13 @@ public static function createFromRequest( $orderService->setVipDiscount($user); $orderService->setOrderType($user); - $orderService->setInvite(user: $user); if ($user->balance && $order->total_amount > 0) { $orderService->handleUserBalance($user, $userService); } + $orderService->setInvite(user: $user); + if (!$order->save()) { throw new ApiException(__('Failed to create order')); } diff --git a/app/Services/PlanService.php b/app/Services/PlanService.php index e67363d2c..0d729d451 100644 --- a/app/Services/PlanService.php +++ b/app/Services/PlanService.php @@ -158,7 +158,12 @@ protected function validatePlanAvailability(User $user): void } if (!$this->plan->show && $this->plan->renew && !app(UserService::class)->isAvailable($user)) { + // 只有当用户不是当前套餐时才拒绝 + if ($user->plan_id !== $this->plan->id) { throw new ApiException(__('This subscription has expired, please change to another subscription')); + } + // 如果是续费原套餐,允许操作 + return; } }